mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
HttpServerConnection#ProcessMessages(): avoid I/O if shutting down
refs #7431
This commit is contained in:
parent
b85b8b9697
commit
0a9563b3db
@ -143,11 +143,15 @@ bool EnsureValidHeaders(
|
|||||||
boost::beast::flat_buffer& buf,
|
boost::beast::flat_buffer& buf,
|
||||||
boost::beast::http::parser<true, boost::beast::http::string_body>& parser,
|
boost::beast::http::parser<true, boost::beast::http::string_body>& parser,
|
||||||
boost::beast::http::response<boost::beast::http::string_body>& response,
|
boost::beast::http::response<boost::beast::http::string_body>& response,
|
||||||
|
bool& shuttingDown,
|
||||||
boost::asio::yield_context& yc
|
boost::asio::yield_context& yc
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
namespace http = boost::beast::http;
|
namespace http = boost::beast::http;
|
||||||
|
|
||||||
|
if (shuttingDown)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool httpError = false;
|
bool httpError = false;
|
||||||
String errorMsg;
|
String errorMsg;
|
||||||
|
|
||||||
@ -348,6 +352,7 @@ bool EnsureValidBody(
|
|||||||
boost::beast::http::parser<true, boost::beast::http::string_body>& parser,
|
boost::beast::http::parser<true, boost::beast::http::string_body>& parser,
|
||||||
ApiUser::Ptr& authenticatedUser,
|
ApiUser::Ptr& authenticatedUser,
|
||||||
boost::beast::http::response<boost::beast::http::string_body>& response,
|
boost::beast::http::response<boost::beast::http::string_body>& response,
|
||||||
|
bool& shuttingDown,
|
||||||
boost::asio::yield_context& yc
|
boost::asio::yield_context& yc
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -390,6 +395,9 @@ bool EnsureValidBody(
|
|||||||
parser.body_limit(maxSize);
|
parser.body_limit(maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shuttingDown)
|
||||||
|
return false;
|
||||||
|
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
|
|
||||||
http::async_read(stream, buf, parser, yc[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.
|
// Best practice is to always reset the buffer.
|
||||||
buf = {};
|
buf = {};
|
||||||
if (!EnsureValidHeaders(*m_Stream, buf, parser, response, yc)) {
|
if (!EnsureValidHeaders(*m_Stream, buf, parser, response, m_ShuttingDown, yc)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,7 +557,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
|
|||||||
|
|
||||||
// Best practice is to always reset the buffer.
|
// Best practice is to always reset the buffer.
|
||||||
buf = {};
|
buf = {};
|
||||||
if (!EnsureValidBody(*m_Stream, buf, parser, authenticatedUser, response, yc)) {
|
if (!EnsureValidBody(*m_Stream, buf, parser, authenticatedUser, response, m_ShuttingDown, yc)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user