Skip to content

Commit 1c34610

Browse files
committed
JsonRpcConnection: Don't read any data on shutdown
When the `Desconnect()` method is called, clients are not disconnected immediately. Instead, a new coroutine is spawned using the same strand as the other coroutines. This coroutine calls `async_shutdown` on the TCP socket, which might be blocking. However, in order not to block indefintely, the `Timeout` class cancels all operations on the socket after `10` seconds. Though, the timeout does not trigger the handler immediately; it creates spawns another coroutine using the same strand as in the `JsonRpcConnection` class. This can cause unexpected delays if e.g. `HandleIncomingMessages` gets resumed before the coroutine from the timeout class. Apart from that, the coroutine for writing messages uses the same condition, making the two symmetrical.
1 parent d894792 commit 1c34610

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/remote/jsonrpcconnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc)
6262
{
6363
m_Stream->next_layer().SetSeen(&m_Seen);
6464

65-
for (;;) {
65+
while (!m_ShuttingDown) {
6666
String message;
6767

6868
try {

0 commit comments

Comments
 (0)