Skip to content

Commit

Permalink
Make copyClosureTo take a regular C++ ref to the store
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ericson2314 committed Feb 20, 2022
1 parent dfb3ecc commit 445bba3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/hydra-queue-runner/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,29 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil
}


static void copyClosureTo(std::timed_mutex & sendMutex, ref<Store> 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
garbage-collect paths that are already there. Optionally, ask
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<StorePathSet> {});
auto present = worker_proto::read(destStore, from, Phantom<StorePathSet> {});

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)
Expand All @@ -138,7 +138,7 @@ static void copyClosureTo(std::timed_mutex & sendMutex, ref<Store> destStore,
std::chrono::seconds(600));

to << cmdImportPaths;
destStore->exportPaths(missing, to);
destStore.exportPaths(missing, to);
to.flush();

if (readInt(from) != 1)
Expand Down Expand Up @@ -308,7 +308,7 @@ void State::buildRemote(ref<Store> 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();
Expand Down

0 comments on commit 445bba3

Please sign in to comment.