mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
* Acquire a lock on the output path when running a substitute. Also
delete obstructing invalid paths.
This commit is contained in:
parent
72c857f0eb
commit
3f3a3ae87b
1 changed files with 22 additions and 0 deletions
|
@ -1207,6 +1207,9 @@ private:
|
||||||
/* The process ID of the builder. */
|
/* The process ID of the builder. */
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
|
/* Lock on the store path. */
|
||||||
|
PathLocks outputLock;
|
||||||
|
|
||||||
typedef void (SubstitutionGoal::*GoalState)();
|
typedef void (SubstitutionGoal::*GoalState)();
|
||||||
GoalState state;
|
GoalState state;
|
||||||
|
|
||||||
|
@ -1316,6 +1319,23 @@ void SubstitutionGoal::exprRealised()
|
||||||
|
|
||||||
logPipe.create();
|
logPipe.create();
|
||||||
|
|
||||||
|
/* Acquire a lock on the output path. */
|
||||||
|
PathSet lockPath;
|
||||||
|
lockPath.insert(storePath);
|
||||||
|
outputLock.lockPaths(lockPath);
|
||||||
|
|
||||||
|
/* Check again whether the path is invalid. */
|
||||||
|
if (isValidPath(storePath)) {
|
||||||
|
debug(format("store path `%1%' has become valid") % storePath);
|
||||||
|
outputLock.setDeletion(true);
|
||||||
|
amDone();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove the (stale) output path if it exists. */
|
||||||
|
if (pathExists(storePath))
|
||||||
|
deletePath(storePath);
|
||||||
|
|
||||||
/* Fork the substitute program. */
|
/* Fork the substitute program. */
|
||||||
switch (pid = fork()) {
|
switch (pid = fork()) {
|
||||||
|
|
||||||
|
@ -1425,6 +1445,8 @@ void SubstitutionGoal::finished()
|
||||||
registerValidPath(txn, storePath);
|
registerValidPath(txn, storePath);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
|
outputLock.setDeletion(true);
|
||||||
|
|
||||||
amDone();
|
amDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue