Loading lib/hostares.c +1 −1 Original line number Original line Diff line number Diff line Loading @@ -291,7 +291,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, /* areschannel is already setup in the Curl_open() function */ /* areschannel is already setup in the Curl_open() function */ ares_gethostbyname(data->state.areschannel, hostname, PF_INET, ares_gethostbyname(data->state.areschannel, hostname, PF_INET, Curl_addrinfo4_callback, conn); (ares_callback)Curl_addrinfo4_callback, conn); *waitp = TRUE; /* please wait for the response */ *waitp = TRUE; /* please wait for the response */ } } Loading lib/hostasyn.c +18 −12 Original line number Original line Diff line number Diff line Loading @@ -108,12 +108,13 @@ * * * The storage operation locks and unlocks the DNS cache. * The storage operation locks and unlocks the DNS cache. */ */ static void addrinfo_callback(void *arg, /* "struct connectdata *" */ static CURLcode addrinfo_callback(void *arg, /* "struct connectdata *" */ int status, int status, void *addr) void *addr) { { struct connectdata *conn = (struct connectdata *)arg; struct connectdata *conn = (struct connectdata *)arg; struct Curl_dns_entry *dns = NULL; struct Curl_dns_entry *dns = NULL; CURLcode rc = CURLE_OK; conn->async.status = status; conn->async.status = status; Loading @@ -135,13 +136,17 @@ static void addrinfo_callback(void *arg, /* "struct connectdata *" */ dns = Curl_cache_addr(data, ai, dns = Curl_cache_addr(data, ai, conn->async.hostname, conn->async.hostname, conn->async.port); conn->async.port); if(!dns) if(!dns) { /* failed to store, cleanup and return error */ /* failed to store, cleanup and return error */ Curl_freeaddrinfo(ai); Curl_freeaddrinfo(ai); rc = CURLE_OUT_OF_MEMORY; } if(data->share) if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); Curl_share_unlock(data, CURL_LOCK_DATA_DNS); } } else rc = CURLE_OUT_OF_MEMORY; } } conn->async.dns = dns; conn->async.dns = dns; Loading @@ -153,21 +158,22 @@ static void addrinfo_callback(void *arg, /* "struct connectdata *" */ /* ipv4: The input hostent struct will be freed by ares when we return from /* ipv4: The input hostent struct will be freed by ares when we return from this function */ this function */ return rc; } } void Curl_addrinfo4_callback(void *arg, /* "struct connectdata *" */ CURLcode Curl_addrinfo4_callback(void *arg, /* "struct connectdata *" */ int status, int status, struct hostent *hostent) struct hostent *hostent) { { addrinfo_callback(arg, status, hostent); return addrinfo_callback(arg, status, hostent); } } #ifdef CURLRES_IPV6 #ifdef CURLRES_IPV6 void Curl_addrinfo6_callback(void *arg, /* "struct connectdata *" */ CURLcode Curl_addrinfo6_callback(void *arg, /* "struct connectdata *" */ int status, int status, struct addrinfo *ai) struct addrinfo *ai) { { addrinfo_callback(arg, status, ai); return addrinfo_callback(arg, status, ai); } } #endif #endif Loading lib/hostip.h +6 −6 Original line number Original line Diff line number Diff line Loading @@ -199,12 +199,12 @@ int curl_dogetnameinfo(const struct sockaddr *sa, socklen_t salen, /* This is the callback function that is used when we build with asynch /* This is the callback function that is used when we build with asynch resolve, ipv4 */ resolve, ipv4 */ void Curl_addrinfo4_callback(void *arg, CURLcode Curl_addrinfo4_callback(void *arg, int status, int status, struct hostent *hostent); struct hostent *hostent); /* This is the callback function that is used when we build with asynch /* This is the callback function that is used when we build with asynch resolve, ipv6 */ resolve, ipv6 */ void Curl_addrinfo6_callback(void *arg, CURLcode Curl_addrinfo6_callback(void *arg, int status, int status, struct addrinfo *ai); struct addrinfo *ai); Loading lib/hostthre.c +13 −13 Original line number Original line Diff line number Diff line Loading @@ -190,7 +190,7 @@ static unsigned __stdcall gethostbyname_thread (void *arg) curr_proc, &mutex_waiting, 0, FALSE, curr_proc, &mutex_waiting, 0, FALSE, DUPLICATE_SAME_ACCESS)) { DUPLICATE_SAME_ACCESS)) { /* failed to duplicate the mutex, no point in continuing */ /* failed to duplicate the mutex, no point in continuing */ return 0; return -1; } } /* Sharing the same _iob[] element with our parent thread should /* Sharing the same _iob[] element with our parent thread should Loading @@ -214,12 +214,10 @@ static unsigned __stdcall gethostbyname_thread (void *arg) SetEvent(td->event_resolved); SetEvent(td->event_resolved); if (he) { if (he) { Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he); rc = Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he); rc = 1; } } else { else { Curl_addrinfo4_callback(conn, (int)WSAGetLastError(), NULL); rc = Curl_addrinfo4_callback(conn, (int)WSAGetLastError(), NULL); rc = 0; } } TRACE(("Winsock-error %d, addr %s\n", conn->async.status, TRACE(("Winsock-error %d, addr %s\n", conn->async.status, he ? inet_ntoa(*(struct in_addr*)he->h_addr) : "unknown")); he ? inet_ntoa(*(struct in_addr*)he->h_addr) : "unknown")); Loading Loading @@ -260,7 +258,7 @@ static unsigned __stdcall getaddrinfo_thread (void *arg) curr_proc, &mutex_waiting, 0, FALSE, curr_proc, &mutex_waiting, 0, FALSE, DUPLICATE_SAME_ACCESS)) { DUPLICATE_SAME_ACCESS)) { /* failed to duplicate the mutex, no point in continuing */ /* failed to duplicate the mutex, no point in continuing */ return 0; return -1; } } #ifndef _WIN32_WCE #ifndef _WIN32_WCE Loading @@ -286,10 +284,10 @@ static unsigned __stdcall getaddrinfo_thread (void *arg) #ifdef DEBUG_THREADING_GETADDRINFO #ifdef DEBUG_THREADING_GETADDRINFO dump_addrinfo (conn, res); dump_addrinfo (conn, res); #endif #endif Curl_addrinfo6_callback(conn, CURL_ASYNC_SUCCESS, res); rc = Curl_addrinfo6_callback(conn, CURL_ASYNC_SUCCESS, res); } } else { else { Curl_addrinfo6_callback(conn, (int)WSAGetLastError(), NULL); rc = Curl_addrinfo6_callback(conn, (int)WSAGetLastError(), NULL); TRACE(("Winsock-error %d, no address\n", conn->async.status)); TRACE(("Winsock-error %d, no address\n", conn->async.status)); } } } } Loading Loading @@ -493,7 +491,11 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, if (!conn->async.dns) { if (!conn->async.dns) { /* a name was not resolved */ /* a name was not resolved */ if (td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) { if (td->thread_status == CURLE_OUT_OF_MEMORY) { rc = CURLE_OUT_OF_MEMORY; failf(data, "Could not resolve host: %s", curl_easy_strerror(rc)); } else if (td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) { failf(data, "Resolving host timed out: %s", conn->host.name); failf(data, "Resolving host timed out: %s", conn->host.name); rc = CURLE_OPERATION_TIMEDOUT; rc = CURLE_OPERATION_TIMEDOUT; } } Loading @@ -508,10 +510,8 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, destroy_thread_data(&conn->async); destroy_thread_data(&conn->async); if(CURLE_OK != rc) if(!conn->async.dns) /* close the connection, since we must not return failure from here conn->bits.close = TRUE; without cleaning up this connection properly */ Curl_disconnect(conn); return (rc); return (rc); } } Loading Loading
lib/hostares.c +1 −1 Original line number Original line Diff line number Diff line Loading @@ -291,7 +291,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, /* areschannel is already setup in the Curl_open() function */ /* areschannel is already setup in the Curl_open() function */ ares_gethostbyname(data->state.areschannel, hostname, PF_INET, ares_gethostbyname(data->state.areschannel, hostname, PF_INET, Curl_addrinfo4_callback, conn); (ares_callback)Curl_addrinfo4_callback, conn); *waitp = TRUE; /* please wait for the response */ *waitp = TRUE; /* please wait for the response */ } } Loading
lib/hostasyn.c +18 −12 Original line number Original line Diff line number Diff line Loading @@ -108,12 +108,13 @@ * * * The storage operation locks and unlocks the DNS cache. * The storage operation locks and unlocks the DNS cache. */ */ static void addrinfo_callback(void *arg, /* "struct connectdata *" */ static CURLcode addrinfo_callback(void *arg, /* "struct connectdata *" */ int status, int status, void *addr) void *addr) { { struct connectdata *conn = (struct connectdata *)arg; struct connectdata *conn = (struct connectdata *)arg; struct Curl_dns_entry *dns = NULL; struct Curl_dns_entry *dns = NULL; CURLcode rc = CURLE_OK; conn->async.status = status; conn->async.status = status; Loading @@ -135,13 +136,17 @@ static void addrinfo_callback(void *arg, /* "struct connectdata *" */ dns = Curl_cache_addr(data, ai, dns = Curl_cache_addr(data, ai, conn->async.hostname, conn->async.hostname, conn->async.port); conn->async.port); if(!dns) if(!dns) { /* failed to store, cleanup and return error */ /* failed to store, cleanup and return error */ Curl_freeaddrinfo(ai); Curl_freeaddrinfo(ai); rc = CURLE_OUT_OF_MEMORY; } if(data->share) if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); Curl_share_unlock(data, CURL_LOCK_DATA_DNS); } } else rc = CURLE_OUT_OF_MEMORY; } } conn->async.dns = dns; conn->async.dns = dns; Loading @@ -153,21 +158,22 @@ static void addrinfo_callback(void *arg, /* "struct connectdata *" */ /* ipv4: The input hostent struct will be freed by ares when we return from /* ipv4: The input hostent struct will be freed by ares when we return from this function */ this function */ return rc; } } void Curl_addrinfo4_callback(void *arg, /* "struct connectdata *" */ CURLcode Curl_addrinfo4_callback(void *arg, /* "struct connectdata *" */ int status, int status, struct hostent *hostent) struct hostent *hostent) { { addrinfo_callback(arg, status, hostent); return addrinfo_callback(arg, status, hostent); } } #ifdef CURLRES_IPV6 #ifdef CURLRES_IPV6 void Curl_addrinfo6_callback(void *arg, /* "struct connectdata *" */ CURLcode Curl_addrinfo6_callback(void *arg, /* "struct connectdata *" */ int status, int status, struct addrinfo *ai) struct addrinfo *ai) { { addrinfo_callback(arg, status, ai); return addrinfo_callback(arg, status, ai); } } #endif #endif Loading
lib/hostip.h +6 −6 Original line number Original line Diff line number Diff line Loading @@ -199,12 +199,12 @@ int curl_dogetnameinfo(const struct sockaddr *sa, socklen_t salen, /* This is the callback function that is used when we build with asynch /* This is the callback function that is used when we build with asynch resolve, ipv4 */ resolve, ipv4 */ void Curl_addrinfo4_callback(void *arg, CURLcode Curl_addrinfo4_callback(void *arg, int status, int status, struct hostent *hostent); struct hostent *hostent); /* This is the callback function that is used when we build with asynch /* This is the callback function that is used when we build with asynch resolve, ipv6 */ resolve, ipv6 */ void Curl_addrinfo6_callback(void *arg, CURLcode Curl_addrinfo6_callback(void *arg, int status, int status, struct addrinfo *ai); struct addrinfo *ai); Loading
lib/hostthre.c +13 −13 Original line number Original line Diff line number Diff line Loading @@ -190,7 +190,7 @@ static unsigned __stdcall gethostbyname_thread (void *arg) curr_proc, &mutex_waiting, 0, FALSE, curr_proc, &mutex_waiting, 0, FALSE, DUPLICATE_SAME_ACCESS)) { DUPLICATE_SAME_ACCESS)) { /* failed to duplicate the mutex, no point in continuing */ /* failed to duplicate the mutex, no point in continuing */ return 0; return -1; } } /* Sharing the same _iob[] element with our parent thread should /* Sharing the same _iob[] element with our parent thread should Loading @@ -214,12 +214,10 @@ static unsigned __stdcall gethostbyname_thread (void *arg) SetEvent(td->event_resolved); SetEvent(td->event_resolved); if (he) { if (he) { Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he); rc = Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he); rc = 1; } } else { else { Curl_addrinfo4_callback(conn, (int)WSAGetLastError(), NULL); rc = Curl_addrinfo4_callback(conn, (int)WSAGetLastError(), NULL); rc = 0; } } TRACE(("Winsock-error %d, addr %s\n", conn->async.status, TRACE(("Winsock-error %d, addr %s\n", conn->async.status, he ? inet_ntoa(*(struct in_addr*)he->h_addr) : "unknown")); he ? inet_ntoa(*(struct in_addr*)he->h_addr) : "unknown")); Loading Loading @@ -260,7 +258,7 @@ static unsigned __stdcall getaddrinfo_thread (void *arg) curr_proc, &mutex_waiting, 0, FALSE, curr_proc, &mutex_waiting, 0, FALSE, DUPLICATE_SAME_ACCESS)) { DUPLICATE_SAME_ACCESS)) { /* failed to duplicate the mutex, no point in continuing */ /* failed to duplicate the mutex, no point in continuing */ return 0; return -1; } } #ifndef _WIN32_WCE #ifndef _WIN32_WCE Loading @@ -286,10 +284,10 @@ static unsigned __stdcall getaddrinfo_thread (void *arg) #ifdef DEBUG_THREADING_GETADDRINFO #ifdef DEBUG_THREADING_GETADDRINFO dump_addrinfo (conn, res); dump_addrinfo (conn, res); #endif #endif Curl_addrinfo6_callback(conn, CURL_ASYNC_SUCCESS, res); rc = Curl_addrinfo6_callback(conn, CURL_ASYNC_SUCCESS, res); } } else { else { Curl_addrinfo6_callback(conn, (int)WSAGetLastError(), NULL); rc = Curl_addrinfo6_callback(conn, (int)WSAGetLastError(), NULL); TRACE(("Winsock-error %d, no address\n", conn->async.status)); TRACE(("Winsock-error %d, no address\n", conn->async.status)); } } } } Loading Loading @@ -493,7 +491,11 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, if (!conn->async.dns) { if (!conn->async.dns) { /* a name was not resolved */ /* a name was not resolved */ if (td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) { if (td->thread_status == CURLE_OUT_OF_MEMORY) { rc = CURLE_OUT_OF_MEMORY; failf(data, "Could not resolve host: %s", curl_easy_strerror(rc)); } else if (td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) { failf(data, "Resolving host timed out: %s", conn->host.name); failf(data, "Resolving host timed out: %s", conn->host.name); rc = CURLE_OPERATION_TIMEDOUT; rc = CURLE_OPERATION_TIMEDOUT; } } Loading @@ -508,10 +510,8 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, destroy_thread_data(&conn->async); destroy_thread_data(&conn->async); if(CURLE_OK != rc) if(!conn->async.dns) /* close the connection, since we must not return failure from here conn->bits.close = TRUE; without cleaning up this connection properly */ Curl_disconnect(conn); return (rc); return (rc); } } Loading