Merge pull request #1162 from obsidiansystems/less-ref

Make `copyClosureTo` take a regular C++ ref to the store
This commit is contained in:
Eelco Dolstra 2022-03-23 16:25:59 +01:00 committed by GitHub
commit 962bf36939
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -104,12 +104,12 @@ 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, FdSource & from, FdSink & to, const StorePathSet & paths,
bool useSubstitutes = false) bool useSubstitutes = false)
{ {
StorePathSet closure; StorePathSet closure;
destStore->computeFSClosure(paths, closure); destStore.computeFSClosure(paths, closure);
/* Send the "query valid paths" command with the "lock" option /* Send the "query valid paths" command with the "lock" option
enabled. This prevents a race where the remote host enabled. This prevents a race where the remote host
@ -117,16 +117,16 @@ static void copyClosureTo(std::timed_mutex & sendMutex, ref<Store> destStore,
the remote host to substitute missing paths. */ the remote host to substitute missing paths. */
// FIXME: substitute output pollutes our build log // FIXME: substitute output pollutes our build log
to << cmdQueryValidPaths << 1 << useSubstitutes; to << cmdQueryValidPaths << 1 << useSubstitutes;
worker_proto::write(*destStore, to, closure); worker_proto::write(destStore, to, closure);
to.flush(); to.flush();
/* Get back the set of paths that are already valid on the remote /* Get back the set of paths that are already valid on the remote
host. */ 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; if (present.size() == closure.size()) return;
auto sorted = destStore->topoSortPaths(closure); auto sorted = destStore.topoSortPaths(closure);
StorePathSet missing; StorePathSet missing;
for (auto i = sorted.rbegin(); i != sorted.rend(); ++i) for (auto i = sorted.rbegin(); i != sorted.rend(); ++i)
@ -138,7 +138,7 @@ static void copyClosureTo(std::timed_mutex & sendMutex, ref<Store> destStore,
std::chrono::seconds(600)); std::chrono::seconds(600));
to << cmdImportPaths; to << cmdImportPaths;
destStore->exportPaths(missing, to); destStore.exportPaths(missing, to);
to.flush(); to.flush();
if (readInt(from) != 1) if (readInt(from) != 1)
@ -308,7 +308,7 @@ void State::buildRemote(ref<Store> destStore,
destStore->computeFSClosure(inputs, closure); destStore->computeFSClosure(inputs, closure);
copyPaths(*destStore, *localStore, closure, NoRepair, NoCheckSigs, NoSubstitute); copyPaths(*destStore, *localStore, closure, NoRepair, NoCheckSigs, NoSubstitute);
} else { } 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(); auto now2 = std::chrono::steady_clock::now();