From 0a9563b3db52b2397b0efa3afecea4287c3afd0c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 9 Sep 2019 13:37:44 +0200 Subject: [PATCH] HttpServerConnection#ProcessMessages(): avoid I/O if shutting down refs #7431 --- lib/remote/httpserverconnection.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; } -- 2.50.1