diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-08-28 11:36:17 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-08-28 11:36:17 +0000 |
commit | c970b28ba0f8866bde800849120d429d781ccb5d (patch) | |
tree | 2df160bfab85deeac18a34494aa6e65482c88f83 /src/libstore/pathlocks.cc | |
parent | bc0429b1cd94289ac8d8a51f562b920999002b89 (diff) |
* Fix a race condition with parallel builds where multiple
fixed-output derivations or substitutions try to build the same
store path at the same time. Locking generally catches this, but
not between multiple goals in the same process. This happened
especially often (actually, only) in the build farm with fetchurl
downloads of the same file being executed on multiple machines and
then copied back to the main machine where they would clobber each
other (NIXBF-13).
Solution: if a goal notices that the output path is already locked,
then go to sleep until another goal finishes (hopefully the one
locking the path) and try again.
Diffstat (limited to 'src/libstore/pathlocks.cc')
-rw-r--r-- | src/libstore/pathlocks.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstore/pathlocks.cc b/src/libstore/pathlocks.cc index 821d4d02f..9d582206d 100644 --- a/src/libstore/pathlocks.cc +++ b/src/libstore/pathlocks.cc @@ -223,5 +223,12 @@ void PathLocks::setDeletion(bool deletePaths) this->deletePaths = deletePaths; } + +bool pathIsLockedByMe(const Path & path) +{ + Path lockPath = path + ".lock"; + return lockedPaths.find(lockPath) != lockedPaths.end(); +} + } |