aboutsummaryrefslogtreecommitdiff
path: root/lib/hostares.c
diff options
context:
space:
mode:
authorTommie Gannert <tommie@spotify.com>2010-12-18 22:31:39 +0100
committerDaniel Stenberg <daniel@haxx.se>2010-12-18 22:33:27 +0100
commit8ab137b2bc9630ce20f45fd09b4ed2149afa45fd (patch)
treed7142eff2af46a955cc74a2929819bc2e0cbfc65 /lib/hostares.c
parentbcfb9ea34cc7cddbbf74376aa16043681e4745a7 (diff)
ares: ask for both IPv4 and IPv6 addresses
Make the c-ares resolver code ask for both IPv4 and IPv6 addresses when IPv6 is enabled. This is a workaround for the missing ares_getaddrinfo() and is a lot easier to implement. Note that as long as c-ares returns IPv4 addresses when IPv6 addresses were requested but missing, this will cause a host's IPv4 addresses to occur twice in the DNS cache. URL: http://curl.haxx.se/mail/lib-2010-12/0041.html
Diffstat (limited to 'lib/hostares.c')
-rw-r--r--lib/hostares.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/hostares.c b/lib/hostares.c
index 97cb27ab9..a86ba435b 100644
--- a/lib/hostares.c
+++ b/lib/hostares.c
@@ -398,13 +398,30 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
Curl_safefree(conn->async.hostname);
conn->async.hostname = bufp;
conn->async.port = port;
- conn->async.done = FALSE; /* not done */
- conn->async.status = 0; /* clear */
- conn->async.dns = NULL; /* clear */
+ conn->async.done = FALSE; /* not done */
+ conn->async.status = 0; /* clear */
+ conn->async.dns = NULL; /* clear */
+ conn->async.temp_ai = NULL; /* clear */
- /* areschannel is already setup in the Curl_open() function */
- ares_gethostbyname(data->state.areschannel, hostname, family,
- (ares_host_callback)ares_query_completed_cb, conn);
+#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
+ if(family == PF_UNSPEC) {
+ conn->async.num_pending = 2;
+
+ /* areschannel is already setup in the Curl_open() function */
+ ares_gethostbyname(data->state.areschannel, hostname, PF_INET,
+ ares_query_completed_cb, conn);
+ ares_gethostbyname(data->state.areschannel, hostname, PF_INET6,
+ ares_query_completed_cb, conn);
+ }
+ else
+#endif /* CURLRES_IPV6 */
+ {
+ conn->async.num_pending = 1;
+
+ /* areschannel is already setup in the Curl_open() function */
+ ares_gethostbyname(data->state.areschannel, hostname, family,
+ ares_query_completed_cb, conn);
+ }
*waitp = 1; /* expect asynchronous response */
}