From 10c014bf98fbc1d87aefda93332223d90f08953f Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Fri, 19 Jun 2020 00:11:06 -0700 Subject: [PATCH] (http client) fix deadlock when following redirects --- docs/CHANGELOG.md | 4 ++++ ixwebsocket/IXHttpClient.cpp | 2 +- ixwebsocket/IXHttpClient.h | 4 +++- ixwebsocket/IXWebSocketVersion.h | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 59e68e03..537b9987 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All changes to this project will be documented in this file. +## [9.7.9] - 2020-06-18 + +(http client) fix deadlock when following redirects + ## [9.7.8] - 2020-06-18 (cobra metrics to statsd bot) send info about net requests diff --git a/ixwebsocket/IXHttpClient.cpp b/ixwebsocket/IXHttpClient.cpp index ef8da7da..49da10da 100644 --- a/ixwebsocket/IXHttpClient.cpp +++ b/ixwebsocket/IXHttpClient.cpp @@ -127,7 +127,7 @@ namespace ix { // We only have one socket connection, so we cannot // make multiple requests concurrently. - std::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); uint64_t uploadSize = 0; uint64_t downloadSize = 0; diff --git a/ixwebsocket/IXHttpClient.h b/ixwebsocket/IXHttpClient.h index f591b1e9..828a5fe7 100644 --- a/ixwebsocket/IXHttpClient.h +++ b/ixwebsocket/IXHttpClient.h @@ -103,7 +103,9 @@ namespace ix std::thread _thread; std::unique_ptr _socket; - std::mutex _mutex; // to protect accessing the _socket (only one socket per client) + std::recursive_mutex _mutex; // to protect accessing the _socket (only one socket per client) + // the mutex needs to be recursive as this function might + // be called recursively to follow HTTP redirections SocketTLSOptions _tlsOptions; diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 6db51798..21215abf 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "9.7.8" +#define IX_WEBSOCKET_VERSION "9.7.9"