JsonRpcConnection#Disconnect(): unregister the connection ASAP

refs #7444
This commit is contained in:
Alexander A. Klimov 2019-08-23 17:14:13 +02:00
parent 8c739fe33b
commit c24312b870
1 changed files with 10 additions and 9 deletions

View File

@ -200,6 +200,16 @@ void JsonRpcConnection::Disconnect()
Log(LogWarning, "JsonRpcConnection")
<< "API client disconnected for identity '" << m_Identity << "'";
{
CpuBoundWork removeClient (yc);
if (m_Endpoint) {
m_Endpoint->RemoveClient(this);
} else {
ApiListener::GetInstance()->RemoveAnonymousClient(this);
}
}
m_OutgoingMessagesQueued.Set();
m_WriterDone.Wait(yc);
@ -221,15 +231,6 @@ void JsonRpcConnection::Disconnect()
m_CheckLivenessTimer.cancel();
m_HeartbeatTimer.cancel();
CpuBoundWork removeClient (yc);
if (m_Endpoint) {
m_Endpoint->RemoveClient(this);
} else {
auto listener (ApiListener::GetInstance());
listener->RemoveAnonymousClient(this);
}
}
});
}