diff options
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build/drv-output-substitution-goal.cc | 3 | ||||
-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/substitution-goal.cc | 3 | ||||
-rw-r--r-- | src/libstore/build/worker.cc | 1 | ||||
-rw-r--r-- | src/libstore/build/worker.hh | 12 |
6 files changed, 12 insertions, 13 deletions
diff --git a/src/libstore/build/drv-output-substitution-goal.cc b/src/libstore/build/drv-output-substitution-goal.cc index 62e86e1cc..068f41a49 100644 --- a/src/libstore/build/drv-output-substitution-goal.cc +++ b/src/libstore/build/drv-output-substitution-goal.cc @@ -41,8 +41,7 @@ Goal::WorkResult DrvOutputSubstitutionGoal::tryNext() if maxSubstitutionJobs == 0, we still allow a substituter to run. This prevents infinite waiting. */ if (worker.runningSubstitutions >= std::max(1U, settings.maxSubstitutionJobs.get())) { - worker.waitForBuildSlot(shared_from_this()); - return StillAlive{}; + return WaitForSlot{}; } maintainRunningSubstitutions = diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh index dd29b9fc4..bf3677bb2 100644 --- a/src/libstore/build/goal.hh +++ b/src/libstore/build/goal.hh @@ -106,12 +106,13 @@ struct Goal : public std::enable_shared_from_this<Goal> public: struct [[nodiscard]] StillAlive {}; + struct [[nodiscard]] WaitForSlot {}; struct [[nodiscard]] Finished { ExitCode result; std::unique_ptr<Error> ex; }; - struct [[nodiscard]] WorkResult : std::variant<StillAlive, Finished> + struct [[nodiscard]] WorkResult : std::variant<StillAlive, WaitForSlot, 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 db380e07c..975e21b49 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -158,9 +158,8 @@ Goal::WorkResult LocalDerivationGoal::tryLocalBuild() unsigned int curBuilds = worker.getNrLocalBuilds(); if (curBuilds >= settings.maxBuildJobs) { state = &DerivationGoal::tryToBuild; - worker.waitForBuildSlot(shared_from_this()); outputLocks.unlock(); - return StillAlive{}; + return WaitForSlot{}; } assert(derivationType); diff --git a/src/libstore/build/substitution-goal.cc b/src/libstore/build/substitution-goal.cc index fb2949fd0..192ddc572 100644 --- a/src/libstore/build/substitution-goal.cc +++ b/src/libstore/build/substitution-goal.cc @@ -194,8 +194,7 @@ Goal::WorkResult PathSubstitutionGoal::tryToRun() if maxSubstitutionJobs == 0, we still allow a substituter to run. This prevents infinite waiting. */ if (worker.getNrSubstitutions() >= std::max(1U, (unsigned int) settings.maxSubstitutionJobs)) { - worker.waitForBuildSlot(shared_from_this()); - return StillAlive{}; + return WaitForSlot{}; } maintainRunningSubstitutions = std::make_unique<MaintainCount<uint64_t>>(worker.runningSubstitutions); diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc index 84727a377..46f1d50e6 100644 --- a/src/libstore/build/worker.cc +++ b/src/libstore/build/worker.cc @@ -187,6 +187,7 @@ void Worker::handleWorkResult(GoalPtr goal, Goal::WorkResult how) std::visit( overloaded{ [&](Goal::StillAlive) {}, + [&](Goal::WaitForSlot) { waitForBuildSlot(goal); }, [&](Goal::Finished & f) { goalFinished(goal, f); }, }, how diff --git a/src/libstore/build/worker.hh b/src/libstore/build/worker.hh index 5af93b49e..101e553fd 100644 --- a/src/libstore/build/worker.hh +++ b/src/libstore/build/worker.hh @@ -108,6 +108,12 @@ private: void goalFinished(GoalPtr goal, Goal::Finished & f); void handleWorkResult(GoalPtr goal, Goal::WorkResult how); + /** + * Put `goal` to sleep until a build slot becomes available (which + * might be right away). + */ + void waitForBuildSlot(GoalPtr goal); + public: const Activity act; @@ -234,12 +240,6 @@ public: void childTerminated(Goal * goal); /** - * Put `goal` to sleep until a build slot becomes available (which - * might be right away). - */ - 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 |