Merge pull request #7445 from Icinga/bugfix/ddos-reconnect-7444

JsonRpcConnection#Disconnect(): unregister the connection ASAP
This commit is contained in:
Michael Friedrich 2019-08-28 08:59:14 +02:00 committed by GitHub
commit 5ed91098d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
}
}
});
}