Loading lib/hostares.c +26 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 */ } Loading lib/hostasyn.c +10 −52 Original line number Diff line number Diff line Loading @@ -72,38 +72,27 @@ * Only for builds using asynchronous name resolves **********************************************************************/ #ifdef CURLRES_ASYNCH /* * addrinfo_callback() gets called by ares, gethostbyname_thread() or * getaddrinfo_thread() when we got the name resolved (or not!). * * If the status argument is CURL_ASYNC_SUCCESS, we might need to copy the * address field since it might be freed when this function returns. This * operation stores the resolved data in the DNS cache. * Curl_addrinfo_callback() gets called by ares, gethostbyname_thread() * or getaddrinfo_thread() when we got the name resolved (or not!). * * NOTE: for IPv6 operations, Curl_addrinfo_copy() returns the same * pointer it is given as argument! * If the status argument is CURL_ASYNC_SUCCESS, this function takes * ownership of the Curl_addrinfo passed, storing the resolved data * in the DNS cache. * * The storage operation locks and unlocks the DNS cache. */ static CURLcode addrinfo_callback(void *arg, /* "struct connectdata *" */ CURLcode Curl_addrinfo_callback(struct connectdata * conn, int status, void *addr) struct Curl_addrinfo *ai) { struct connectdata *conn = (struct connectdata *)arg; struct Curl_dns_entry *dns = NULL; CURLcode rc = CURLE_OK; conn->async.status = status; if(CURL_ASYNC_SUCCESS == status) { /* * IPv4/ares: Curl_addrinfo_copy() copies the address and returns an * allocated version. * * IPv6: Curl_addrinfo_copy() returns the input pointer! */ Curl_addrinfo *ai = Curl_addrinfo_copy(addr, conn->async.port); if(ai) { struct SessionHandle *data = conn->data; Loading Loading @@ -138,35 +127,4 @@ static CURLcode addrinfo_callback(void *arg, /* "struct connectdata *" */ return rc; } CURLcode Curl_addrinfo4_callback(void *arg, /* "struct connectdata *" */ int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif struct hostent *hostent) { #ifdef HAVE_CARES_CALLBACK_TIMEOUTS (void)timeouts; /* ignored */ #endif return addrinfo_callback(arg, status, hostent); } #ifdef CURLRES_IPV6 CURLcode Curl_addrinfo6_callback(void *arg, /* "struct connectdata *" */ int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif Curl_addrinfo *ai) { /* NOTE: for CURLRES_ARES, the 'ai' argument is really a * 'struct hostent' pointer. */ #ifdef HAVE_CARES_CALLBACK_TIMEOUTS (void)timeouts; /* ignored */ #endif return addrinfo_callback(arg, status, ai); } #endif #endif /* CURLRES_ASYNC */ #endif /* CURLRES_ASYNCH */ lib/hostip.c +1 −17 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -712,20 +712,4 @@ struct curl_hash *Curl_mk_dnscache(void) return Curl_hash_alloc(7, Curl_hash_str, Curl_str_key_compare, freednsentry); } #ifdef CURLRES_ADDRINFO_COPY /* align on even 64bit boundaries */ #define MEMALIGN(x) ((x)+(8-(((unsigned long)(x))&0x7))) /* * Curl_addrinfo_copy() performs a "deep" copy of a hostent into a buffer and * returns a pointer to the malloc()ed copy. You need to call free() on the * returned buffer when you're done with it. */ Curl_addrinfo *Curl_addrinfo_copy(const void *org, int port) { const struct hostent *orig = org; return Curl_he2ai(orig, port); } #endif /* CURLRES_ADDRINFO_COPY */ lib/hostip.h +10 −34 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -65,23 +65,10 @@ #define CURLRES_IPV4 #endif #if defined(CURLRES_IPV4) || defined(CURLRES_ARES) #if !defined(HAVE_GETHOSTBYNAME_R) || defined(CURLRES_ASYNCH) /* If built for ipv4 and missing gethostbyname_r(), or if using async name resolve, we need the Curl_addrinfo_copy() function (which itself needs the Curl_he2ai() function)) */ #define CURLRES_ADDRINFO_COPY #endif #endif /* IPv4/ares-only */ #ifndef CURLRES_ASYNCH #define CURLRES_SYNCH #endif #ifndef USE_LIBIDN #define CURLRES_IDN #endif /* Allocate enough memory to hold the full name information structs and * everything. OSF1 is known to require at least 8872 bytes. The buffer * required for storing all possible aliases and IP numbers is according to Loading Loading @@ -203,27 +190,16 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa, int line, const char *source); #endif /* This is the callback function that is used when we build with asynch resolve, ipv4 */ CURLcode Curl_addrinfo4_callback(void *arg, int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif struct hostent *hostent); /* This is the callback function that is used when we build with asynch resolve, ipv6 */ CURLcode Curl_addrinfo6_callback(void *arg, /* * Curl_addrinfo_callback() is used when we build with any asynch specialty. * Handles end of async request processing. Inserts ai into hostcache when * status is CURL_ASYNC_SUCCESS. Twiddles fields in conn to indicate async * request completed wether successfull or failed. */ CURLcode Curl_addrinfo_callback(struct connectdata *conn, int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif Curl_addrinfo *ai); /* Clone a Curl_addrinfo struct, works protocol independently */ Curl_addrinfo *Curl_addrinfo_copy(const void *orig, int port); /* * Curl_printable_address() returns a printable version of the 1st address * given in the 'ip' argument. The result will be stored in the buf that is Loading lib/hostip6.c +1 −15 Original line number Diff line number Diff line Loading @@ -75,20 +75,6 @@ **********************************************************************/ #ifdef CURLRES_IPV6 #ifndef CURLRES_ARES #ifdef CURLRES_ASYNCH /* * Curl_addrinfo_copy() is used by the asynch callback to copy a given * address. But this is an ipv6 build and then we don't copy the address, we * just return the same pointer! */ Curl_addrinfo *Curl_addrinfo_copy(const void *orig, int port) { (void) port; return (Curl_addrinfo*)orig; } #endif /* CURLRES_ASYNCH */ #endif /* CURLRES_ARES */ #if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) /* These are strictly for memory tracing and are using the same style as the Loading Loading @@ -249,5 +235,5 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, return res; } #endif /* !USE_THREADING_GETADDRINFO && !CURLRES_ARES */ #endif /* ipv6 */ #endif /* CURLRES_IPV6 */ Loading
lib/hostares.c +26 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 */ } Loading
lib/hostasyn.c +10 −52 Original line number Diff line number Diff line Loading @@ -72,38 +72,27 @@ * Only for builds using asynchronous name resolves **********************************************************************/ #ifdef CURLRES_ASYNCH /* * addrinfo_callback() gets called by ares, gethostbyname_thread() or * getaddrinfo_thread() when we got the name resolved (or not!). * * If the status argument is CURL_ASYNC_SUCCESS, we might need to copy the * address field since it might be freed when this function returns. This * operation stores the resolved data in the DNS cache. * Curl_addrinfo_callback() gets called by ares, gethostbyname_thread() * or getaddrinfo_thread() when we got the name resolved (or not!). * * NOTE: for IPv6 operations, Curl_addrinfo_copy() returns the same * pointer it is given as argument! * If the status argument is CURL_ASYNC_SUCCESS, this function takes * ownership of the Curl_addrinfo passed, storing the resolved data * in the DNS cache. * * The storage operation locks and unlocks the DNS cache. */ static CURLcode addrinfo_callback(void *arg, /* "struct connectdata *" */ CURLcode Curl_addrinfo_callback(struct connectdata * conn, int status, void *addr) struct Curl_addrinfo *ai) { struct connectdata *conn = (struct connectdata *)arg; struct Curl_dns_entry *dns = NULL; CURLcode rc = CURLE_OK; conn->async.status = status; if(CURL_ASYNC_SUCCESS == status) { /* * IPv4/ares: Curl_addrinfo_copy() copies the address and returns an * allocated version. * * IPv6: Curl_addrinfo_copy() returns the input pointer! */ Curl_addrinfo *ai = Curl_addrinfo_copy(addr, conn->async.port); if(ai) { struct SessionHandle *data = conn->data; Loading Loading @@ -138,35 +127,4 @@ static CURLcode addrinfo_callback(void *arg, /* "struct connectdata *" */ return rc; } CURLcode Curl_addrinfo4_callback(void *arg, /* "struct connectdata *" */ int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif struct hostent *hostent) { #ifdef HAVE_CARES_CALLBACK_TIMEOUTS (void)timeouts; /* ignored */ #endif return addrinfo_callback(arg, status, hostent); } #ifdef CURLRES_IPV6 CURLcode Curl_addrinfo6_callback(void *arg, /* "struct connectdata *" */ int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif Curl_addrinfo *ai) { /* NOTE: for CURLRES_ARES, the 'ai' argument is really a * 'struct hostent' pointer. */ #ifdef HAVE_CARES_CALLBACK_TIMEOUTS (void)timeouts; /* ignored */ #endif return addrinfo_callback(arg, status, ai); } #endif #endif /* CURLRES_ASYNC */ #endif /* CURLRES_ASYNCH */
lib/hostip.c +1 −17 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -712,20 +712,4 @@ struct curl_hash *Curl_mk_dnscache(void) return Curl_hash_alloc(7, Curl_hash_str, Curl_str_key_compare, freednsentry); } #ifdef CURLRES_ADDRINFO_COPY /* align on even 64bit boundaries */ #define MEMALIGN(x) ((x)+(8-(((unsigned long)(x))&0x7))) /* * Curl_addrinfo_copy() performs a "deep" copy of a hostent into a buffer and * returns a pointer to the malloc()ed copy. You need to call free() on the * returned buffer when you're done with it. */ Curl_addrinfo *Curl_addrinfo_copy(const void *org, int port) { const struct hostent *orig = org; return Curl_he2ai(orig, port); } #endif /* CURLRES_ADDRINFO_COPY */
lib/hostip.h +10 −34 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -65,23 +65,10 @@ #define CURLRES_IPV4 #endif #if defined(CURLRES_IPV4) || defined(CURLRES_ARES) #if !defined(HAVE_GETHOSTBYNAME_R) || defined(CURLRES_ASYNCH) /* If built for ipv4 and missing gethostbyname_r(), or if using async name resolve, we need the Curl_addrinfo_copy() function (which itself needs the Curl_he2ai() function)) */ #define CURLRES_ADDRINFO_COPY #endif #endif /* IPv4/ares-only */ #ifndef CURLRES_ASYNCH #define CURLRES_SYNCH #endif #ifndef USE_LIBIDN #define CURLRES_IDN #endif /* Allocate enough memory to hold the full name information structs and * everything. OSF1 is known to require at least 8872 bytes. The buffer * required for storing all possible aliases and IP numbers is according to Loading Loading @@ -203,27 +190,16 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa, int line, const char *source); #endif /* This is the callback function that is used when we build with asynch resolve, ipv4 */ CURLcode Curl_addrinfo4_callback(void *arg, int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif struct hostent *hostent); /* This is the callback function that is used when we build with asynch resolve, ipv6 */ CURLcode Curl_addrinfo6_callback(void *arg, /* * Curl_addrinfo_callback() is used when we build with any asynch specialty. * Handles end of async request processing. Inserts ai into hostcache when * status is CURL_ASYNC_SUCCESS. Twiddles fields in conn to indicate async * request completed wether successfull or failed. */ CURLcode Curl_addrinfo_callback(struct connectdata *conn, int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif Curl_addrinfo *ai); /* Clone a Curl_addrinfo struct, works protocol independently */ Curl_addrinfo *Curl_addrinfo_copy(const void *orig, int port); /* * Curl_printable_address() returns a printable version of the 1st address * given in the 'ip' argument. The result will be stored in the buf that is Loading
lib/hostip6.c +1 −15 Original line number Diff line number Diff line Loading @@ -75,20 +75,6 @@ **********************************************************************/ #ifdef CURLRES_IPV6 #ifndef CURLRES_ARES #ifdef CURLRES_ASYNCH /* * Curl_addrinfo_copy() is used by the asynch callback to copy a given * address. But this is an ipv6 build and then we don't copy the address, we * just return the same pointer! */ Curl_addrinfo *Curl_addrinfo_copy(const void *orig, int port) { (void) port; return (Curl_addrinfo*)orig; } #endif /* CURLRES_ASYNCH */ #endif /* CURLRES_ARES */ #if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) /* These are strictly for memory tracing and are using the same style as the Loading Loading @@ -249,5 +235,5 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, return res; } #endif /* !USE_THREADING_GETADDRINFO && !CURLRES_ARES */ #endif /* ipv6 */ #endif /* CURLRES_IPV6 */