]> granicus.if.org Git - icinga2/commitdiff
HttpServerConnection#ProcessMessages(): avoid I/O if shutting down 7487/head
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Mon, 9 Sep 2019 11:37:44 +0000 (13:37 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 9 Sep 2019 11:37:44 +0000 (13:37 +0200)
refs #7431

lib/remote/httpserverconnection.cpp

index a73e99f829584de5b83c32bfb871a18166a5b2a3..524916b4e735bddb6229054f9c4ae7135cb2b7cd 100644 (file)
@@ -143,11 +143,15 @@ bool EnsureValidHeaders(
        boost::beast::flat_buffer& buf,
        boost::beast::http::parser<true, boost::beast::http::string_body>& parser,
        boost::beast::http::response<boost::beast::http::string_body>& 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<true, boost::beast::http::string_body>& parser,
        ApiUser::Ptr& authenticatedUser,
        boost::beast::http::response<boost::beast::http::string_body>& 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;
                        }