diff --git a/include/opendht/dht_proxy_client.h b/include/opendht/dht_proxy_client.h index 2c0c3fb45c1a54581d4edb31d8c5920b185ff69c..80198a7f4f0a46c11e8f71db3eda91f44e7c6a3a 100644 --- a/include/opendht/dht_proxy_client.h +++ b/include/opendht/dht_proxy_client.h @@ -330,18 +330,6 @@ private: //std::pair<std::string, std::string> serverHostService_; std::string pushClientId_; - /* - * ASIO I/O Context for sockets in httpClient_ - * Note: Each context is used in one thread only - */ - asio::io_context httpContext_; - std::shared_ptr<http::Resolver> resolver_; - std::map<unsigned int /*id*/, std::shared_ptr<http::Request>> requests_; - /* - * Thread for executing the http io_context.run() blocking call - */ - std::thread httpClientThread_; - mutable std::mutex lockCurrentProxyInfos_; NodeStatus statusIpv4_ {NodeStatus::Disconnected}; NodeStatus statusIpv6_ {NodeStatus::Disconnected}; @@ -355,20 +343,32 @@ private: // registred types TypeStore types; + /* + * ASIO I/O Context for sockets in httpClient_ + * Note: Each context is used in one thread only + */ + asio::io_context httpContext_; + std::shared_ptr<http::Resolver> resolver_; + std::map<unsigned int /*id*/, std::shared_ptr<http::Request>> requests_; + /* + * Thread for executing the http io_context.run() blocking call + */ + std::thread httpClientThread_; + /** * Store listen requests. */ struct ProxySearch; + mutable std::mutex searchLock_; size_t listenerToken_ {0}; std::map<InfoHash, ProxySearch> searches_; - mutable std::mutex searchLock_; /** * Callbacks should be executed in the main thread. */ - std::vector<std::function<void()>> callbacks_; std::mutex lockCallbacks_; + std::vector<std::function<void()>> callbacks_; Sp<InfoState> infoState_; diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp index 73b974867ce3cf686b1c3e047a62fd7aeeee33d8..3495802a6029f2a97ab5a5f0417702382ef71cba 100644 --- a/src/dht_proxy_client.cpp +++ b/src/dht_proxy_client.cpp @@ -981,6 +981,8 @@ DhtProxyClient::sendListen(const restinio::http_request_header_t header, void DhtProxyClient::opFailed() { + if (isDestroying_) + return; if (logger_) logger_->e("[proxy:client] proxy request failed"); {