From b4b02992236d2f7b657d132fce0f37c94e18dcfb Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Mon, 15 Jan 2024 10:18:43 +0100 Subject: [PATCH] Fix synchronization issue with console. If a query couldn't be processed, client and server could get synchronized. --- src/io/console.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/io/console.cc b/src/io/console.cc index 56f63918..75e580a1 100644 --- a/src/io/console.cc +++ b/src/io/console.cc @@ -220,18 +220,16 @@ void ConsoleServer::Implementation::query(const socket::Remote& remote, const st if ( subscription && *subscription == query::SubscriptionType::Snapshots ) pending->remote << std::endl; - if ( ! pending->remote ) { - // Cancel query on error, but still try to get - // the error message across. - sendError(pending->remote, frmt("console send failed: {}", *pending->remote.error())); + if ( ! pending->remote ) + // Cancel query on error. pending->done_cv.notify_all(); - } }, .callback_done = [pending](query::ID id, bool regular_shutdown) { std::unique_lock lock(pending->done_mutex); pending->remote << std::endl; + sendEndOfMessage(pending->remote); pending->done_cv.notify_all(); }}; @@ -256,7 +254,6 @@ void ConsoleServer::Implementation::query(const socket::Remote& remote, const st }); pending->done_cv.wait(lock); - sendEndOfMessage(pending->remote); if ( auto err = pending->remote.error() ) logger()->warn("console send failed: {}", *err);