mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
Don't endlessly wait on writer coroutine on disconnect
This commit is contained in:
parent
f2fbb61ad8
commit
7b30cb3431
@ -213,7 +213,22 @@ void JsonRpcConnection::Disconnect()
|
|||||||
IoEngine::SpawnCoroutine(m_IoStrand, [this, keepAlive](asio::yield_context yc) {
|
IoEngine::SpawnCoroutine(m_IoStrand, [this, keepAlive](asio::yield_context yc) {
|
||||||
m_OutgoingMessagesQueued.Set();
|
m_OutgoingMessagesQueued.Set();
|
||||||
|
|
||||||
m_WriterDone.Wait(yc);
|
{
|
||||||
|
Timeout writerTimeout(
|
||||||
|
m_IoStrand,
|
||||||
|
boost::posix_time::seconds(5),
|
||||||
|
[this]() {
|
||||||
|
// The writer coroutine could not finish soon enough to unblock the waiter down blow,
|
||||||
|
// so we have to do this on our own, and the coroutine will be terminated forcibly when
|
||||||
|
// the ops on the underlying socket are cancelled.
|
||||||
|
boost::system::error_code ec;
|
||||||
|
m_Stream->lowest_layer().cancel(ec);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
m_WriterDone.Wait(yc);
|
||||||
|
// We don't need to explicitly cancel the timer here; its destructor will handle it for us.
|
||||||
|
}
|
||||||
|
|
||||||
m_CheckLivenessTimer.cancel();
|
m_CheckLivenessTimer.cancel();
|
||||||
m_HeartbeatTimer.cancel();
|
m_HeartbeatTimer.cancel();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user