HttpClient class is not thread safe, we should protect it as we only have one socket
This commit is contained in:
parent
6e0463c981
commit
03a2f1443b
@ -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;
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user