diff options
-rw-r--r-- | src/libstore/build/derivation-goal.cc | 6 | ||||
-rw-r--r-- | src/libstore/build/goal.hh | 3 | ||||
-rw-r--r-- | src/libstore/build/local-derivation-goal.cc | 3 | ||||
-rw-r--r-- | src/libstore/build/worker.cc | 1 | ||||
-rw-r--r-- | src/libstore/build/worker.hh | 16 |
5 files changed, 14 insertions, 15 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 17a2b04f1..bcef9807b 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -701,8 +701,7 @@ Goal::WorkResult DerivationGoal::tryToBuild() if (!actLock) actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting, fmt("waiting for lock on %s", Magenta(showPaths(lockFiles)))); - worker.waitForAWhile(shared_from_this()); - return StillAlive{}; + return WaitForAWhile{}; } actLock.reset(); @@ -753,9 +752,8 @@ Goal::WorkResult DerivationGoal::tryToBuild() if (!actLock) actLock = std::make_unique<Activity>(*logger, lvlTalkative, actBuildWaiting, fmt("waiting for a machine to build '%s'", Magenta(worker.store.printStorePath(drvPath)))); - worker.waitForAWhile(shared_from_this()); outputLocks.unlock(); - return StillAlive{}; + return WaitForAWhile{}; case rpDecline: /* We should do it ourselves. */ break; diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh index bf3677bb2..f41fbea2f 100644 --- a/src/libstore/build/goal.hh +++ b/src/libstore/build/goal.hh @@ -107,12 +107,13 @@ public: struct [[nodiscard]] StillAlive {}; struct [[nodiscard]] WaitForSlot {}; + struct [[nodiscard]] WaitForAWhile {}; struct [[nodiscard]] Finished { ExitCode result; std::unique_ptr<Error> ex; }; - struct [[nodiscard]] WorkResult : std::variant<StillAlive, WaitForSlot, Finished> + struct [[nodiscard]] WorkResult : std::variant<StillAlive, WaitForSlot, WaitForAWhile, Finished> { WorkResult() = delete; using variant::variant; diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index 975e21b49..3618aa191 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -201,8 +201,7 @@ Goal::WorkResult LocalDerivationGoal::tryLocalBuild() if (!actLock) actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting, fmt("waiting for a free build user ID for '%s'", Magenta(worker.store.printStorePath(drvPath)))); - worker.waitForAWhile(shared_from_this()); - return StillAlive{}; + return WaitForAWhile{}; } } diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc index 46f1d50e6..722956e0d 100644 --- a/src/libstore/build/worker.cc +++ b/src/libstore/build/worker.cc @@ -188,6 +188,7 @@ void Worker::handleWorkResult(GoalPtr goal, Goal::WorkResult how) overloaded{ [&](Goal::StillAlive) {}, [&](Goal::WaitForSlot) { waitForBuildSlot(goal); }, + [&](Goal::WaitForAWhile) { waitForAWhile(goal); }, [&](Goal::Finished & f) { goalFinished(goal, f); }, }, how diff --git a/src/libstore/build/worker.hh b/src/libstore/build/worker.hh index 101e553fd..3644039fb 100644 --- a/src/libstore/build/worker.hh +++ b/src/libstore/build/worker.hh @@ -114,6 +114,14 @@ private: */ void waitForBuildSlot(GoalPtr goal); + /** + * Wait for a few seconds and then retry this goal. Used when + * waiting for a lock held by another process. This kind of + * polling is inefficient, but POSIX doesn't really provide a way + * to wait for multiple locks in the main select() loop. + */ + void waitForAWhile(GoalPtr goal); + public: const Activity act; @@ -240,14 +248,6 @@ public: void childTerminated(Goal * goal); /** - * Wait for a few seconds and then retry this goal. Used when - * waiting for a lock held by another process. This kind of - * polling is inefficient, but POSIX doesn't really provide a way - * to wait for multiple locks in the main select() loop. - */ - void waitForAWhile(GoalPtr goal); - - /** * Loop until the specified top-level goals have finished. */ void run(const Goals & topGoals); |