Merge pull request #20464 from azat/abnormal-server-termination-fix

Fix abnormal server termination when http client goes away
This commit is contained in:
alesapin 2021-02-15 11:10:29 +03:00 committed by GitHub
commit 9557bca4af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -188,14 +188,14 @@ void WriteBufferFromHTTPServerResponse::onProgress(const Progress & progress)
void WriteBufferFromHTTPServerResponse::finalize()
{
if (offset())
next();
if (out)
{
next();
if (out)
out.reset();
out->next();
out.reset();
}
else
if (!offset())
{
/// If no remaining data, just send headers.
std::lock_guard lock(mutex);

View File

@ -715,7 +715,6 @@ void HTTPHandler::trySendExceptionToClient(const std::string & s, int exception_
writeChar('\n', *used_output.out_maybe_compressed);
used_output.out_maybe_compressed->next();
used_output.out->next();
used_output.out->finalize();
}
}
@ -775,6 +774,9 @@ void HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Ne
trySendExceptionToClient(exception_message, exception_code, request, response, used_output);
}
if (used_output.out)
used_output.out->finalize();
}
DynamicQueryHandler::DynamicQueryHandler(IServer & server_, const std::string & param_name_)