Skip to content
Snippets Groups Projects
Commit e3114cd5 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

proxy client: catch name resolving exception

parent 84894330
Branches
Tags
No related merge requests found
...@@ -490,10 +490,11 @@ DhtProxyClient::getProxyInfos() ...@@ -490,10 +490,11 @@ DhtProxyClient::getProxyInfos()
if (statusThread_.joinable()) if (statusThread_.joinable())
statusThread_.join(); statusThread_.join();
statusThread_ = std::thread([this, serverHost]{ statusThread_ = std::thread([this, serverHost]{
auto hostAndService = splitPort(serverHost);
auto resolved_proxies = SockAddr::resolve(hostAndService.first, hostAndService.second);
struct SuccessCount {std::atomic_uint ipv4 {0}, ipv6 {0};}; struct SuccessCount {std::atomic_uint ipv4 {0}, ipv6 {0};};
auto successCount = std::make_shared<SuccessCount>(); auto successCount = std::make_shared<SuccessCount>();
try {
auto hostAndService = splitPort(serverHost);
auto resolved_proxies = SockAddr::resolve(hostAndService.first, hostAndService.second);
std::vector<std::future<Sp<restbed::Response>>> reqs; std::vector<std::future<Sp<restbed::Response>>> reqs;
reqs.reserve(resolved_proxies.size()); reqs.reserve(resolved_proxies.size());
for (const auto& resolved_proxy: resolved_proxies) { for (const auto& resolved_proxy: resolved_proxies) {
...@@ -535,6 +536,9 @@ DhtProxyClient::getProxyInfos() ...@@ -535,6 +536,9 @@ DhtProxyClient::getProxyInfos()
for (auto& r : reqs) for (auto& r : reqs)
r.get(); r.get();
reqs.clear(); reqs.clear();
} catch (const std::exception& e) {
DHT_LOG.e("Error sending proxy info request: %s", e.what());
}
if (successCount->ipv4 == 0) onProxyInfos(Json::Value{}, AF_INET); if (successCount->ipv4 == 0) onProxyInfos(Json::Value{}, AF_INET);
if (successCount->ipv6 == 0) onProxyInfos(Json::Value{}, AF_INET6); if (successCount->ipv6 == 0) onProxyInfos(Json::Value{}, AF_INET6);
ongoingStatusUpdate_.clear(); ongoingStatusUpdate_.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment