diff options
Diffstat (limited to 'src/libstore/build/drv-output-substitution-goal.cc')
-rw-r--r-- | src/libstore/build/drv-output-substitution-goal.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstore/build/drv-output-substitution-goal.cc b/src/libstore/build/drv-output-substitution-goal.cc index b30957c84..0e85650a7 100644 --- a/src/libstore/build/drv-output-substitution-goal.cc +++ b/src/libstore/build/drv-output-substitution-goal.cc @@ -3,6 +3,7 @@ #include "worker.hh" #include "substitution-goal.hh" #include "callback.hh" +#include "signals.hh" namespace nix { @@ -38,6 +39,18 @@ void DrvOutputSubstitutionGoal::tryNext() { trace("trying next substituter"); + /* Make sure that we are allowed to start a substitution. Note that even + if maxSubstitutionJobs == 0, we still allow a substituter to run. This + prevents infinite waiting. */ + if (worker.runningCASubstitutions >= std::max(1U, settings.maxSubstitutionJobs.get())) { + worker.waitForBuildSlot(shared_from_this()); + return; + } + + maintainRunningSubstitutions = + std::make_unique<MaintainCount<uint64_t>>(worker.runningCASubstitutions); + worker.updateProgress(); + if (subs.size() == 0) { /* None left. Terminate this goal and let someone else deal with it. */ @@ -87,6 +100,7 @@ void DrvOutputSubstitutionGoal::tryNext() void DrvOutputSubstitutionGoal::realisationFetched() { worker.childTerminated(this); + maintainRunningSubstitutions.reset(); try { outputInfo = downloadState->promise.get_future().get(); |