From: Alexander A. Klimov Date: Mon, 9 Sep 2019 11:37:44 +0000 (+0200) Subject: HttpServerConnection#ProcessMessages(): avoid I/O if shutting down X-Git-Tag: v2.11.0~1^2~9^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a9563b3db52b2397b0efa3afecea4287c3afd0c;p=icinga2 HttpServerConnection#ProcessMessages(): avoid I/O if shutting down refs #7431 --- diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index a73e99f82..524916b4e 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -143,11 +143,15 @@ bool EnsureValidHeaders( boost::beast::flat_buffer& buf, boost::beast::http::parser& parser, boost::beast::http::response& response, + bool& shuttingDown, boost::asio::yield_context& yc ) { namespace http = boost::beast::http; + if (shuttingDown) + return false; + bool httpError = false; String errorMsg; @@ -348,6 +352,7 @@ bool EnsureValidBody( boost::beast::http::parser& parser, ApiUser::Ptr& authenticatedUser, boost::beast::http::response& response, + bool& shuttingDown, boost::asio::yield_context& yc ) { @@ -390,6 +395,9 @@ bool EnsureValidBody( parser.body_limit(maxSize); } + if (shuttingDown) + return false; + boost::system::error_code ec; http::async_read(stream, buf, parser, yc[ec]); @@ -502,7 +510,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc) // Best practice is to always reset the buffer. buf = {}; - if (!EnsureValidHeaders(*m_Stream, buf, parser, response, yc)) { + if (!EnsureValidHeaders(*m_Stream, buf, parser, response, m_ShuttingDown, yc)) { break; } @@ -549,7 +557,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc) // Best practice is to always reset the buffer. buf = {}; - if (!EnsureValidBody(*m_Stream, buf, parser, authenticatedUser, response, yc)) { + if (!EnsureValidBody(*m_Stream, buf, parser, authenticatedUser, response, m_ShuttingDown, yc)) { break; }