diff --git a/include/opendht/dht_proxy_client.h b/include/opendht/dht_proxy_client.h index 6384f577837cef06305a9ed0ae5a089bc2c20e13..3afa8af60dd8ac5d881e472af9f70c0bcd4daf2b 100644 --- a/include/opendht/dht_proxy_client.h +++ b/include/opendht/dht_proxy_client.h @@ -319,10 +319,6 @@ private: * cancel all Listeners */ void cancelAllListeners(); - /** - * cancel all Operations - */ - void cancelAllOperations(); std::atomic_bool isDestroying_ {false}; diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp index 32dad3e03d780b403b37415bf980754a024b31cf..cd9a14af90cf73bed650015d538ddee5cce83b33 100644 --- a/src/dht_proxy_client.cpp +++ b/src/dht_proxy_client.cpp @@ -154,12 +154,16 @@ DhtProxyClient::stop() { isDestroying_ = true; resolver_.reset(); - cancelAllOperations(); cancelAllListeners(); if (infoState_) infoState_->cancel = true; - for (auto& request : requests_) - request.second->cancel(); + { + std::lock_guard<std::mutex> lock(requestLock_); + for (auto& request : requests_) + request.second->cancel(); + } + if (not httpContext_.stopped()) + httpContext_.stop(); if (httpClientThread_.joinable()) httpClientThread_.join(); requests_.clear(); @@ -183,13 +187,6 @@ DhtProxyClient::getLocalById(const InfoHash& k, Value::Id id) const { return s->second.ops.get(id); } -void -DhtProxyClient::cancelAllOperations() -{ - if (!httpContext_.stopped()) - httpContext_.stop(); -} - void DhtProxyClient::cancelAllListeners() {