1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

* 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.
This commit is contained in:
Eelco Dolstra 2006-12-02 16:41:36 +00:00
parent 30bf547f4f
commit e25fad691a
11 changed files with 81 additions and 17 deletions

View file

@ -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) {