diff --git a/include/opendht/dht_proxy_client.h b/include/opendht/dht_proxy_client.h index 577cdae5358a0ebcfea79f108a76e44d3d771515..848ea0af6d7c81d2e97b8d7552982b0aefdb4e41 100644 --- a/include/opendht/dht_proxy_client.h +++ b/include/opendht/dht_proxy_client.h @@ -264,11 +264,10 @@ public: std::vector<unsigned> getNodeMessageStats(bool) override { return {}; } void setStorageLimit(size_t) override {} void connectivityChanged(sa_family_t) override { - restartListeners(); + getProxyInfos(); } void connectivityChanged() override { getProxyInfos(); - restartListeners(); loopSignal_(); } @@ -385,7 +384,7 @@ private: /** * Relaunch LISTEN requests if the client disconnect/reconnect. */ - void restartListeners(); + void restartListeners(const asio::error_code &ec); /** * Refresh a listen via a token diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp index 18f9c5250f194a939a1e28fc7b1bcd34ed31e0a1..247c9d6da8c859c046e336c7942b6ec57ffe9852 100644 --- a/src/dht_proxy_client.cpp +++ b/src/dht_proxy_client.cpp @@ -720,7 +720,7 @@ DhtProxyClient::onProxyInfos(const Json::Value& proxyInfos, const sa_family_t fa if (newStatus == NodeStatus::Connected) { if (oldStatus == NodeStatus::Disconnected || oldStatus == NodeStatus::Connecting) { listenerRestartTimer_->expires_at(std::chrono::steady_clock::now()); - listenerRestartTimer_->async_wait(std::bind(&DhtProxyClient::restartListeners, this)); + listenerRestartTimer_->async_wait(std::bind(&DhtProxyClient::restartListeners, this, std::placeholders::_1)); } nextProxyConfirmationTimer_->expires_at(std::chrono::steady_clock::now() + std::chrono::minutes(15)); nextProxyConfirmationTimer_->async_wait(std::bind(&DhtProxyClient::handleProxyConfirm, this, std::placeholders::_1)); @@ -1078,8 +1078,16 @@ DhtProxyClient::getConnectivityStatus() } void -DhtProxyClient::restartListeners() +DhtProxyClient::restartListeners(const asio::error_code &ec) { + if (ec == asio::error::operation_aborted) + return; + else if (ec){ + if (logger_) + logger_->e("[proxy:client] restart error: %s", ec.message().c_str()); + return; + } + if (isDestroying_) return; if (logger_)