diff options
author | Yang Tse <yangsita@gmail.com> | 2010-01-22 06:36:52 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-01-22 06:36:52 +0000 |
commit | bfc4c33985aa40557a7b48d8052577b0c8bd0c5c (patch) | |
tree | 20a119eb6fc7b0260a9a55dd75bf4ab4b9db9f06 /lib/hostares.c | |
parent | 5af20c70e4ae23437378d92e162d3377d9666b1f (diff) |
Constantine Sapuntzakis refactoring of async callbacks, allowing
removal of Curl_addrinfo_copy(), Curl_addrinfo6_callback(), and
Curl_addrinfo4_callback()
Diffstat (limited to 'lib/hostares.c')
-rw-r--r-- | lib/hostares.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/hostares.c b/lib/hostares.c index 3b729315e..94240a6ab 100644 --- a/lib/hostares.c +++ b/lib/hostares.c @@ -304,6 +304,31 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, return rc; } +/* + * ares_query_completed_cb() is the callback that ares will call when + * the host query initiated by ares_gethostbyname() from Curl_getaddrinfo(), + * when using ares, is completed either successfully or with failure. + */ +static void ares_query_completed_cb(void *arg, /* (struct connectdata *) */ + int status, +#ifdef HAVE_CARES_CALLBACK_TIMEOUTS + int timeouts, +#endif + struct hostent *hostent) +{ + struct connectdata *conn = (struct connectdata *)arg; + struct Curl_addrinfo * ai = NULL; + +#ifdef HAVE_CARES_CALLBACK_TIMEOUTS + (void)timeouts; /* ignored */ +#endif + + if (status == CURL_ASYNC_SUCCESS) { + ai = Curl_he2ai(hostent, conn->async.port); + } + + (void)Curl_addrinfo_callback(arg, status, ai); +} /* * Curl_getaddrinfo() - when using ares @@ -369,7 +394,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, /* areschannel is already setup in the Curl_open() function */ ares_gethostbyname(data->state.areschannel, hostname, family, - (ares_host_callback)Curl_addrinfo4_callback, conn); + (ares_host_callback)ares_query_completed_cb, conn); *waitp = TRUE; /* please wait for the response */ } |