icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

JsonRpcConnection#Send*() queues messages in memory even after #Disconnect()

Open Al2Klimov opened this issue 1 year ago • 2 comments

Describe the bug

  1. JsonRpcConnection#Send*() posts a closure with the message in question into its strand which processes such sequentially
  2. That closure inserts the message into #m_OutgoingMessagesQueue

Especially ApiListener#ReplayLog() fills it aggressively. After some time that queue is emptied by #WriteOutgoingMessages(). Unless it's been stopped, either by itself or by #Disconnect().

Expected behavior

  • #Disconnect() immediately sets an atomic bool
  • (1) and (2) from above happen only depending on that bool (also consult https://en.cppreference.com/w/cpp/atomic/memory_order)
  • The closure #Disconnect() posts clears #m_OutgoingMessagesQueue ASAP

Additional context

ref/IP/48306

Al2Klimov avatar Feb 01 '24 11:02 Al2Klimov

@lippserd Admittedly this was already present in v2.11.x with the new network stack, same for what actually fills our queues:

  • #8475

Al2Klimov avatar Feb 02 '24 13:02 Al2Klimov

Btw. also an unnecessary in-memory queue:

  • #9855

Al2Klimov avatar Feb 07 '24 13:02 Al2Klimov