HttpClient class is not thread safe, we should protect it as we only have one socket

This commit is contained in:
Benjamin Sergeant 2019-06-05 18:43:35 -07:00
parent 6e0463c981
commit 03a2f1443b
2 changed files with 5 additions and 0 deletions

View File

@ -109,6 +109,10 @@ namespace ix
HttpRequestArgsPtr args,
int redirects)
{
// We only have one socket connection, so we cannot
// make multiple requests concurrently.
std::lock_guard<std::mutex> lock(_mutex);
uint64_t uploadSize = 0;
uint64_t downloadSize = 0;
int code = 0;

View File

@ -156,5 +156,6 @@ namespace ix
std::thread _thread;
std::shared_ptr<Socket> _socket;
std::mutex _mutex; // to protect accessing the _socket (only one socket per client)
};
} // namespace ix