mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
JsonRpcConnection#Send*(): discard messages ASAP once shutting down
Especially ApiListener#ReplayLog() enqueued lots of messages into JsonRpcConnection#{m_IoStrand,m_OutgoingMessagesQueue} (RAM) even if the connection was shut(ting) down. Now #Disconnect() takes effect ASAP.
This commit is contained in:
parent
33f8ea6dcc
commit
b538ad2528
@ -163,6 +163,10 @@ ConnectionRole JsonRpcConnection::GetRole() const
|
|||||||
|
|
||||||
void JsonRpcConnection::SendMessage(const Dictionary::Ptr& message)
|
void JsonRpcConnection::SendMessage(const Dictionary::Ptr& message)
|
||||||
{
|
{
|
||||||
|
if (m_ShuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Ptr keepAlive (this);
|
Ptr keepAlive (this);
|
||||||
|
|
||||||
m_IoStrand.post([this, keepAlive, message]() { SendMessageInternal(message); });
|
m_IoStrand.post([this, keepAlive, message]() { SendMessageInternal(message); });
|
||||||
@ -170,9 +174,17 @@ void JsonRpcConnection::SendMessage(const Dictionary::Ptr& message)
|
|||||||
|
|
||||||
void JsonRpcConnection::SendRawMessage(const String& message)
|
void JsonRpcConnection::SendRawMessage(const String& message)
|
||||||
{
|
{
|
||||||
|
if (m_ShuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Ptr keepAlive (this);
|
Ptr keepAlive (this);
|
||||||
|
|
||||||
m_IoStrand.post([this, keepAlive, message]() {
|
m_IoStrand.post([this, keepAlive, message]() {
|
||||||
|
if (m_ShuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_OutgoingMessagesQueue.emplace_back(message);
|
m_OutgoingMessagesQueue.emplace_back(message);
|
||||||
m_OutgoingMessagesQueued.Set();
|
m_OutgoingMessagesQueued.Set();
|
||||||
});
|
});
|
||||||
@ -180,6 +192,10 @@ void JsonRpcConnection::SendRawMessage(const String& message)
|
|||||||
|
|
||||||
void JsonRpcConnection::SendMessageInternal(const Dictionary::Ptr& message)
|
void JsonRpcConnection::SendMessageInternal(const Dictionary::Ptr& message)
|
||||||
{
|
{
|
||||||
|
if (m_ShuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_OutgoingMessagesQueue.emplace_back(JsonEncode(message));
|
m_OutgoingMessagesQueue.emplace_back(JsonEncode(message));
|
||||||
m_OutgoingMessagesQueued.Set();
|
m_OutgoingMessagesQueued.Set();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user