diff --git a/lix/libstore/remote-store-connection.hh b/lix/libstore/remote-store-connection.hh index 2f97cc642..fa3414d0b 100644 --- a/lix/libstore/remote-store-connection.hh +++ b/lix/libstore/remote-store-connection.hh @@ -97,7 +97,7 @@ struct RemoteStore::Connection virtual ~Connection(); - std::exception_ptr processStderr(bool flush = true); + std::exception_ptr processStderr(); }; /** @@ -134,7 +134,7 @@ struct RemoteStore::ConnectionHandle RemoteStore::Connection & operator * () { return *handle; } RemoteStore::Connection * operator -> () { return &*handle; } - void processStderr(bool flush = true); + void processStderr(); kj::Promise> withFramedSinkAsync(std::function>(Sink & sink)> fun); @@ -153,6 +153,7 @@ struct RemoteStore::ConnectionHandle // the subframing layer (which is then responsible for any error handling) if constexpr (requires { handle->to << std::declval(); }) { ((handle->to << std::forward(args)), ...); + handle->to.flush(); processStderr(); } else { using ImmediateArgsIdxs = std::make_index_sequence; @@ -160,6 +161,7 @@ struct RemoteStore::ConnectionHandle [&](std::integer_sequence) { ((handle->to << std::get(std::forward(allArgs))), ...); + handle->to.flush(); }(ImmediateArgsIdxs{}); LIX_TRY_AWAIT(withFramedSinkAsync(std::get(allArgs))); diff --git a/lix/libstore/remote-store.cc b/lix/libstore/remote-store.cc index a4ac8b92a..b4b5e1693 100644 --- a/lix/libstore/remote-store.cc +++ b/lix/libstore/remote-store.cc @@ -154,6 +154,7 @@ void RemoteStore::setOptions(Connection & conn) command << i.first << i.second.value; StringSource{command.s}.drainInto(conn.to); + conn.to.flush(); auto ex = conn.processStderr(); if (ex) std::rethrow_exception(ex); } @@ -167,9 +168,9 @@ RemoteStore::ConnectionHandle::~ConnectionHandle() } } -void RemoteStore::ConnectionHandle::processStderr(bool flush) +void RemoteStore::ConnectionHandle::processStderr() { - auto ex = handle->processStderr(flush); + auto ex = handle->processStderr(); if (ex) { daemonException = true; std::rethrow_exception(ex); @@ -742,11 +743,8 @@ static Logger::Fields readFields(Source & from) } -std::exception_ptr RemoteStore::Connection::processStderr(bool flush) +std::exception_ptr RemoteStore::Connection::processStderr() { - if (flush) - to.flush(); - while (true) { auto msg = readNum(from); @@ -795,13 +793,12 @@ RemoteStore::ConnectionHandle::FramedSinkHandler::FramedSinkHandler( ) : stderrHandler([&]() { try { - conn.processStderr(false); + conn.processStderr(); } catch (...) { ex = std::current_exception(); } }) { - conn.handle->to.flush(); handlerThreads.enqueue([&] { stderrHandler(); }); }