Merge pull request #7841 from Icinga/bugfix/jsonrpcconnection-sendmessage-keepalive

JsonRpcConnection#Send*Message(): keep this alive
This commit is contained in:
Noah Hilverling 2020-03-03 10:46:33 +01:00 committed by GitHub
commit c9ab04d511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -170,12 +170,16 @@ ConnectionRole JsonRpcConnection::GetRole() const
void JsonRpcConnection::SendMessage(const Dictionary::Ptr& message)
{
m_IoStrand.post([this, message]() { SendMessageInternal(message); });
Ptr keepAlive (this);
m_IoStrand.post([this, keepAlive, message]() { SendMessageInternal(message); });
}
void JsonRpcConnection::SendRawMessage(const String& message)
{
m_IoStrand.post([this, message]() {
Ptr keepAlive (this);
m_IoStrand.post([this, keepAlive, message]() {
m_OutgoingMessagesQueue.emplace_back(message);
m_OutgoingMessagesQueued.Set();
});