libstore: remove flushing from processStderr

it's part of sending the command and should be treated as such.

Change-Id: I7406ead5cd08c79efe50f3b0fcb522a18d9d7bcf
This commit is contained in:
eldritch horrors
2025-06-11 22:29:30 +02:00
parent 8b3fdbc847
commit cc04a433f0
2 changed files with 9 additions and 10 deletions
+4 -2
View File
@@ -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<Result<void>>
withFramedSinkAsync(std::function<kj::Promise<Result<void>>(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<LastArgT>(); }) {
((handle->to << std::forward<Args>(args)), ...);
handle->to.flush();
processStderr();
} else {
using ImmediateArgsIdxs = std::make_index_sequence<sizeof...(Args) - 1>;
@@ -160,6 +161,7 @@ struct RemoteStore::ConnectionHandle
[&]<size_t... Ids>(std::integer_sequence<size_t, Ids...>) {
((handle->to << std::get<Ids>(std::forward<AllArgsT>(allArgs))), ...);
handle->to.flush();
}(ImmediateArgsIdxs{});
LIX_TRY_AWAIT(withFramedSinkAsync(std::get<LastArgIdx>(allArgs)));
+5 -8
View File
@@ -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<uint64_t>(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(); });
}