aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libstore/build/derivation-goal.cc15
-rw-r--r--src/libstore/build/derivation-goal.hh2
-rw-r--r--src/libstore/build/drv-output-substitution-goal.cc4
-rw-r--r--src/libstore/build/goal.hh4
-rw-r--r--src/libstore/build/local-derivation-goal.cc2
-rw-r--r--src/libstore/build/substitution-goal.cc4
-rw-r--r--src/libstore/build/worker.cc11
7 files changed, 19 insertions, 23 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index b8c4d278d..037b4fb10 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -787,7 +787,7 @@ try {
buildResult.startTime = time(0); // inexact
state = &DerivationGoal::buildDone;
started();
- return {{WaitForWorld{std::move(a.promise)}}};
+ return continueOrError(std::move(a.promise));
},
[&](HookReply::Postpone) -> std::optional<kj::Promise<Result<WorkResult>>> {
/* Not now; wait until at least one child finishes or
@@ -1756,4 +1756,17 @@ void DerivationGoal::waiteeDone(GoalPtr waitee)
}
}
+kj::Promise<Result<Goal::WorkResult>>
+DerivationGoal::continueOrError(kj::Promise<Outcome<void, Goal::Finished>> p)
+{
+ return p.then([](auto r) -> Result<WorkResult> {
+ if (r.has_value()) {
+ return ContinueImmediately{};
+ } else if (r.has_error()) {
+ return r.assume_error();
+ } else {
+ return r.assume_exception();
+ }
+ });
+}
}
diff --git a/src/libstore/build/derivation-goal.hh b/src/libstore/build/derivation-goal.hh
index d60bb0b4c..b1311bd7e 100644
--- a/src/libstore/build/derivation-goal.hh
+++ b/src/libstore/build/derivation-goal.hh
@@ -327,6 +327,8 @@ protected:
Finished tooMuchLogs();
void flushLine();
+ static kj::Promise<Result<WorkResult>> continueOrError(kj::Promise<Outcome<void, Goal::Finished>> p);
+
public:
/**
* Wrappers around the corresponding Store methods that first consult the
diff --git a/src/libstore/build/drv-output-substitution-goal.cc b/src/libstore/build/drv-output-substitution-goal.cc
index 80b2c4cfb..923cbba58 100644
--- a/src/libstore/build/drv-output-substitution-goal.cc
+++ b/src/libstore/build/drv-output-substitution-goal.cc
@@ -86,9 +86,7 @@ try {
});
state = &DrvOutputSubstitutionGoal::realisationFetched;
- return {WaitForWorld{
- pipe.promise.then([]() -> Outcome<void, Finished> { return result::success(); })
- }};
+ return pipe.promise.then([]() -> Result<WorkResult> { return ContinueImmediately{}; });
} catch (...) {
return {std::current_exception()};
}
diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh
index e7a500a00..7933fbc31 100644
--- a/src/libstore/build/goal.hh
+++ b/src/libstore/build/goal.hh
@@ -115,9 +115,6 @@ public:
struct [[nodiscard]] StillAlive {};
struct [[nodiscard]] ContinueImmediately {};
- struct [[nodiscard]] WaitForWorld {
- kj::Promise<Outcome<void, Finished>> promise;
- };
struct [[nodiscard]] Finished {
ExitCode exitCode;
BuildResult result;
@@ -131,7 +128,6 @@ public:
struct [[nodiscard]] WorkResult : std::variant<
StillAlive,
ContinueImmediately,
- WaitForWorld,
Finished>
{
WorkResult() = delete;
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc
index 2443cfb5a..a32f742f4 100644
--- a/src/libstore/build/local-derivation-goal.cc
+++ b/src/libstore/build/local-derivation-goal.cc
@@ -251,7 +251,7 @@ try {
state = &DerivationGoal::buildDone;
started();
- return {WaitForWorld{std::move(promise)}};
+ return continueOrError(std::move(promise));
} catch (BuildError & e) {
outputLocks.unlock();
diff --git a/src/libstore/build/substitution-goal.cc b/src/libstore/build/substitution-goal.cc
index 74a63ca21..d9d8f1a7d 100644
--- a/src/libstore/build/substitution-goal.cc
+++ b/src/libstore/build/substitution-goal.cc
@@ -240,9 +240,7 @@ try {
});
state = &PathSubstitutionGoal::finished;
- return {WaitForWorld{
- pipe.promise.then([]() -> Outcome<void, Finished> { return result::success(); })
- }};
+ return pipe.promise.then([]() -> Result<WorkResult> { return ContinueImmediately{}; });
} catch (...) {
return {std::current_exception()};
}
diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc
index 18cdde63a..1b1bf1d5c 100644
--- a/src/libstore/build/worker.cc
+++ b/src/libstore/build/worker.cc
@@ -202,17 +202,6 @@ void Worker::handleWorkResult(GoalPtr goal, Goal::WorkResult how)
overloaded{
[&](Goal::StillAlive) {},
[&](Goal::ContinueImmediately) { wakeUp(goal); },
- [&](Goal::WaitForWorld & w) {
- childStarted(goal, w.promise.then([](auto r) -> Result<Goal::WorkResult> {
- if (r.has_value()) {
- return {Goal::ContinueImmediately{}};
- } else if (r.has_error()) {
- return {std::move(r).error()};
- } else {
- return r.exception();
- }
- }));
- },
[&](Goal::Finished & f) { goalFinished(goal, f); },
},
how