diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index 44f1662dde1..38afd511672 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -110,6 +110,10 @@ void JsonRpcConnection::WriteOutgoingMessages(boost::asio::yield_context yc) if (!queue.empty()) { try { for (auto& message : queue) { + if (m_ShuttingDown) { + return; + } + size_t bytesSent = JsonRpc::SendRawMessage(m_Stream, message, yc); if (m_Endpoint) { @@ -117,6 +121,10 @@ void JsonRpcConnection::WriteOutgoingMessages(boost::asio::yield_context yc) } } + if (m_ShuttingDown) { + return; + } + m_Stream->async_flush(yc); } catch (const std::exception& ex) { Log(m_ShuttingDown ? LogDebug : LogWarning, "JsonRpcConnection")