Exceptions in Disconnect() might be thrown (this has been reworked
into error_code locally) which are swallowed inside the Destructor
for being dangerous. On the other hand, swallowing them may
corrupt the stack unwinding operation from the coroutine layer.
The best is to avoid Defer inside lib/remote and call Disconnect()
directly after breaking from other operations.
refs #7351
refs #7431
Defer shutDownIfNeeded ([&sslConn, &willBeShutDown, &yc]() {
if (!willBeShutDown) {
- sslConn.async_shutdown(yc);
+ // Ignore the error, but do not throw an exception being swallowed at all cost.
+ // https://github.com/Icinga/icinga2/issues/7351
+ boost::system::error_code ec;
+ sslConn.async_shutdown(yc[ec]);
}
});
namespace beast = boost::beast;
namespace http = beast::http;
- Defer disconnect ([this]() { Disconnect(); });
-
try {
beast::flat_buffer buf;
<< "Unhandled exception while processing HTTP request: " << ex.what();
}
}
+
+ Disconnect();
}
void HttpServerConnection::CheckLiveness(boost::asio::yield_context yc)
void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc)
{
- Defer disconnect ([this]() { Disconnect(); });
-
for (;;) {
String message;
l_TaskStats.InsertValue(Utility::GetTime(), 1);
}
+
+ Disconnect();
}
void JsonRpcConnection::WriteOutgoingMessages(boost::asio::yield_context yc)
{
- Defer disconnect ([this]() { Disconnect(); });
-
Defer signalWriterDone ([this]() { m_WriterDone.Set(); });
do {
}
}
} while (!m_ShuttingDown);
+
+ Disconnect();
}
double JsonRpcConnection::GetTimestamp() const