From e7b03e4d53bcf62a2775bffa61f13fa83b1a033c Mon Sep 17 00:00:00 2001 From: Seva <seva@binarytrails.net> Date: Tue, 16 Jul 2019 15:46:13 -0400 Subject: [PATCH] dhtproxy: unify client destruction & shutdown with stop() --- include/opendht/dht_proxy_client.h | 1 + src/dht_proxy_client.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/opendht/dht_proxy_client.h b/include/opendht/dht_proxy_client.h index bcf6f3c9..f5ac8348 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 228329cf..b96ce111 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(); } -- GitLab