From 368a842d2e56605ab545abfc546e76b95effba43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Sun, 8 Apr 2018 13:06:59 -0400 Subject: [PATCH] proxy client: don't block resolving address --- src/dht_proxy_client.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp index 44de6d05..9682ac9d 100644 --- a/src/dht_proxy_client.cpp +++ b/src/dht_proxy_client.cpp @@ -463,13 +463,13 @@ DhtProxyClient::getProxyInfos() } // A node can have a Ipv4 and a Ipv6. So, we need to retrieve all public ips - auto hostAndService = splitPort(serverHost_); - auto resolved_proxies = SockAddr::resolve(hostAndService.first, hostAndService.second); auto serverHost = serverHost_; // Try to contact the proxy and set the status to connected when done. // will change the connectivity status - statusThread_ = std::thread([this, resolved_proxies, serverHost]{ + statusThread_ = std::thread([this, serverHost]{ + auto hostAndService = splitPort(serverHost); + auto resolved_proxies = SockAddr::resolve(hostAndService.first, hostAndService.second); for (const auto& resolved_proxy: resolved_proxies) { auto server = resolved_proxy.toString(); if (resolved_proxy.getFamily() == AF_INET6) { @@ -481,7 +481,8 @@ DhtProxyClient::getProxyInfos() auto req = std::make_shared(uri); restbed::Http::async(req, [this, resolved_proxy](const std::shared_ptr&, - const std::shared_ptr& reply) { + const std::shared_ptr& reply) + { auto code = reply->get_status_code(); Json::Value proxyInfos; if (code == 200) { @@ -498,11 +499,10 @@ DhtProxyClient::getProxyInfos() } onProxyInfos(proxyInfos, resolved_proxy.getFamily()); } - ongoingStatusUpdate_.clear(); }); + ongoingStatusUpdate_.clear(); } }); - statusThread_.detach(); } void