mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
DerivationBuildingGoal::tryToBuild pull hook waiting out of switch
Do this with a new `useHook` boolean we carefully make sure is set in all cases. This change isn't really worthwhile by itself, but it allows us to make further refactors (see later commits) which are well-motivated.
This commit is contained in:
parent
1935c19705
commit
95c5779880
1 changed files with 15 additions and 6 deletions
|
|
@ -470,6 +470,8 @@ void DerivationBuildingGoal::started()
|
||||||
|
|
||||||
Goal::Co DerivationBuildingGoal::tryToBuild()
|
Goal::Co DerivationBuildingGoal::tryToBuild()
|
||||||
{
|
{
|
||||||
|
bool useHook;
|
||||||
|
|
||||||
trace("trying to build");
|
trace("trying to build");
|
||||||
|
|
||||||
/* Obtain locks on all output paths, if the paths are known a priori.
|
/* Obtain locks on all output paths, if the paths are known a priori.
|
||||||
|
|
@ -539,16 +541,15 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
|
||||||
bool buildLocally =
|
bool buildLocally =
|
||||||
(buildMode != bmNormal || drvOptions->willBuildLocally(worker.store, *drv)) && settings.maxBuildJobs.get() != 0;
|
(buildMode != bmNormal || drvOptions->willBuildLocally(worker.store, *drv)) && settings.maxBuildJobs.get() != 0;
|
||||||
|
|
||||||
if (!buildLocally) {
|
if (buildLocally) {
|
||||||
|
useHook = false;
|
||||||
|
} else {
|
||||||
switch (tryBuildHook()) {
|
switch (tryBuildHook()) {
|
||||||
case rpAccept:
|
case rpAccept:
|
||||||
/* Yes, it has started doing so. Wait until we get
|
/* Yes, it has started doing so. Wait until we get
|
||||||
EOF from the hook. */
|
EOF from the hook. */
|
||||||
actLock.reset();
|
useHook = true;
|
||||||
buildResult.startTime = time(0); // inexact
|
break;
|
||||||
started();
|
|
||||||
co_await Suspend{};
|
|
||||||
co_return hookDone();
|
|
||||||
case rpPostpone:
|
case rpPostpone:
|
||||||
/* Not now; wait until at least one child finishes or
|
/* Not now; wait until at least one child finishes or
|
||||||
the wake-up timeout expires. */
|
the wake-up timeout expires. */
|
||||||
|
|
@ -563,12 +564,20 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
|
||||||
co_return tryToBuild();
|
co_return tryToBuild();
|
||||||
case rpDecline:
|
case rpDecline:
|
||||||
/* We should do it ourselves. */
|
/* We should do it ourselves. */
|
||||||
|
useHook = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actLock.reset();
|
actLock.reset();
|
||||||
|
|
||||||
|
if (useHook) {
|
||||||
|
buildResult.startTime = time(0); // inexact
|
||||||
|
started();
|
||||||
|
co_await Suspend{};
|
||||||
|
co_return hookDone();
|
||||||
|
}
|
||||||
|
|
||||||
co_await yield();
|
co_await yield();
|
||||||
|
|
||||||
if (!dynamic_cast<LocalStore *>(&worker.store)) {
|
if (!dynamic_cast<LocalStore *>(&worker.store)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue