1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 12:06:01 +01:00

Get rid of a tryToBuild tail recursive call with loop

This will make it easier to convert somethings to RAII.
This commit is contained in:
John Ericson 2025-08-29 13:59:47 -04:00
parent 95c5779880
commit 4c44a213a3

View file

@ -472,6 +472,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
{
bool useHook;
while (true) {
trace("trying to build");
/* Obtain locks on all output paths, if the paths are known a priori.
@ -500,7 +501,8 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
}
if (!outputLocks.lockPaths(lockFiles, "", false)) {
Activity act(*logger, lvlWarn, actBuildWaiting, fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));
Activity act(
*logger, lvlWarn, actBuildWaiting, fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));
/* Wait then try locking again, repeat until success (returned
boolean is true). */
@ -538,8 +540,8 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
/* Don't do a remote build if the derivation has the attribute
`preferLocalBuild' set. Also, check and repair modes are only
supported for local builds. */
bool buildLocally =
(buildMode != bmNormal || drvOptions->willBuildLocally(worker.store, *drv)) && settings.maxBuildJobs.get() != 0;
bool buildLocally = (buildMode != bmNormal || drvOptions->willBuildLocally(worker.store, *drv))
&& settings.maxBuildJobs.get() != 0;
if (buildLocally) {
useHook = false;
@ -561,13 +563,15 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
fmt("waiting for a machine to build '%s'", Magenta(worker.store.printStorePath(drvPath))));
outputLocks.unlock();
co_await waitForAWhile();
co_return tryToBuild();
continue;
case rpDecline:
/* We should do it ourselves. */
useHook = false;
break;
}
}
break;
}
actLock.reset();