Commit b2e8a90a authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #2064 from garlick/issue_2051

Problem: getifaddrs can fail with ECONNREFUSED
parents d44ef4fa d090a871
......@@ -182,7 +182,16 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_
{
// Get the addresses.
ifaddrs *ifa = NULL;
const int rc = getifaddrs (&ifa);
int rc;
const int max_attempts = 10;
const int backoff_msec = 1;
for (int i = 0; i < max_attempts; i++) {
rc = getifaddrs (&ifa);
if (rc == 0 || (rc < 0 && errno != ECONNREFUSED))
break;
usleep ((backoff_msec << i) * 1000);
}
if (rc != 0 && errno == EINVAL) {
// Windows Subsystem for Linux compatibility
LIBZMQ_UNUSED (nic_);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment