diff --git a/include/opendht/dht_proxy_client.h b/include/opendht/dht_proxy_client.h index bcf6f3c9a570abee395fef9f33e9f48fda45ffc4..f5ac83480ce1bd7ffb7976677f7b910de13c5615 100644 --- a/include/opendht/dht_proxy_client.h +++ b/include/opendht/dht_proxy_client.h @@ -277,6 +277,7 @@ private: * Start the connection with a server. */ void startProxy(); + void stop(); /** * Get informations from the proxy node diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp index 228329cfe45f2d1a4a5b319e3a2bb400d3b82758..b96ce11195ed8083fa868a6368b3a2ae029e1d41 100644 --- a/src/dht_proxy_client.cpp +++ b/src/dht_proxy_client.cpp @@ -133,6 +133,12 @@ DhtProxyClient::handleProxyConfirm(const asio::error_code &ec) } DhtProxyClient::~DhtProxyClient() +{ + stop(); +} + +void +DhtProxyClient::stop() { isDestroying_ = true; cancelAllOperations(); @@ -200,8 +206,7 @@ DhtProxyClient::cancelAllListeners() void DhtProxyClient::shutdown(ShutdownCallback cb) { - cancelAllOperations(); - cancelAllListeners(); + stop(); if (cb) cb(); }