mirror of https://github.com/Icinga/icinga2.git
HttpServerConnection#ProcessMessages(): avoid I/O after boost::asio::error::operation_aborted
refs #7431
This commit is contained in:
parent
dfaeb88ac3
commit
b85b8b9697
|
@ -21,10 +21,12 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <boost/asio/error.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
#include <boost/beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <boost/beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/system/system_error.hpp>
|
#include <boost/system/system_error.hpp>
|
||||||
#include <boost/thread/once.hpp>
|
#include <boost/thread/once.hpp>
|
||||||
|
|
||||||
|
@ -154,16 +156,19 @@ bool EnsureValidHeaders(
|
||||||
http::async_read_header(stream, buf, parser, yc[ec]);
|
http::async_read_header(stream, buf, parser, yc[ec]);
|
||||||
|
|
||||||
if (ec) {
|
if (ec) {
|
||||||
|
if (ec == boost::asio::error::operation_aborted)
|
||||||
|
return false;
|
||||||
|
|
||||||
errorMsg = ec.message();
|
errorMsg = ec.message();
|
||||||
httpError = true;
|
httpError = true;
|
||||||
}
|
} else {
|
||||||
|
switch (parser.get().version()) {
|
||||||
switch (parser.get().version()) {
|
case 10:
|
||||||
case 10:
|
case 11:
|
||||||
case 11:
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
errorMsg = "Unsupported HTTP version";
|
||||||
errorMsg = "Unsupported HTTP version";
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!errorMsg.IsEmpty() || httpError) {
|
if (!errorMsg.IsEmpty() || httpError) {
|
||||||
|
@ -390,6 +395,9 @@ bool EnsureValidBody(
|
||||||
http::async_read(stream, buf, parser, yc[ec]);
|
http::async_read(stream, buf, parser, yc[ec]);
|
||||||
|
|
||||||
if (ec) {
|
if (ec) {
|
||||||
|
if (ec == boost::asio::error::operation_aborted)
|
||||||
|
return false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unfortunately there's no way to tell an HTTP protocol error
|
* Unfortunately there's no way to tell an HTTP protocol error
|
||||||
* from an error on a lower layer:
|
* from an error on a lower layer:
|
||||||
|
@ -443,6 +451,12 @@ bool ProcessRequest(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto sysErr (dynamic_cast<const boost::system::system_error*>(&ex));
|
||||||
|
|
||||||
|
if (sysErr && sysErr->code() == boost::asio::error::operation_aborted) {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
http::response<http::string_body> response;
|
http::response<http::string_body> response;
|
||||||
|
|
||||||
HttpUtility::SendJsonError(response, nullptr, 500, "Unhandled exception" , DiagnosticInformation(ex));
|
HttpUtility::SendJsonError(response, nullptr, 500, "Unhandled exception" , DiagnosticInformation(ex));
|
||||||
|
|
Loading…
Reference in New Issue