Based on a patch provided by Siddhartha Prakash Jain. In Curl_resolv() when
my_getaddrinfo() has been called (and wait has been set to TRUE), we check if the name already is resolved and if so don't return wait status to the parent. This can happen with IP-only names.
This commit is contained in:
Родитель
b864e25011
Коммит
343291ce37
27
lib/hostip.c
27
lib/hostip.c
|
@ -320,10 +320,16 @@ int Curl_resolv(struct connectdata *conn,
|
|||
Curl_addrinfo *addr = my_getaddrinfo(conn, hostname, port, &wait);
|
||||
|
||||
if (!addr) {
|
||||
if(wait)
|
||||
if(wait) {
|
||||
/* the response to our resolve call will come asynchronously at
|
||||
a later time, good or bad */
|
||||
rc = 1;
|
||||
/* First, check that we haven't received the info by now */
|
||||
(void)Curl_is_resolved(conn, &dns);
|
||||
if(dns)
|
||||
rc = 0; /* pointer provided */
|
||||
else
|
||||
rc = 1; /* no info yet */
|
||||
}
|
||||
}
|
||||
else
|
||||
/* we got a response, store it in the cache */
|
||||
|
@ -401,7 +407,8 @@ CURLcode Curl_multi_ares_fdset(struct connectdata *conn,
|
|||
}
|
||||
|
||||
/* called to check if the name is resolved now */
|
||||
CURLcode Curl_is_resolved(struct connectdata *conn, bool *done)
|
||||
CURLcode Curl_is_resolved(struct connectdata *conn,
|
||||
struct Curl_dns_entry **dns)
|
||||
{
|
||||
fd_set read_fds, write_fds;
|
||||
static const struct timeval tv={0,0};
|
||||
|
@ -419,12 +426,12 @@ CURLcode Curl_is_resolved(struct connectdata *conn, bool *done)
|
|||
if(count)
|
||||
ares_process(data->state.areschannel, &read_fds, &write_fds);
|
||||
|
||||
*done = FALSE;
|
||||
*dns = NULL;
|
||||
|
||||
if(conn->async.done) {
|
||||
if(!conn->async.dns)
|
||||
return CURLE_COULDNT_RESOLVE_HOST;
|
||||
*done = TRUE;
|
||||
*dns = conn->async.dns;
|
||||
}
|
||||
|
||||
return CURLE_OK;
|
||||
|
@ -557,7 +564,8 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
|
|||
ares_gethostbyname(data->state.areschannel, hostname, PF_INET,
|
||||
host_callback, conn);
|
||||
|
||||
*waitp = TRUE; /* please wait for the response */
|
||||
|
||||
*waitp = TRUE; /* please wait for the response */
|
||||
}
|
||||
else
|
||||
ares_destroy(data->state.areschannel);
|
||||
|
@ -590,12 +598,13 @@ CURLcode Curl_multi_ares_fdset(struct connectdata *conn,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
CURLcode Curl_is_resolved(struct connectdata *conn, bool *done)
|
||||
CURLcode Curl_is_resolved(struct connectdata *conn,
|
||||
struct Curl_dns_entry **dns)
|
||||
{
|
||||
(void)conn;
|
||||
*done = TRUE;
|
||||
*dns = NULL;
|
||||
|
||||
return CURLE_OK;
|
||||
return CURLE_COULDNT_RESOLVE_HOST;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -57,7 +57,8 @@ int Curl_resolv(struct connectdata *conn,
|
|||
int port,
|
||||
struct Curl_dns_entry **dnsentry);
|
||||
|
||||
CURLcode Curl_is_resolved(struct connectdata *conn, bool *done);
|
||||
CURLcode Curl_is_resolved(struct connectdata *conn,
|
||||
struct Curl_dns_entry **dns);
|
||||
CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
||||
struct Curl_dns_entry **dnsentry);
|
||||
CURLcode Curl_multi_ares_fdset(struct connectdata *conn,
|
||||
|
|
|
@ -360,12 +360,12 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
|
|||
case CURLM_STATE_WAITRESOLVE:
|
||||
/* awaiting an asynch name resolve to complete */
|
||||
{
|
||||
bool done;
|
||||
struct Curl_dns_entry *dns;
|
||||
|
||||
/* check if we have the name resolved by now */
|
||||
easy->result = Curl_is_resolved(easy->easy_conn, &done);
|
||||
easy->result = Curl_is_resolved(easy->easy_conn, &dns);
|
||||
|
||||
if(done) {
|
||||
if(dns) {
|
||||
/* Perform the next step in the connection phase, and then move on
|
||||
to the WAITCONNECT state */
|
||||
easy->result = Curl_async_resolved(easy->easy_conn);
|
||||
|
|
Загрузка…
Ссылка в новой задаче