Hello everyone!
I was experiencing resolving issues on some Mac OS X systems using c-ares 1.7.0, where some or all requests to resolve a domain name would fail with a ARES_ECONNREFUSED error. This originally occurred indirectly through libcurl, but it is also reproducible in a standalone debugging app).
After some digging, I found two distinct situations that resulted in this error:
- Internet access through some Airport base stations that were bridged to a combo modem/router
- Missing /etc/resolv.conf
The first issue was caused by the IPv6/IPv4 improvements after 1.6.0, since resolving the domain with PF_UNSPEC would result in ARES_ECONNREFUSED failure for the IPv6 lookup. As a result the IPv4 lookup didn't happen at all, and nothing would resolve.
The second problem seems to be a rather rare configuration anomaly in Mac OS X. Normally /etc/resolv.conf is a symlink to /var/run/resolv.conf, but in this case the link wasn't present. Since the OS always places the original in /var/run/resolv.conf, I think it's better to use this path for OS X specifically.
Cheers,
Jan
------
Proposed patches:
--- ares_gethostbyname.c 2009-11-02 19:45:45.000000000 +0100
+++ ares_gethostbyname.c 2010-01-31 23:34:51.000000000 +0100
@@ -208,7 +208,7 @@ static void host_callback(void *arg, int
}
end_hquery(hquery, status, host);
}
- else if ((status == ARES_ENODATA || status == ARES_EBADRESP || status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
+ else if ((status == ARES_ENODATA || status == ARES_EBADRESP || status == ARES_ETIMEOUT || status == ARES_ECONNREFUSED) && hquery->sent_family == AF_INET6)
{
/* The AAAA query yielded no useful result. Now look up an A instead.
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
--- ares_private.h 2009-11-10 20:19:08.000000000 +0100
+++ ares_private.h 2010-01-31 23:06:46.000000000 +0100
@@ -76,7 +76,12 @@
#else
+#ifdef __APPLE__
+#define PATH_RESOLV_CONF "/var/run/resolv.conf"
+#else
#define PATH_RESOLV_CONF "/etc/resolv.conf"
+#endif
+
#ifdef ETC_INET
#define PATH_HOSTS "/etc/inet/hosts"
#else
Received on 2010-02-01