Skip to content
Snippets Groups Projects
Commit 476d0bca authored by Adrien Béraud's avatar Adrien Béraud
Browse files

proxy client: lock while canceling requests

parent 259986e7
No related branches found
No related tags found
No related merge requests found
...@@ -319,10 +319,6 @@ private: ...@@ -319,10 +319,6 @@ private:
* cancel all Listeners * cancel all Listeners
*/ */
void cancelAllListeners(); void cancelAllListeners();
/**
* cancel all Operations
*/
void cancelAllOperations();
std::atomic_bool isDestroying_ {false}; std::atomic_bool isDestroying_ {false};
......
...@@ -154,12 +154,16 @@ DhtProxyClient::stop() ...@@ -154,12 +154,16 @@ DhtProxyClient::stop()
{ {
isDestroying_ = true; isDestroying_ = true;
resolver_.reset(); resolver_.reset();
cancelAllOperations();
cancelAllListeners(); cancelAllListeners();
if (infoState_) if (infoState_)
infoState_->cancel = true; infoState_->cancel = true;
{
std::lock_guard<std::mutex> lock(requestLock_);
for (auto& request : requests_) for (auto& request : requests_)
request.second->cancel(); request.second->cancel();
}
if (not httpContext_.stopped())
httpContext_.stop();
if (httpClientThread_.joinable()) if (httpClientThread_.joinable())
httpClientThread_.join(); httpClientThread_.join();
requests_.clear(); requests_.clear();
...@@ -183,13 +187,6 @@ DhtProxyClient::getLocalById(const InfoHash& k, Value::Id id) const { ...@@ -183,13 +187,6 @@ DhtProxyClient::getLocalById(const InfoHash& k, Value::Id id) const {
return s->second.ops.get(id); return s->second.ops.get(id);
} }
void
DhtProxyClient::cancelAllOperations()
{
if (!httpContext_.stopped())
httpContext_.stop();
}
void void
DhtProxyClient::cancelAllListeners() DhtProxyClient::cancelAllListeners()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment