From 4af97c57f5a0a58f5182cb82389957442226b454 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 1 Sep 2017 16:28:49 +0200 Subject: [PATCH] Acquire the send lock only while actually sending Thus, we no longer hold the send lock while substituting missing paths on the build machine. This is a good thing in particular for macOS builders which have a tendency to hang forever in curl downloads. --- src/hydra-queue-runner/build-remote.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index 298d886e..b0ad2df0 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -77,7 +77,7 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil } -static void copyClosureTo(ref destStore, +static void copyClosureTo(std::timed_mutex & sendMutex, ref destStore, FdSource & from, FdSink & to, const PathSet & paths, bool useSubstitutes = false) { @@ -107,6 +107,9 @@ static void copyClosureTo(ref destStore, printMsg(lvlDebug, format("sending %1% missing paths") % missing.size()); + std::unique_lock sendLock(sendMutex, + std::chrono::seconds(600)); + to << cmdImportPaths; destStore->exportPaths(missing, to); to.flush(); @@ -229,15 +232,13 @@ void State::buildRemote(ref destStore, /* Copy the input closure. */ if (/* machine->sshName != "localhost" */ true) { auto mc1 = std::make_shared(nrStepsWaiting); - std::unique_lock sendLock( - machine->state->sendLock, std::chrono::seconds(600)); mc1.reset(); MaintainCount mc2(nrStepsCopyingTo); printMsg(lvlDebug, format("sending closure of ‘%1%’ to ‘%2%’") % step->drvPath % machine->sshName); auto now1 = std::chrono::steady_clock::now(); - copyClosureTo(destStore, from, to, inputs, true); + copyClosureTo(machine->state->sendLock, destStore, from, to, inputs, true); auto now2 = std::chrono::steady_clock::now();