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

This commit is contained in:
Benjamin Sergeant committed 2019-06-05 18:43:35 -07:00
1 parent 6e0463c981
commit 03a2f1443b
2 files changed
+5

No files matched your search

+4
View File
@@ -109,6 +109,10 @@ namespace ix
HttpRequestArgsPtr args, HttpRequestArgsPtr args,
int redirects) 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 uploadSize = 0;
uint64_t downloadSize = 0; uint64_t downloadSize = 0;
int code = 0; int code = 0;
+1
View File
@@ -156,5 +156,6 @@ namespace ix
std::thread _thread; std::thread _thread;
std::shared_ptr<Socket> _socket; std::shared_ptr<Socket> _socket;
std::mutex _mutex; // to protect accessing the _socket (only one socket per client)
}; };
} // namespace ix } // namespace ix