Fix possible terminate called for uncaught exception in InterserverIOHTTPHandler::handleRequest

This commit is contained in:
Kruglov Pavel 2023-04-24 17:03:48 +02:00 committed by GitHub
parent 029c92344b
commit bc0c431eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,10 +93,13 @@ void InterserverIOHTTPHandler::handleRequest(HTTPServerRequest & request, HTTPSe
auto write_response = [&](const std::string & message)
{
if (response.sent())
return;
auto & out = *used_output.out;
if (response.sent())
{
out.finalize();
return;
}
try
{
writeString(message, out);
@ -127,7 +130,10 @@ void InterserverIOHTTPHandler::handleRequest(HTTPServerRequest & request, HTTPSe
catch (Exception & e)
{
if (e.code() == ErrorCodes::TOO_MANY_SIMULTANEOUS_QUERIES)
{
used_output.out->finalize();
return;
}
response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);