From e5b9ff4a39ba870f70fc7ab1ca0aaed503a6eaab Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Wed, 13 Nov 2024 17:18:28 +0100 Subject: [PATCH] Add comment for remaining uses of async_shutdown() why it's safe The reason for introducing AsioTlsStream::GracefulDisconnect() was to handle the TLS shutdown properly with a timeout since it involves a timeout. However, the implementation of this timeout involves spwaning coroutines which are redundant in some cases. This commit adds comments to the remaining calls of async_shutdown() stating why calling it is safe in these places. --- lib/methods/ifwapichecktask.cpp | 2 ++ lib/remote/apilistener.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/methods/ifwapichecktask.cpp b/lib/methods/ifwapichecktask.cpp index 2f5ff9c6c2..fb0cee6260 100644 --- a/lib/methods/ifwapichecktask.cpp +++ b/lib/methods/ifwapichecktask.cpp @@ -102,6 +102,8 @@ static void DoIfwNetIo( } { + // Using async_shutdown() instead of AsioTlsStream::GracefulDisconnect() as this whole function + // is already guarded by a timeout based on the check timeout. boost::system::error_code ec; sslConn.async_shutdown(yc[ec]); } diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 32e63daf73..2c2bb7c81a 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -719,6 +719,9 @@ void ApiListener::NewClientHandlerInternal( // 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; + + // Using async_shutdown() instead of AsioTlsStream::GracefulDisconnect() as this whole function + // is already guarded by a timeout based on the connect timeout. sslConn.async_shutdown(yc[ec]); } });