From b04521e4ecfe84816c8a2bb34644fd4d5a59cb83 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 11 Oct 2025 21:59:56 +0200 Subject: [PATCH] libstore: move log handling fully into handleBuilderOutput it was split up like this only because the old worker system had no promises. since we have them now we can use them for encapsulation. Change-Id: Idbd523eff617d4c53c14b125ab3dfce4979cdab1 --- lix/libstore/build/derivation-goal.cc | 45 ++++++++++++++------------- lix/libstore/build/derivation-goal.hh | 4 --- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/lix/libstore/build/derivation-goal.cc b/lix/libstore/build/derivation-goal.cc index ca024c960..27bfef0d1 100644 --- a/lix/libstore/build/derivation-goal.cc +++ b/lix/libstore/build/derivation-goal.cc @@ -1229,6 +1229,30 @@ Goal::WorkResult DerivationGoal::tooMuchLogs() kj::Promise>> DerivationGoal::handleBuilderOutput(AsyncInputStream & in) noexcept try { + std::string currentLogLine; + size_t currentLogLinePos = 0; // to handle carriage return + + auto flushLine = [&] { + KJ_DEFER({ + currentLogLine = ""; + currentLogLinePos = 0; + }); + + if (const auto state = handleJSONLogMessage( + currentLogLine, *act, builderActivities, "the derivation builder", false + )) + { + return *state; + } else { + logTail.push_back(currentLogLine); + if (logTail.size() > settings.logLines) { + logTail.pop_front(); + } + + return act->result(resBuildLogLine, currentLogLine); + } + }; + auto buf = kj::heapArray(4096); while (true) { std::string_view data; @@ -1417,27 +1441,6 @@ DerivationGoal::handleChildStreams(AsyncInputStream * builderIn, AsyncInputStrea co_return std::nullopt; } -Logger::BufferState DerivationGoal::flushLine() -{ - KJ_DEFER({ - currentLogLine = ""; - currentLogLinePos = 0; - }); - - if (const auto state = handleJSONLogMessage( - currentLogLine, *act, builderActivities, "the derivation builder", false - )) - { - return *state; - } else { - logTail.push_back(currentLogLine); - if (logTail.size() > settings.logLines) logTail.pop_front(); - - return act->result(resBuildLogLine, currentLogLine); - } -} - - kj::Promise> DerivationGoal::queryDerivationOutputMap() try { OutputPathMap res; diff --git a/lix/libstore/build/derivation-goal.hh b/lix/libstore/build/derivation-goal.hh index 2df3adf42..8bd7b2975 100644 --- a/lix/libstore/build/derivation-goal.hh +++ b/lix/libstore/build/derivation-goal.hh @@ -201,9 +201,6 @@ struct DerivationGoal : public Goal */ std::list logTail; - std::string currentLogLine; - size_t currentLogLinePos = 0; // to handle carriage return - std::string currentHookLine; /** @@ -325,7 +322,6 @@ protected: kj::Promise>> handleHookOutput(AsyncInputStream & in) noexcept; kj::Promise>> monitorForSilence() noexcept; WorkResult tooMuchLogs(); - Logger::BufferState flushLine(); virtual std::string buildErrorContents(const std::string & exitMsg, bool diskFull);