Author: eelco Date: 2010-06-21 11:08:09 +0000 (Mon, 21 Jun 2010) New Revision: 22354
You can view the changes in this commit at: https://svn.nixos.org/viewvc/nix?rev=22354&view=rev Modified: nix/branches/sqlite/src/libstore/local-store.cc nix/branches/sqlite/src/libstore/local-store.hh Log: * Okay, putting a lock on the temporary directory used by importPath() doesn't work because the garbage collector doesn't actually look at locks. So r22253 was stupid. Use addTempRoot() instead. Also, locking the temporary directory in exportPath() was silly because it isn't even in the store. Changes: Modified: nix/branches/sqlite/src/libstore/local-store.cc =================================================================== --- nix/branches/sqlite/src/libstore/local-store.cc 2010-06-21 08:38:45 UTC (rev 22353) +++ nix/branches/sqlite/src/libstore/local-store.cc 2010-06-21 11:08:09 UTC (rev 22354) @@ -1036,8 +1036,6 @@ writeInt(1, hashAndWriteSink); Path tmpDir = createTempDir(); - PathLocks tmpDirLock(singleton<PathSet, Path>(tmpDir)); - tmpDirLock.setDeletion(true); AutoDelete delTmp(tmpDir); Path hashFile = tmpDir + "/hash"; writeFile(hashFile, printHash(hash)); @@ -1079,6 +1077,22 @@ }; +/* Create a temporary directory in the store that won't be + garbage-collected. */ +Path LocalStore::createTempDirInStore() +{ + Path tmpDir; + do { + /* There is a slight possibility that `tmpDir' gets deleted by + the GC between createTempDir() and addTempRoot(), so repeat + until `tmpDir' exists. */ + tmpDir = createTempDir(nixStore); + addTempRoot(tmpDir); + } while (!pathExists(tmpDir)); + return tmpDir; +} + + Path LocalStore::importPath(bool requireSignature, Source & source) { HashAndReadSource hashAndReadSource(source); @@ -1086,10 +1100,8 @@ /* We don't yet know what store path this archive contains (the store path follows the archive data proper), and besides, we don't know yet whether the signature is valid. */ - Path tmpDir = createTempDir(nixStore); - PathLocks tmpDirLock(singleton<PathSet, Path>(tmpDir)); - tmpDirLock.setDeletion(true); - AutoDelete delTmp(tmpDir); /* !!! could be GC'ed! */ + Path tmpDir = createTempDirInStore(); + AutoDelete delTmp(tmpDir); Path unpacked = tmpDir + "/unpacked"; restorePath(unpacked, hashAndReadSource); Modified: nix/branches/sqlite/src/libstore/local-store.hh =================================================================== --- nix/branches/sqlite/src/libstore/local-store.hh 2010-06-21 08:38:45 UTC (rev 22353) +++ nix/branches/sqlite/src/libstore/local-store.hh 2010-06-21 11:08:09 UTC (rev 22354) @@ -246,6 +246,8 @@ void startSubstituter(const Path & substituter, RunningSubstituter & runningSubstituter); + + Path createTempDirInStore(); }; _______________________________________________ nix-commits mailing list nix-comm...@cs.uu.nl http://mail.cs.uu.nl/mailman/listinfo/nix-commits