mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +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;
|
headers_started_sending = true;
|
||||||
|
|
||||||
if (response.getChunkedTransferEncoding())
|
if (!response.getChunkedTransferEncoding() && response.getContentLength() == Poco::Net::HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
||||||
setChunked();
|
|
||||||
else if (response.getContentLength() == Poco::Net::HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
|
||||||
{
|
{
|
||||||
/// In case there is no Content-Length we cannot use keep-alive,
|
/// 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
|
/// since there is no way to know when the server send all the
|
||||||
@ -134,6 +132,8 @@ WriteBufferFromHTTPServerResponse::WriteBufferFromHTTPServerResponse(
|
|||||||
, response(response_)
|
, response(response_)
|
||||||
, is_http_method_head(is_http_method_head_)
|
, 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*/)
|
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);
|
auto out = responseWriteBuffer(request, response);
|
||||||
|
|
||||||
try
|
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.
|
/// Workaround. Poco does not detect 411 Length Required case.
|
||||||
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST && !request.getChunkedTransferEncoding() && !request.hasContentLength())
|
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST && !request.getChunkedTransferEncoding() && !request.hasContentLength())
|
||||||
throw Exception(ErrorCodes::HTTP_LENGTH_REQUIRED,
|
throw Exception(ErrorCodes::HTTP_LENGTH_REQUIRED,
|
||||||
|
Loading…
Reference in New Issue
Block a user