aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/hostip.c27
-rw-r--r--lib/hostip.h3
-rw-r--r--lib/multi.c6
3 files changed, 23 insertions, 13 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index 1a881cf9b..8b1e80d47 100644
--- a/lib/hostip.c
+++ b/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
diff --git a/lib/hostip.h b/lib/hostip.h
index 2f53f4f16..f902b5c64 100644
--- a/lib/hostip.h
+++ b/lib/hostip.h
@@ -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,
diff --git a/lib/multi.c b/lib/multi.c
index a1e10d59b..39ab97799 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -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);