From 6517446c3473ecf76596f0fb4e41f4b72db8f436 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 14 Sep 2017 17:22:48 +0200 Subject: [PATCH] Update to latest nixUnstable --- src/hydra-queue-runner/build-remote.cc | 8 ++++---- src/hydra-queue-runner/counter.hh | 17 ----------------- src/hydra-queue-runner/hydra-queue-runner.cc | 12 +++++------- src/hydra-queue-runner/state.hh | 5 +++-- 4 files changed, 12 insertions(+), 30 deletions(-) delete mode 100644 src/hydra-queue-runner/counter.hh diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index b0ad2df0..d5d2a05b 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -231,9 +231,9 @@ void State::buildRemote(ref destStore, /* Copy the input closure. */ if (/* machine->sshName != "localhost" */ true) { - auto mc1 = std::make_shared(nrStepsWaiting); + auto mc1 = std::make_shared>(nrStepsWaiting); mc1.reset(); - MaintainCount mc2(nrStepsCopyingTo); + MaintainCount mc2(nrStepsCopyingTo); printMsg(lvlDebug, format("sending closure of ‘%1%’ to ‘%2%’") % step->drvPath % machine->sshName); auto now1 = std::chrono::steady_clock::now(); @@ -276,7 +276,7 @@ void State::buildRemote(ref destStore, result.startTime = time(0); int res; { - MaintainCount mc(nrStepsBuilding); + MaintainCount mc(nrStepsBuilding); res = readInt(from); } result.stopTime = time(0); @@ -371,7 +371,7 @@ void State::buildRemote(ref destStore, /* Copy the output paths. */ if (/* machine->sshName != "localhost" */ true) { - MaintainCount mc(nrStepsCopyingFrom); + MaintainCount mc(nrStepsCopyingFrom); auto now1 = std::chrono::steady_clock::now(); diff --git a/src/hydra-queue-runner/counter.hh b/src/hydra-queue-runner/counter.hh deleted file mode 100644 index 6afff99d..00000000 --- a/src/hydra-queue-runner/counter.hh +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include -#include - -typedef std::atomic counter; - -struct MaintainCount -{ - counter & c; - MaintainCount(counter & c) : c(c) { c++; } - MaintainCount(counter & c, std::function warn) : c(c) - { - warn(++c); - } - ~MaintainCount() { auto prev = c--; assert(prev); } -}; diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index b8c50a43..14c1ec7f 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -105,13 +105,11 @@ State::State() } -MaintainCount State::startDbUpdate() +nix::MaintainCount State::startDbUpdate() { - return MaintainCount(nrActiveDbUpdates, [](unsigned long c) { - if (c > 6) { - printMsg(lvlError, format("warning: %d concurrent database updates; PostgreSQL may be stalled") % c); - } - }); + if (nrActiveDbUpdates > 6) + printError("warning: %d concurrent database updates; PostgreSQL may be stalled", nrActiveDbUpdates.load()); + return MaintainCount(nrActiveDbUpdates); } @@ -485,7 +483,7 @@ void State::notificationSender() notificationSenderQueue_->pop(); } - MaintainCount mc(nrNotificationsInProgress); + MaintainCount mc(nrNotificationsInProgress); printMsg(lvlChatty, format("sending notification about build %1%") % item.id); diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index 93c06a73..4660ca38 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -8,7 +8,6 @@ #include #include "db.hh" -#include "counter.hh" #include "token-server.hh" #include "derivations.hh" @@ -22,6 +21,8 @@ typedef unsigned int BuildID; typedef std::chrono::time_point system_time; +typedef std::atomic counter; + typedef enum { bsSuccess = 0, @@ -439,7 +440,7 @@ public: private: - MaintainCount startDbUpdate(); + nix::MaintainCount startDbUpdate(); /* Return a store object to store build results. */ nix::ref getDestStore();