aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/pathlocks.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-02-12 16:56:12 +0100
committerEelco Dolstra <edolstra@gmail.com>2018-02-12 17:06:06 +0100
commit4f09ce7940689887a18d4aa44367d2e6abeaa3cf (patch)
tree25f9fe61ac75c54cc60d8348b40593c9aa0112b5 /src/libstore/pathlocks.hh
parent35fd31770c589f28c569e7868f868a5b558cf83d (diff)
Fix 'deadlock: trying to re-acquire self-held lock'
This was caused by derivations with 'allowSubstitutes = false'. Such derivations will be built locally. However, if there is another SubstitionGoal that has the output of the first derivation in its closure, then the path will be simultaneously built and substituted. There was a check to catch this situation (via pathIsLockedByMe()), but it no longer worked reliably because substitutions are now done in another thread. (Thus the comment 'It can't happen between here and the lockPaths() call below because we're not allowing multi-threading' was no longer valid.) The fix is to handle the path already being locked in both SubstitutionGoal and DerivationGoal.
Diffstat (limited to 'src/libstore/pathlocks.hh')
-rw-r--r--src/libstore/pathlocks.hh6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/libstore/pathlocks.hh b/src/libstore/pathlocks.hh
index 2a7de6114..db51f950a 100644
--- a/src/libstore/pathlocks.hh
+++ b/src/libstore/pathlocks.hh
@@ -2,10 +2,8 @@
#include "util.hh"
-
namespace nix {
-
/* Open (possibly create) a lock file and return the file descriptor.
-1 is returned if create is false and the lock could not be opened
because it doesn't exist. Any other error throws an exception. */
@@ -18,6 +16,7 @@ enum LockType { ltRead, ltWrite, ltNone };
bool lockFile(int fd, LockType lockType, bool wait);
+MakeError(AlreadyLocked, Error);
class PathLocks
{
@@ -38,9 +37,6 @@ public:
void setDeletion(bool deletePaths);
};
-
-// FIXME: not thread-safe!
bool pathIsLockedByMe(const Path & path);
-
}