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
This commit is contained in:
Tommie Gannert
2010-12-18 22:31:39 +01:00
committed by Daniel Stenberg
parent bcfb9ea34c
commit 8ab137b2bc
3 changed files with 80 additions and 8 deletions

View File

@@ -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 */
}