diff options
Diffstat (limited to 'src/libstore/pathlocks.hh')
-rw-r--r-- | src/libstore/pathlocks.hh | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/libstore/pathlocks.hh b/src/libstore/pathlocks.hh index 411da0222..5e3a734b4 100644 --- a/src/libstore/pathlocks.hh +++ b/src/libstore/pathlocks.hh @@ -20,19 +20,33 @@ class PathLocks { private: typedef std::pair<int, Path> FDPair; - list<FDPair> fds; + std::list<FDPair> fds; bool deletePaths; public: PathLocks(); PathLocks(const PathSet & paths, - const string & waitMsg = ""); + const std::string & waitMsg = ""); bool lockPaths(const PathSet & _paths, - const string & waitMsg = "", + const std::string & waitMsg = "", bool wait = true); ~PathLocks(); void unlock(); void setDeletion(bool deletePaths); }; +struct FdLock +{ + int fd; + bool acquired = false; + + FdLock(int fd, LockType lockType, bool wait, std::string_view waitMsg); + + ~FdLock() + { + if (acquired) + lockFile(fd, ltNone, false); + } +}; + } |