mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-17 19:30:54 +00:00
take the request lock in open_stream_ before reusing the socket (#2669)
* take the request lock in open_stream_ before reusing the socket * Hold the request lock only while open_stream_ takes the socket The handle owns the connection once the socket is transferred to it, so holding request_mutex_ while the stream wrote its request and read the response head only made requests on other threads wait for the stream. Also shorten the comments. --------- Co-authored-by: yhirose <yuji.hirose.bug@gmail.com>
This commit is contained in:
1 parent
654fd3546c
commit
f57672b390
2 files changed
+41
No files matched your search
@@ -16062,6 +16062,8 @@ inline ClientImpl::StreamHandle ClientImpl::open_stream_(Request &req) {
|
||||
handle.connection_ = detail::make_unique<ClientConnection>();
|
||||
|
||||
{
|
||||
// A request in flight uses socket_ without holding socket_mutex_
|
||||
std::lock_guard<std::recursive_mutex> request_mutex_guard(request_mutex_);
|
||||
std::lock_guard<std::mutex> guard(socket_mutex_);
|
||||
|
||||
if (!socket_reusable()) {
|
||||
|
||||
Reference in new issue
Block a user