diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-12-02T16·41+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-12-02T16·41+0000 |
commit | e25fad691aa3ccb492c4fb8840289f76151e553e (patch) | |
tree | 1610455ac3d4d1d0b992f56e10825cf91e1445e5 /src/libstore/gc.cc | |
parent | 30bf547f4f5bc881eb60c9e11020d077fbb8b899 (diff) |
* Move addTempRoot() to the store API, and add another function
syncWithGC() to allow clients to register GC roots without needing write access to the global roots directory or the GC lock.
Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r-- | src/libstore/gc.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 3e4150d89811..56e64369a741 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -76,6 +76,12 @@ void createSymlink(const Path & link, const Path & target, bool careful) } +void LocalStore::syncWithGC() +{ + AutoCloseFD fdGCLock = openGCLock(ltRead); +} + + Path addPermRoot(const Path & _storePath, const Path & _gcRoot, bool indirect, bool allowOutsideRootsDir) { @@ -83,10 +89,6 @@ Path addPermRoot(const Path & _storePath, const Path & _gcRoot, Path gcRoot(canonPath(_gcRoot)); assertStorePath(storePath); - /* Grab the global GC root. This prevents the set of permanent - roots from increasing while a GC is in progress. */ - AutoCloseFD fdGCLock = openGCLock(ltRead); - if (indirect) { string hash = printHash32(hashString(htSHA1, gcRoot)); Path realRoot = canonPath((format("%1%/%2%/auto/%3%") @@ -110,6 +112,11 @@ Path addPermRoot(const Path & _storePath, const Path & _gcRoot, createSymlink(gcRoot, storePath, false); } + /* Grab the global GC root, causing us to block while a GC is in + progress. This prevents the set of permanent roots from + increasing while a GC is in progress. */ + store->syncWithGC(); + return gcRoot; } @@ -119,7 +126,7 @@ static Path fnTempRoots; static AutoCloseFD fdTempRoots; -void addTempRoot(const Path & path) +void LocalStore::addTempRoot(const Path & path) { /* Create the temporary roots file for this process. */ if (fdTempRoots == -1) { |