hydra-queue-runner: Fix assertion failure

It was hitting

    assert(reservation.unique());

Since we do want the machine reservation to be released before calling
wakeDispatcher(), let's use a different object for keeping track of
active steps.
This commit is contained in:
Eelco Dolstra 2016-11-02 12:41:00 +01:00
parent 07decd6915
commit 4f08c85c69
2 changed files with 13 additions and 8 deletions

View file

@ -13,13 +13,14 @@ void State::builder(MachineReservation::ptr reservation)
nrStepsStarted++;
reservation->threadId = pthread_self();
activeSteps_.lock()->insert(reservation);
auto activeStep = std::make_shared<ActiveStep>();
activeStep->step = reservation->step;
activeStep->threadId = pthread_self();
activeSteps_.lock()->insert(activeStep);
Finally removeActiveStep([&]() {
reservation->threadId = -1;
activeSteps_.lock()->erase(reservation);
activeStep->threadId = -1;
activeSteps_.lock()->erase(activeStep);
});
auto step = reservation->step;

View file

@ -370,13 +370,17 @@ private:
State & state;
Step::ptr step;
Machine::ptr machine;
pthread_t threadId = 0;
bool cancelled = false;
MachineReservation(State & state, Step::ptr step, Machine::ptr machine);
~MachineReservation();
};
nix::Sync<std::set<std::shared_ptr<MachineReservation>>> activeSteps_;
struct ActiveStep
{
Step::ptr step;
pthread_t threadId;
};
nix::Sync<std::set<std::shared_ptr<ActiveStep>>> activeSteps_;
std::atomic<time_t> lastDispatcherCheck{0};