diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-02-28 18:04:39 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-02-28 18:29:33 +0000 |
commit | c863e5f338947ecff275a67725ecf50b2a47bdb5 (patch) | |
tree | 733893d760809edcbc55c7aa8078ab84fcd2aa73 /src/libstore/pathlocks.cc | |
parent | 7869be49c2735280ceabbd13c087b4a06444ae63 (diff) | |
parent | b592359c565e0220545ba146b32f367e4ecdb23f (diff) |
Merge remote-tracking branch 'upstream/master' into trustless-remote-builder-simple
Diffstat (limited to 'src/libstore/pathlocks.cc')
-rw-r--r-- | src/libstore/pathlocks.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/libstore/pathlocks.cc b/src/libstore/pathlocks.cc index 926f4ea1e..42023cd0a 100644 --- a/src/libstore/pathlocks.cc +++ b/src/libstore/pathlocks.cc @@ -74,7 +74,7 @@ PathLocks::PathLocks() } -PathLocks::PathLocks(const PathSet & paths, const string & waitMsg) +PathLocks::PathLocks(const PathSet & paths, const std::string & waitMsg) : deletePaths(false) { lockPaths(paths, waitMsg); @@ -82,7 +82,7 @@ PathLocks::PathLocks(const PathSet & paths, const string & waitMsg) bool PathLocks::lockPaths(const PathSet & paths, - const string & waitMsg, bool wait) + const std::string & waitMsg, bool wait) { assert(fds.empty()); @@ -176,4 +176,17 @@ void PathLocks::setDeletion(bool deletePaths) } +FdLock::FdLock(int fd, LockType lockType, bool wait, std::string_view waitMsg) + : fd(fd) +{ + if (wait) { + if (!lockFile(fd, lockType, false)) { + printInfo("%s", waitMsg); + acquired = lockFile(fd, lockType, true); + } + } else + acquired = lockFile(fd, lockType, false); +} + + } |