mirror of https://gitee.com/bigwinds/arangodb
fix use-after-free for HTTP 100 Continue case (#10397)
This commit is contained in:
parent
211596cfa3
commit
9117a2b14f
|
@ -175,12 +175,12 @@ int HttpCommTask<T>::on_header_complete(llhttp_t* p) {
|
|||
<< "received a 100-continue request";
|
||||
char const* response = "HTTP/1.1 100 Continue\r\n\r\n";
|
||||
auto buff = asio_ns::buffer(response, strlen(response));
|
||||
asio_ns::async_write(self->_protocol->socket, buff,
|
||||
[self](asio_ns::error_code const& ec, std::size_t transferred) {
|
||||
llhttp_resume(&self->_parser);
|
||||
self->asyncReadSome();
|
||||
});
|
||||
return HPE_PAUSED;
|
||||
asio_ns::async_write(self->_protocol->socket, buff, [self = self->shared_from_this()](asio_ns::error_code const& ec, std::size_t) {
|
||||
if (ec) {
|
||||
static_cast<HttpCommTask<T>*>(self.get())->close();
|
||||
}
|
||||
});
|
||||
return HPE_OK;
|
||||
}
|
||||
if (self->_request->requestType() == RequestType::HEAD) {
|
||||
// Assume that request/response has no body, proceed parsing next message
|
||||
|
@ -805,7 +805,8 @@ void HttpCommTask<T>::sendResponse(std::unique_ptr<GeneralResponse> baseRes,
|
|||
RequestStatistics::SET_WRITE_START(stat);
|
||||
|
||||
// FIXME measure performance w/o sync write
|
||||
auto cb = [self = CommTask::shared_from_this(),
|
||||
asio_ns::async_write(this->_protocol->socket, buffers,
|
||||
[self = CommTask::shared_from_this(),
|
||||
h = std::move(header),
|
||||
b = std::move(body),
|
||||
stat](asio_ns::error_code ec, size_t nwrite) {
|
||||
|
@ -827,8 +828,7 @@ void HttpCommTask<T>::sendResponse(std::unique_ptr<GeneralResponse> baseRes,
|
|||
if (stat != nullptr) {
|
||||
stat->release();
|
||||
}
|
||||
};
|
||||
asio_ns::async_write(this->_protocol->socket, buffers, std::move(cb));
|
||||
});
|
||||
}
|
||||
|
||||
template <SocketType T>
|
||||
|
|
Loading…
Reference in New Issue