From 5cbca8553581a358f9b5067bc8def24b1c7b37cc Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 11 Aug 2024 21:53:29 +0200 Subject: [PATCH] libstore: clarify that build log fd and hook log fd are different only DerivationGoal can set the hook to anything at all. it always sets buildOutFD to something that is not related to fromHook in any way, and mixing the two would have rather dire consequences for log consistency. Change-Id: Ida86727fd1cd5e1ecd78f07f3bde330a346658a8 --- src/libstore/build/derivation-goal.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index f43a2a5b6..cc445a0a4 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -1288,9 +1288,7 @@ Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data }; // local & `ssh://`-builds are dealt with here. - auto isWrittenToLog = fd == builderOutFD->get(); - if (isWrittenToLog) - { + if (fd == builderOutFD->get()) { logSize += data.size(); if (settings.maxLogSize && logSize > settings.maxLogSize) { return tooMuchLogs(); @@ -1308,6 +1306,7 @@ Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data } if (logSink) (*logSink)(data); + return StillAlive{}; } if (hook && fd == hook->fromHook.readSide.get()) { @@ -1318,7 +1317,7 @@ Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data auto s = handleJSONLogMessage(*json, worker.act, hook->activities, true); // ensure that logs from a builder using `ssh-ng://` as protocol // are also available to `nix log`. - if (s && !isWrittenToLog && logSink) { + if (s && logSink) { const auto type = (*json)["type"]; const auto fields = (*json)["fields"]; if (type == resBuildLogLine) {