1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 07:22:43 +01:00

GC: Don't delete own temproots file

Since file locks are per-process rather than per-file-descriptor, the
garbage collector would always acquire a lock on its own temproots
file and conclude that it's stale.
This commit is contained in:
Eelco Dolstra 2017-09-05 20:39:57 +02:00
parent 8215b75d36
commit b932ea58ec
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 34 additions and 34 deletions

View file

@ -51,6 +51,8 @@ LocalStore::LocalStore(const Params & params)
, reservedPath(dbDir + "/reserved")
, schemaPath(dbDir + "/schema")
, trashDir(realStoreDir + "/trash")
, tempRootsDir(stateDir + "/temproots")
, fnTempRoots(fmt("%s/%d", tempRootsDir, getpid()))
, publicKeys(getDefaultPublicKeys())
{
auto state(_state.lock());
@ -61,7 +63,7 @@ LocalStore::LocalStore(const Params & params)
createDirs(linksDir);
Path profilesDir = stateDir + "/profiles";
createDirs(profilesDir);
createDirs(stateDir + "/temproots");
createDirs(tempRootsDir);
createDirs(dbDir);
Path gcRootsDir = stateDir + "/gcroots";
if (!pathExists(gcRootsDir)) {
@ -242,12 +244,12 @@ LocalStore::LocalStore(const Params & params)
LocalStore::~LocalStore()
{
auto state(_state.lock());
try {
auto state(_state.lock());
if (state->fdTempRoots) {
state->fdTempRoots = -1;
unlink(state->fnTempRoots.c_str());
unlink(fnTempRoots.c_str());
}
} catch (...) {
ignoreException();