From ebb0826be0a4398e0fc9c9fc44e65392669ab737 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 9 Sep 2019 09:26:12 +0200 Subject: [PATCH] JsonRpcConnection: Don't swallow exceptions in Boost.Coroutine refs #7351 --- lib/remote/httpserverconnection.cpp | 8 ++++++++ lib/remote/jsonrpcconnection.cpp | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index e9c834d3a..01b32f403 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -78,6 +78,14 @@ void HttpServerConnection::Disconnect() Log(LogInformation, "HttpServerConnection") << "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; m_Stream->next_layer().async_shutdown(yc[ec]); diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index 3c775f68d..e63f1183a 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -214,20 +214,21 @@ void JsonRpcConnection::Disconnect() m_WriterDone.Wait(yc); - try { - m_Stream->next_layer().async_shutdown(yc); - } catch (...) { - } + /* + * 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; - try { - m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both); - } catch (...) { - } + m_Stream->next_layer().async_shutdown(yc[ec]); - try { - m_Stream->lowest_layer().cancel(); - } catch (...) { - } + m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both, ec); + + m_Stream->lowest_layer().cancel(ec); m_CheckLivenessTimer.cancel(); m_HeartbeatTimer.cancel(); -- 2.40.0