aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/worker.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-10-05 00:38:35 +0200
committereldritch horrors <pennae@lix.systems>2024-10-05 21:19:51 +0000
commit9adf6f4568d5a6b1c61ff93beb12a45b962c2602 (patch)
treee4c158535a8db9f2e1e1312f0d829bfb30648dd5 /src/libstore/build/worker.cc
parent03cbc0ecb9402fe7bbe1a2acd4643995003d7bb2 (diff)
libstore: remove Goal::notify
Goal::work() is a fully usable promise that does not rely on the worker to report completion conditions. as such we no longer need the `notify` field that enabled this interplay. we do have to clear goal caches when destroying the worker though, otherwise goal promises may (incorrectly) keep goals alive due to strong shared pointers created by childStarted. Change-Id: Ie607209aafec064dbdf3464fe207d70ba9ee158a
Diffstat (limited to 'src/libstore/build/worker.cc')
-rw-r--r--src/libstore/build/worker.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc
index 0f89159e4..4e8fa38db 100644
--- a/src/libstore/build/worker.cc
+++ b/src/libstore/build/worker.cc
@@ -48,6 +48,10 @@ Worker::~Worker()
their destructors). */
children.clear();
+ derivationGoals.clear();
+ drvOutputSubstitutionGoals.clear();
+ substitutionGoals.clear();
+
assert(expectedSubstitutions == 0);
assert(expectedDownloadSize == 0);
assert(expectedNarSize == 0);
@@ -71,21 +75,21 @@ std::pair<std::shared_ptr<G>, kj::Promise<Result<Goal::WorkResult>>> Worker::mak
auto goal = goal_weak.goal.lock();
if (!goal) {
goal = create();
- goal->notify = std::move(goal_weak.fulfiller);
goal_weak.goal = goal;
// do not start working immediately. if we are not yet running we
// may create dependencies as though they were toplevel goals, in
// which case the dependencies will not report build errors. when
// we are running we may be called for this same goal more times,
// and then we want to modify rather than recreate when possible.
- childStarted(goal, kj::evalLater([goal] { return goal->work(); }));
+ goal_weak.promise = kj::evalLater([goal] { return goal->work(); }).fork();
+ childStarted(goal, goal_weak.promise.addBranch());
} else {
if (!modify(*goal)) {
goal_weak = {};
continue;
}
}
- return {goal, goal_weak.promise->addBranch()};
+ return {goal, goal_weak.promise.addBranch()};
}
assert(false && "could not make a goal. possible concurrent worker access");
}
@@ -224,8 +228,6 @@ void Worker::childStarted(GoalPtr goal, kj::Promise<Result<Goal::WorkResult>> pr
.then([this, goal](auto result) {
if (result.has_value()) {
goalFinished(goal, result.assume_value());
- } else {
- goal->notify->fulfill(result.assume_error());
}
}));
}