Revert "libstore: remove worker removeGoal"
Revert submission 1946
Reason for revert: regression in building (found via bisection)
Reported by users:
> error: path '/nix/store/04ca5xwvasz6s3jg0k7njz6rzi0d225w-jq-1.7.1-dev' does not exist in the store
Reverted changes: /q/submissionid:1946
Change-Id: I6f1a4b2f7d7ef5ca430e477fc32bca62fd97036b
This commit is contained in:
parent
a16ceb9411
commit
8e05cc1e6c
|
@ -65,26 +65,7 @@ std::pair<std::shared_ptr<G>, kj::Promise<void>> Worker::makeGoalCommon(
|
||||||
auto & goal_weak = it->second;
|
auto & goal_weak = it->second;
|
||||||
auto goal = goal_weak.goal.lock();
|
auto goal = goal_weak.goal.lock();
|
||||||
if (!goal) {
|
if (!goal) {
|
||||||
struct Deleter
|
goal = create();
|
||||||
{
|
|
||||||
std::map<ID, CachedGoal<G>> * from;
|
|
||||||
std::map<ID, CachedGoal<G>>::const_iterator iter;
|
|
||||||
|
|
||||||
void operator()(G * g)
|
|
||||||
{
|
|
||||||
from->erase(iter);
|
|
||||||
delete g;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// this dance is necessary to be memory-safe in exceptional cases.
|
|
||||||
// if *anything* here throws we must still delete the goal object.
|
|
||||||
goal = [&] {
|
|
||||||
std::unique_ptr<G, Deleter> tmp(nullptr, Deleter{&map, it});
|
|
||||||
tmp.reset(create().release());
|
|
||||||
return tmp;
|
|
||||||
}();
|
|
||||||
|
|
||||||
goal->notify = std::move(goal_weak.fulfiller);
|
goal->notify = std::move(goal_weak.fulfiller);
|
||||||
goal_weak.goal = goal;
|
goal_weak.goal = goal;
|
||||||
wakeUp(goal);
|
wakeUp(goal);
|
||||||
|
@ -184,6 +165,21 @@ std::pair<GoalPtr, kj::Promise<void>> Worker::makeGoal(const DerivedPath & req,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename G>
|
||||||
|
static void removeGoal(std::shared_ptr<G> goal, auto & goalMap)
|
||||||
|
{
|
||||||
|
/* !!! inefficient */
|
||||||
|
for (auto i = goalMap.begin();
|
||||||
|
i != goalMap.end(); )
|
||||||
|
if (i->second.goal.lock() == goal) {
|
||||||
|
auto j = i; ++j;
|
||||||
|
goalMap.erase(i);
|
||||||
|
i = j;
|
||||||
|
}
|
||||||
|
else ++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Worker::goalFinished(GoalPtr goal, Goal::Finished & f)
|
void Worker::goalFinished(GoalPtr goal, Goal::Finished & f)
|
||||||
{
|
{
|
||||||
goal->trace("done");
|
goal->trace("done");
|
||||||
|
@ -196,16 +192,9 @@ void Worker::goalFinished(GoalPtr goal, Goal::Finished & f)
|
||||||
hashMismatch |= f.hashMismatch;
|
hashMismatch |= f.hashMismatch;
|
||||||
checkMismatch |= f.checkMismatch;
|
checkMismatch |= f.checkMismatch;
|
||||||
|
|
||||||
|
removeGoal(goal);
|
||||||
goal->notify->fulfill();
|
goal->notify->fulfill();
|
||||||
goal->cleanup();
|
goal->cleanup();
|
||||||
|
|
||||||
if (topGoals.find(goal) != topGoals.end()) {
|
|
||||||
topGoals.erase(goal);
|
|
||||||
/* If a top-level goal failed, then kill all other goals
|
|
||||||
(unless keepGoing was set). */
|
|
||||||
if (goal->exitCode == Goal::ecFailed && !settings.keepGoing)
|
|
||||||
topGoals.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::handleWorkResult(GoalPtr goal, Goal::WorkResult how)
|
void Worker::handleWorkResult(GoalPtr goal, Goal::WorkResult how)
|
||||||
|
@ -220,6 +209,27 @@ void Worker::handleWorkResult(GoalPtr goal, Goal::WorkResult how)
|
||||||
updateStatistics();
|
updateStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::removeGoal(GoalPtr goal)
|
||||||
|
{
|
||||||
|
if (auto drvGoal = std::dynamic_pointer_cast<DerivationGoal>(goal))
|
||||||
|
nix::removeGoal(drvGoal, derivationGoals);
|
||||||
|
else if (auto subGoal = std::dynamic_pointer_cast<PathSubstitutionGoal>(goal))
|
||||||
|
nix::removeGoal(subGoal, substitutionGoals);
|
||||||
|
else if (auto subGoal = std::dynamic_pointer_cast<DrvOutputSubstitutionGoal>(goal))
|
||||||
|
nix::removeGoal(subGoal, drvOutputSubstitutionGoals);
|
||||||
|
else
|
||||||
|
assert(false);
|
||||||
|
|
||||||
|
if (topGoals.find(goal) != topGoals.end()) {
|
||||||
|
topGoals.erase(goal);
|
||||||
|
/* If a top-level goal failed, then kill all other goals
|
||||||
|
(unless keepGoing was set). */
|
||||||
|
if (goal->exitCode == Goal::ecFailed && !settings.keepGoing)
|
||||||
|
topGoals.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Worker::wakeUp(GoalPtr goal)
|
void Worker::wakeUp(GoalPtr goal)
|
||||||
{
|
{
|
||||||
goal->trace("woken up");
|
goal->trace("woken up");
|
||||||
|
|
|
@ -158,6 +158,11 @@ private:
|
||||||
*/
|
*/
|
||||||
void waitForInput();
|
void waitForInput();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a dead goal.
|
||||||
|
*/
|
||||||
|
void removeGoal(GoalPtr goal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a running child process.
|
* Registers a running child process.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue