diff --git a/src/hydra-queue-runner/db.hh b/src/hydra-queue-runner/db.hh index 9242fd75..9b5b7348 100644 --- a/src/hydra-queue-runner/db.hh +++ b/src/hydra-queue-runner/db.hh @@ -4,18 +4,17 @@ #include "util.hh" -using namespace nix; - struct Connection : pqxx::connection { Connection() : pqxx::connection(getFlags()) { }; - string getFlags() + std::string getFlags() { - string s = getEnv("HYDRA_DBI", "dbi:Pg:dbname=hydra;"); - string prefix = "dbi:Pg:"; - if (string(s, 0, prefix.size()) != prefix) + using namespace nix; + auto s = getEnv("HYDRA_DBI", "dbi:Pg:dbname=hydra;"); + std::string prefix = "dbi:Pg:"; + if (std::string(s, 0, prefix.size()) != prefix) throw Error("$HYDRA_DBI does not denote a PostgreSQL database"); return concatStringsSep(" ", tokenizeString(string(s, prefix.size()), ";")); } @@ -27,7 +26,7 @@ struct receiver : public pqxx::notification_receiver bool status = false; receiver(pqxx::connection_base & c, const std::string & channel) : pqxx::notification_receiver(c, channel) { } - void operator() (const string & payload, int pid) override + void operator() (const std::string & payload, int pid) override { status = true; }; diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index 877870af..525db44e 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -17,8 +17,6 @@ #include "store-api.hh" #include "derivations.hh" -using namespace nix; - typedef unsigned int BuildID; @@ -70,8 +68,8 @@ struct Build typedef std::weak_ptr wptr; BuildID id; - Path drvPath; - std::map outputs; + nix::Path drvPath; + std::map outputs; std::string fullJobName; unsigned int maxSilentTime, buildTimeout; @@ -86,8 +84,8 @@ struct Step typedef std::shared_ptr ptr; typedef std::weak_ptr wptr; - Path drvPath; - Derivation drv; + nix::Path drvPath; + nix::Derivation drv; std::set requiredSystemFeatures; bool preferLocalBuild; @@ -160,9 +158,9 @@ class State { private: - Path hydraData, logDir; + nix::Path hydraData, logDir; - StringSet localPlatforms; + nix::StringSet localPlatforms; /* The queued builds. */ typedef std::map Builds; @@ -172,7 +170,7 @@ private: queued builds). Note that these are weak pointers. Steps are kept alive by being reachable from Builds or by being in progress. */ - typedef std::map Steps; + typedef std::map Steps; Sync steps; /* Build steps that have no unbuilt dependencies. */ @@ -187,10 +185,10 @@ private: Pool dbPool; /* The build machines. */ - typedef std::map Machines; + typedef std::map Machines; Sync machines; // FIXME: use atomic_shared_ptr - Path machinesFile; + nix::Path machinesFile; struct stat machinesFileStat; /* Token server limiting the number of threads copying closures in @@ -216,7 +214,7 @@ private: counter bytesReceived{0}; /* Log compressor work queue. */ - Sync> logCompressorQueue; + Sync> logCompressorQueue; std::condition_variable_any logCompressorWakeup; /* Notification sender work queue. FIXME: if hydra-queue-runner is @@ -248,7 +246,7 @@ private: BuildID propagatedFrom = 0); void finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime, BuildID buildId, int stepNr, - const std::string & machine, BuildStepStatus status, const string & errorMsg = "", + const std::string & machine, BuildStepStatus status, const std::string & errorMsg = "", BuildID propagatedFrom = 0); void updateBuild(pqxx::work & txn, Build::ptr build, BuildStatus status); @@ -257,12 +255,12 @@ private: void queueMonitorLoop(); - void getQueuedBuilds(Connection & conn, std::shared_ptr store, unsigned int & lastBuildId); + void getQueuedBuilds(Connection & conn, std::shared_ptr store, unsigned int & lastBuildId); void removeCancelledBuilds(Connection & conn); - Step::ptr createStep(std::shared_ptr store, const Path & drvPath, - Build::ptr referringBuild, Step::ptr referringStep, std::set & finishedDrvs, + Step::ptr createStep(std::shared_ptr store, const nix::Path & drvPath, + Build::ptr referringBuild, Step::ptr referringStep, std::set & finishedDrvs, std::set & newSteps, std::set & newRunnable); void makeRunnable(Step::ptr step); @@ -276,7 +274,7 @@ private: /* Perform the given build step. Return true if the step is to be retried. */ - bool doBuildStep(std::shared_ptr store, Step::ptr step, + bool doBuildStep(std::shared_ptr store, Step::ptr step, Machine::ptr machine); void buildRemote(std::shared_ptr store, @@ -298,7 +296,7 @@ private: /* Acquire the global queue runner lock, or null if somebody else has it. */ - std::shared_ptr acquireGlobalLock(); + std::shared_ptr acquireGlobalLock(); void dumpStatus(Connection & conn, bool log);