From 445bba337b6a78dad9b72da878ae21aabf85af3d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 20 Feb 2022 17:18:52 +0000 Subject: [PATCH] Make `copyClosureTo` take a regular C++ ref to the store This is syntactically lighter wait, and demonstates there are no weird dynamic lifetimes involved, just regular passing reference to callee which it only borrows for the duration of the call. --- src/hydra-queue-runner/build-remote.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index 696077de..464a35c8 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -104,12 +104,12 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil } -static void copyClosureTo(std::timed_mutex & sendMutex, ref destStore, +static void copyClosureTo(std::timed_mutex & sendMutex, Store & destStore, FdSource & from, FdSink & to, const StorePathSet & paths, bool useSubstitutes = false) { StorePathSet closure; - destStore->computeFSClosure(paths, closure); + destStore.computeFSClosure(paths, closure); /* Send the "query valid paths" command with the "lock" option enabled. This prevents a race where the remote host @@ -117,16 +117,16 @@ static void copyClosureTo(std::timed_mutex & sendMutex, ref destStore, the remote host to substitute missing paths. */ // FIXME: substitute output pollutes our build log to << cmdQueryValidPaths << 1 << useSubstitutes; - worker_proto::write(*destStore, to, closure); + worker_proto::write(destStore, to, closure); to.flush(); /* Get back the set of paths that are already valid on the remote host. */ - auto present = worker_proto::read(*destStore, from, Phantom {}); + auto present = worker_proto::read(destStore, from, Phantom {}); if (present.size() == closure.size()) return; - auto sorted = destStore->topoSortPaths(closure); + auto sorted = destStore.topoSortPaths(closure); StorePathSet missing; for (auto i = sorted.rbegin(); i != sorted.rend(); ++i) @@ -138,7 +138,7 @@ static void copyClosureTo(std::timed_mutex & sendMutex, ref destStore, std::chrono::seconds(600)); to << cmdImportPaths; - destStore->exportPaths(missing, to); + destStore.exportPaths(missing, to); to.flush(); if (readInt(from) != 1) @@ -308,7 +308,7 @@ void State::buildRemote(ref destStore, destStore->computeFSClosure(inputs, closure); copyPaths(*destStore, *localStore, closure, NoRepair, NoCheckSigs, NoSubstitute); } else { - copyClosureTo(machine->state->sendLock, destStore, from, to, inputs, true); + copyClosureTo(machine->state->sendLock, *destStore, from, to, inputs, true); } auto now2 = std::chrono::steady_clock::now();