1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56: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; bool useHook;
while (true) {
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.
@ -500,7 +501,8 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
} }
if (!outputLocks.lockPaths(lockFiles, "", false)) { 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 /* Wait then try locking again, repeat until success (returned
boolean is true). */ boolean is true). */
@ -538,8 +540,8 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
/* Don't do a remote build if the derivation has the attribute /* Don't do a remote build if the derivation has the attribute
`preferLocalBuild' set. Also, check and repair modes are only `preferLocalBuild' set. Also, check and repair modes are only
supported for local builds. */ supported for local builds. */
bool buildLocally = bool buildLocally = (buildMode != bmNormal || drvOptions->willBuildLocally(worker.store, *drv))
(buildMode != bmNormal || drvOptions->willBuildLocally(worker.store, *drv)) && settings.maxBuildJobs.get() != 0; && settings.maxBuildJobs.get() != 0;
if (buildLocally) { if (buildLocally) {
useHook = false; useHook = false;
@ -561,13 +563,15 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
fmt("waiting for a machine to build '%s'", Magenta(worker.store.printStorePath(drvPath)))); fmt("waiting for a machine to build '%s'", Magenta(worker.store.printStorePath(drvPath))));
outputLocks.unlock(); outputLocks.unlock();
co_await waitForAWhile(); co_await waitForAWhile();
co_return tryToBuild(); continue;
case rpDecline: case rpDecline:
/* We should do it ourselves. */ /* We should do it ourselves. */
useHook = false; useHook = false;
break; break;
} }
} }
break;
}
actLock.reset(); actLock.reset();