mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Merge pull request #7485 from Icinga/bugfix/api-disconnect-defer
Avoid the Defer-Disconnect destructor pattern with Boost.Coroutines
This commit is contained in:
commit
b3c48e7520
@ -553,7 +553,10 @@ void ApiListener::NewClientHandlerInternal(boost::asio::yield_context yc, const
|
||||
|
||||
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]);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -472,8 +472,6 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
|
||||
namespace beast = boost::beast;
|
||||
namespace http = beast::http;
|
||||
|
||||
Defer disconnect ([this]() { Disconnect(); });
|
||||
|
||||
try {
|
||||
beast::flat_buffer buf;
|
||||
|
||||
@ -557,6 +555,8 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
|
||||
<< "Unhandled exception while processing HTTP request: " << ex.what();
|
||||
}
|
||||
}
|
||||
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
void HttpServerConnection::CheckLiveness(boost::asio::yield_context yc)
|
||||
|
@ -60,8 +60,6 @@ void JsonRpcConnection::Start()
|
||||
|
||||
void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc)
|
||||
{
|
||||
Defer disconnect ([this]() { Disconnect(); });
|
||||
|
||||
for (;;) {
|
||||
String message;
|
||||
|
||||
@ -97,12 +95,12 @@ void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc)
|
||||
|
||||
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 {
|
||||
@ -136,6 +134,8 @@ void JsonRpcConnection::WriteOutgoingMessages(boost::asio::yield_context yc)
|
||||
}
|
||||
}
|
||||
} while (!m_ShuttingDown);
|
||||
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
double JsonRpcConnection::GetTimestamp() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user