mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
Merge pull request #69601 from ClickHouse/fix-tsan-writebufferfromhttpserverresponse
Try to fix data race in `WriteBufferFromHTTPServerResponse`
This commit is contained in:
commit
a329150eef
@ -17,9 +17,7 @@ void WriteBufferFromHTTPServerResponse::startSendHeaders()
|
||||
{
|
||||
headers_started_sending = true;
|
||||
|
||||
if (response.getChunkedTransferEncoding())
|
||||
setChunked();
|
||||
else if (response.getContentLength() == Poco::Net::HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
||||
if (!response.getChunkedTransferEncoding() && response.getContentLength() == Poco::Net::HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
||||
{
|
||||
/// In case there is no Content-Length we cannot use keep-alive,
|
||||
/// since there is no way to know when the server send all the
|
||||
@ -134,6 +132,8 @@ WriteBufferFromHTTPServerResponse::WriteBufferFromHTTPServerResponse(
|
||||
, response(response_)
|
||||
, is_http_method_head(is_http_method_head_)
|
||||
{
|
||||
if (response.getChunkedTransferEncoding())
|
||||
setChunked();
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,15 +90,15 @@ static inline void trySendExceptionToClient(
|
||||
|
||||
void StaticRequestHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse & response, const ProfileEvents::Event & /*write_event*/)
|
||||
{
|
||||
applyHTTPResponseHeaders(response, http_response_headers_override);
|
||||
|
||||
if (request.getVersion() == Poco::Net::HTTPServerRequest::HTTP_1_1)
|
||||
response.setChunkedTransferEncoding(true);
|
||||
|
||||
auto out = responseWriteBuffer(request, response);
|
||||
|
||||
try
|
||||
{
|
||||
applyHTTPResponseHeaders(response, http_response_headers_override);
|
||||
|
||||
if (request.getVersion() == Poco::Net::HTTPServerRequest::HTTP_1_1)
|
||||
response.setChunkedTransferEncoding(true);
|
||||
|
||||
/// Workaround. Poco does not detect 411 Length Required case.
|
||||
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST && !request.getChunkedTransferEncoding() && !request.hasContentLength())
|
||||
throw Exception(ErrorCodes::HTTP_LENGTH_REQUIRED,
|
||||
|
Loading…
Reference in New Issue
Block a user