Merge pull request #7483 from Icinga/bugfix/jsonrpc-boost-asio-coroutine-exceptions

JsonRpcConnection: Don't swallow exceptions in Boost.Coroutine
This commit is contained in:
Michael Friedrich 2019-09-09 10:21:21 +02:00 committed by GitHub
commit 5aa5ab956d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 12 deletions

View File

@ -78,6 +78,14 @@ void HttpServerConnection::Disconnect()
Log(LogInformation, "HttpServerConnection") Log(LogInformation, "HttpServerConnection")
<< "HTTP client disconnected (from " << m_PeerAddress << ")"; << "HTTP client disconnected (from " << m_PeerAddress << ")";
/*
* Do not swallow exceptions in a coroutine.
* https://github.com/Icinga/icinga2/issues/7351
* We must not catch `detail::forced_unwind exception` as
* this is used for unwinding the stack.
*
* Just use the error_code dummy here.
*/
boost::system::error_code ec; boost::system::error_code ec;
m_Stream->next_layer().async_shutdown(yc[ec]); m_Stream->next_layer().async_shutdown(yc[ec]);

View File

@ -214,20 +214,21 @@ void JsonRpcConnection::Disconnect()
m_WriterDone.Wait(yc); m_WriterDone.Wait(yc);
try { /*
m_Stream->next_layer().async_shutdown(yc); * Do not swallow exceptions in a coroutine.
} catch (...) { * https://github.com/Icinga/icinga2/issues/7351
} * We must not catch `detail::forced_unwind exception` as
* this is used for unwinding the stack.
*
* Just use the error_code dummy here.
*/
boost::system::error_code ec;
try { m_Stream->next_layer().async_shutdown(yc[ec]);
m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both);
} catch (...) {
}
try { m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both, ec);
m_Stream->lowest_layer().cancel();
} catch (...) { m_Stream->lowest_layer().cancel(ec);
}
m_CheckLivenessTimer.cancel(); m_CheckLivenessTimer.cancel();
m_HeartbeatTimer.cancel(); m_HeartbeatTimer.cancel();