* Remove lock files after building.

This commit is contained in:
Eelco Dolstra 2003-11-21 16:05:19 +00:00
parent 06208d1d86
commit 7a02d95418
3 changed files with 20 additions and 1 deletions

View file

@ -256,6 +256,11 @@ Path normaliseStoreExpr(const Path & _nePath, PathSet pending)
registerSuccessor(txn, nePath, nfPath);
txn.commit();
/* It is now safe to delete the lock files, since all future
lockers will see the successor; they will not create new lock
files with the same names as the old (unlinked) lock files. */
outputLocks.setDeletion(true);
return nfPath;
}

View file

@ -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;
}

View file

@ -14,10 +14,12 @@ class PathLocks
private:
list<int> fds;
Paths paths;
bool deletePaths;
public:
PathLocks(const PathSet & _paths);
~PathLocks();
void setDeletion(bool deletePaths);
};