Loading lib/hostares.c +3 −2 Original line number Diff line number Diff line Loading @@ -350,7 +350,8 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ struct in6_addr in6; #endif /* CURLRES_IPV6 */ *waitp = FALSE; *waitp = 0; /* default to synchronous response */ /* First check if this is an IPv4 address string */ if(Curl_inet_pton(AF_INET, hostname, &in) > 0) { Loading Loading @@ -396,7 +397,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, ares_gethostbyname(data->state.areschannel, hostname, family, (ares_host_callback)ares_query_completed_cb, conn); *waitp = TRUE; /* please wait for the response */ *waitp = 1; /* expect asynchronous response */ } return NULL; /* no struct yet */ } Loading lib/hostip.h +6 −3 Original line number Diff line number Diff line #ifndef __HOSTIP_H #define __HOSTIP_H #ifndef HEADER_CURL_HOSTIP_H #define HEADER_CURL_HOSTIP_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | Loading Loading @@ -165,6 +165,9 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa, int line, const char *source); #endif /* IPv4 threadsafe resolve function used for synch and asynch builds */ Curl_addrinfo *Curl_ipv4_resolve_r(const char * hostname, int port); /* * Curl_addrinfo_callback() is used when we build with any asynch specialty. * Handles end of async request processing. Inserts ai into hostcache when Loading Loading @@ -214,4 +217,4 @@ void Curl_destroy_thread_data(struct Curl_async *async); extern sigjmp_buf curl_jmpenv; #endif #endif #endif /* HEADER_CURL_HOSTIP_H */ lib/hostip4.c +48 −18 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 @@ -87,8 +87,7 @@ bool Curl_ipvalid(struct SessionHandle *data) return TRUE; /* OK, proceed */ } #ifdef CURLRES_SYNCH /* the functions below are for synchronous resolves */ #ifdef CURLRES_SYNCH /* * Curl_getaddrinfo() - the ipv4 synchronous version. * Loading @@ -109,6 +108,33 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, const char *hostname, int port, int *waitp) { Curl_addrinfo *ai = NULL; #ifdef CURL_DISABLE_VERBOSE_STRINGS (void)conn; #endif *waitp = 0; /* synchronous response only */ ai = Curl_ipv4_resolve_r(hostname, port); if(!ai) infof(conn->data, "Curl_ipv4_resolve_r failed for %s\n", hostname); return ai; } #endif /* CURLRES_SYNCH */ #endif /* CURLRES_IPV4 */ /* * Curl_ipv4_resolve_r() - ipv4 threadsafe resolver function. * * This is used for both synchronous and asynchronous resolver builds, * implying that only threadsafe code and function calls may be used. * */ Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port) { #if defined(HAVE_GETHOSTBYNAME_R_3) int res; Loading @@ -118,17 +144,28 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, struct in_addr in; struct hostent *buf = NULL; #ifdef CURL_DISABLE_VERBOSE_STRINGS (void)conn; #endif *waitp = 0; /* don't wait, we act synchronously */ if(Curl_inet_pton(AF_INET, hostname, &in) > 0) /* This is a dotted IP address 123.123.123.123-style */ return Curl_ip2addr(AF_INET, &in, hostname, port); #if defined(HAVE_GETHOSTBYNAME_R) #if defined(HAVE_GETADDRINFO_THREADSAFE) else { struct addrinfo hints; char sbuf[NI_MAXSERV]; char *sbufptr = NULL; int error; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_INET; hints.ai_socktype = SOCK_STREAM; if (port) { snprintf(sbuf, sizeof(sbuf), "%d", port); sbufptr = sbuf; } hints.ai_flags = AI_CANONNAME; error = Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &ai); #elif defined(HAVE_GETHOSTBYNAME_R) /* * gethostbyname_r() is the preferred resolve function for many platforms. * Since there are three different versions of it, the following code is Loading Loading @@ -261,7 +298,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, else #endif /* HAVE_GETHOSTBYNAME_R_3 */ { infof(conn->data, "gethostbyname_r(2) failed for %s\n", hostname); h = NULL; /* set return code to NULL */ free(buf); } Loading @@ -276,8 +312,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, #else h = gethostbyname(hostname); #endif if(!h) infof(conn->data, "gethostbyname(2) failed for %s\n", hostname); #endif /*HAVE_GETHOSTBYNAME_R */ } Loading @@ -290,7 +324,3 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, return ai; } #endif /* CURLRES_SYNCH */ #endif /* CURLRES_IPV4 */ lib/hostip6.c +3 −3 Original line number Diff line number Diff line Loading @@ -126,7 +126,7 @@ bool Curl_ipvalid(struct SessionHandle *data) return TRUE; } #if !defined(USE_THREADING_GETADDRINFO) && !defined(CURLRES_ARES) #if defined(CURLRES_SYNCH) #ifdef DEBUG_ADDRINFO static void dump_addrinfo(struct connectdata *conn, const Curl_addrinfo *ai) Loading Loading @@ -170,7 +170,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, int pf; struct SessionHandle *data = conn->data; *waitp=0; /* don't wait, we have the response now */ *waitp = 0; /* synchronous response only */ /* * Check if a limited name resolve has been requested. Loading Loading @@ -234,6 +234,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, return res; } #endif /* !USE_THREADING_GETADDRINFO && !CURLRES_ARES */ #endif /* CURLRES_SYNCH */ #endif /* CURLRES_IPV6 */ lib/hostthre.c +224 −405 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
lib/hostares.c +3 −2 Original line number Diff line number Diff line Loading @@ -350,7 +350,8 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ struct in6_addr in6; #endif /* CURLRES_IPV6 */ *waitp = FALSE; *waitp = 0; /* default to synchronous response */ /* First check if this is an IPv4 address string */ if(Curl_inet_pton(AF_INET, hostname, &in) > 0) { Loading Loading @@ -396,7 +397,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, ares_gethostbyname(data->state.areschannel, hostname, family, (ares_host_callback)ares_query_completed_cb, conn); *waitp = TRUE; /* please wait for the response */ *waitp = 1; /* expect asynchronous response */ } return NULL; /* no struct yet */ } Loading
lib/hostip.h +6 −3 Original line number Diff line number Diff line #ifndef __HOSTIP_H #define __HOSTIP_H #ifndef HEADER_CURL_HOSTIP_H #define HEADER_CURL_HOSTIP_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | Loading Loading @@ -165,6 +165,9 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa, int line, const char *source); #endif /* IPv4 threadsafe resolve function used for synch and asynch builds */ Curl_addrinfo *Curl_ipv4_resolve_r(const char * hostname, int port); /* * Curl_addrinfo_callback() is used when we build with any asynch specialty. * Handles end of async request processing. Inserts ai into hostcache when Loading Loading @@ -214,4 +217,4 @@ void Curl_destroy_thread_data(struct Curl_async *async); extern sigjmp_buf curl_jmpenv; #endif #endif #endif /* HEADER_CURL_HOSTIP_H */
lib/hostip4.c +48 −18 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 @@ -87,8 +87,7 @@ bool Curl_ipvalid(struct SessionHandle *data) return TRUE; /* OK, proceed */ } #ifdef CURLRES_SYNCH /* the functions below are for synchronous resolves */ #ifdef CURLRES_SYNCH /* * Curl_getaddrinfo() - the ipv4 synchronous version. * Loading @@ -109,6 +108,33 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, const char *hostname, int port, int *waitp) { Curl_addrinfo *ai = NULL; #ifdef CURL_DISABLE_VERBOSE_STRINGS (void)conn; #endif *waitp = 0; /* synchronous response only */ ai = Curl_ipv4_resolve_r(hostname, port); if(!ai) infof(conn->data, "Curl_ipv4_resolve_r failed for %s\n", hostname); return ai; } #endif /* CURLRES_SYNCH */ #endif /* CURLRES_IPV4 */ /* * Curl_ipv4_resolve_r() - ipv4 threadsafe resolver function. * * This is used for both synchronous and asynchronous resolver builds, * implying that only threadsafe code and function calls may be used. * */ Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port) { #if defined(HAVE_GETHOSTBYNAME_R_3) int res; Loading @@ -118,17 +144,28 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, struct in_addr in; struct hostent *buf = NULL; #ifdef CURL_DISABLE_VERBOSE_STRINGS (void)conn; #endif *waitp = 0; /* don't wait, we act synchronously */ if(Curl_inet_pton(AF_INET, hostname, &in) > 0) /* This is a dotted IP address 123.123.123.123-style */ return Curl_ip2addr(AF_INET, &in, hostname, port); #if defined(HAVE_GETHOSTBYNAME_R) #if defined(HAVE_GETADDRINFO_THREADSAFE) else { struct addrinfo hints; char sbuf[NI_MAXSERV]; char *sbufptr = NULL; int error; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_INET; hints.ai_socktype = SOCK_STREAM; if (port) { snprintf(sbuf, sizeof(sbuf), "%d", port); sbufptr = sbuf; } hints.ai_flags = AI_CANONNAME; error = Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &ai); #elif defined(HAVE_GETHOSTBYNAME_R) /* * gethostbyname_r() is the preferred resolve function for many platforms. * Since there are three different versions of it, the following code is Loading Loading @@ -261,7 +298,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, else #endif /* HAVE_GETHOSTBYNAME_R_3 */ { infof(conn->data, "gethostbyname_r(2) failed for %s\n", hostname); h = NULL; /* set return code to NULL */ free(buf); } Loading @@ -276,8 +312,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, #else h = gethostbyname(hostname); #endif if(!h) infof(conn->data, "gethostbyname(2) failed for %s\n", hostname); #endif /*HAVE_GETHOSTBYNAME_R */ } Loading @@ -290,7 +324,3 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, return ai; } #endif /* CURLRES_SYNCH */ #endif /* CURLRES_IPV4 */
lib/hostip6.c +3 −3 Original line number Diff line number Diff line Loading @@ -126,7 +126,7 @@ bool Curl_ipvalid(struct SessionHandle *data) return TRUE; } #if !defined(USE_THREADING_GETADDRINFO) && !defined(CURLRES_ARES) #if defined(CURLRES_SYNCH) #ifdef DEBUG_ADDRINFO static void dump_addrinfo(struct connectdata *conn, const Curl_addrinfo *ai) Loading Loading @@ -170,7 +170,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, int pf; struct SessionHandle *data = conn->data; *waitp=0; /* don't wait, we have the response now */ *waitp = 0; /* synchronous response only */ /* * Check if a limited name resolve has been requested. Loading Loading @@ -234,6 +234,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, return res; } #endif /* !USE_THREADING_GETADDRINFO && !CURLRES_ARES */ #endif /* CURLRES_SYNCH */ #endif /* CURLRES_IPV6 */