diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-21 16:05:19 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-21 16:05:19 +0000 |
commit | 7a02d954186d6ba1ea41d9917d63f9fab84736b3 (patch) | |
tree | 09b42785f1b34f1d6cbe2781e721b9ddd697639a /src/libstore/pathlocks.cc | |
parent | 06208d1d8677eaea1fb56dd09832f43154bbab5d (diff) |
* Remove lock files after building.
Diffstat (limited to 'src/libstore/pathlocks.cc')
-rw-r--r-- | src/libstore/pathlocks.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libstore/pathlocks.cc b/src/libstore/pathlocks.cc index 3ecbbbcba..c057edce1 100644 --- a/src/libstore/pathlocks.cc +++ b/src/libstore/pathlocks.cc @@ -43,6 +43,7 @@ static StringSet lockedPaths; /* !!! not thread-safe */ PathLocks::PathLocks(const PathSet & _paths) + : deletePaths(false) { /* Note that `fds' is built incrementally so that the destructor will only release those locks that we have already acquired. */ @@ -85,6 +86,17 @@ PathLocks::~PathLocks() for (list<int>::iterator i = fds.begin(); i != fds.end(); i++) close(*i); - for (Paths::iterator i = paths.begin(); i != paths.end(); i++) + for (Paths::iterator i = paths.begin(); i != paths.end(); i++) { + if (deletePaths) + /* This is not safe in general! */ + if (unlink(i->c_str()) != 0) + throw SysError(format("removing lock file `%1%'") % *i); lockedPaths.erase(*i); + } +} + + +void PathLocks::setDeletion(bool deletePaths) +{ + this->deletePaths = deletePaths; } |