JsonRpcConnection: don't write new messages on shutdown

In fact, this is already done for the outer loop (for each bulk), just not yet for the inner one (for each message of a bulk). So once the remote signals EOF, don't try to process the remaining queue until write error (which can't be associated with a particular message anyway, due to buffering), but just let the peer go. Flush already half-written messages, though, if possible.
This commit is contained in:
Alexander Aleksandrovič Klimov 2024-11-07 17:32:12 +01:00 committed by GitHub
parent 9a8620d923
commit aa7f159a0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -110,6 +110,10 @@ void JsonRpcConnection::WriteOutgoingMessages(boost::asio::yield_context yc)
if (!queue.empty()) { if (!queue.empty()) {
try { try {
for (auto& message : queue) { for (auto& message : queue) {
if (m_ShuttingDown) {
break;
}
size_t bytesSent = JsonRpc::SendRawMessage(m_Stream, message, yc); size_t bytesSent = JsonRpc::SendRawMessage(m_Stream, message, yc);
if (m_Endpoint) { if (m_Endpoint) {