c-ares: improve error message on failed resolve
When the c-ares based resolver backend failed to resolve a name, it tried to show the name that failed from existing structs. This caused the wrong output and shown hostname when for example --interface [hostname] was used and that name resolving failed. Now we use the hostname used in the actual resolve attempt in the error message as well. Bug: http://curl.haxx.se/bug/view.cgi?id=1191 Reported-by: Kim Vandry
This commit is contained in:
parent
8a7a277c08
commit
ad47d8e263
@ -315,6 +315,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
|
|||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
struct ResolverResults *res = (struct ResolverResults *)
|
struct ResolverResults *res = (struct ResolverResults *)
|
||||||
conn->async.os_specific;
|
conn->async.os_specific;
|
||||||
|
CURLcode rc = CURLE_OK;
|
||||||
|
|
||||||
*dns = NULL;
|
*dns = NULL;
|
||||||
|
|
||||||
@ -325,19 +326,19 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
|
|||||||
/* temp_ai ownership is moved to the connection, so we need not free-up
|
/* temp_ai ownership is moved to the connection, so we need not free-up
|
||||||
them */
|
them */
|
||||||
res->temp_ai = NULL;
|
res->temp_ai = NULL;
|
||||||
destroy_async_data(&conn->async);
|
|
||||||
if(!conn->async.dns) {
|
if(!conn->async.dns) {
|
||||||
failf(data, "Could not resolve %s: %s (%s)",
|
failf(data, "Could not resolve: %s (%s)",
|
||||||
conn->bits.proxy?"proxy":"host",
|
conn->async.hostname, ares_strerror(conn->async.status));
|
||||||
conn->host.dispname,
|
rc = conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY:
|
||||||
ares_strerror(conn->async.status));
|
|
||||||
return conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY:
|
|
||||||
CURLE_COULDNT_RESOLVE_HOST;
|
CURLE_COULDNT_RESOLVE_HOST;
|
||||||
}
|
}
|
||||||
*dns = conn->async.dns;
|
else
|
||||||
|
*dns = conn->async.dns;
|
||||||
|
|
||||||
|
destroy_async_data(&conn->async);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CURLE_OK;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -415,37 +416,12 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
|
|||||||
if(entry)
|
if(entry)
|
||||||
*entry = conn->async.dns;
|
*entry = conn->async.dns;
|
||||||
|
|
||||||
if(!conn->async.dns) {
|
if(rc)
|
||||||
/* a name was not resolved */
|
|
||||||
if((timeout < 0) || (conn->async.status == ARES_ETIMEOUT)) {
|
|
||||||
if(conn->bits.proxy) {
|
|
||||||
failf(data, "Resolving proxy timed out: %s", conn->proxy.dispname);
|
|
||||||
rc = CURLE_COULDNT_RESOLVE_PROXY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
failf(data, "Resolving host timed out: %s", conn->host.dispname);
|
|
||||||
rc = CURLE_COULDNT_RESOLVE_HOST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(conn->async.done) {
|
|
||||||
if(conn->bits.proxy) {
|
|
||||||
failf(data, "Could not resolve proxy: %s (%s)", conn->proxy.dispname,
|
|
||||||
ares_strerror(conn->async.status));
|
|
||||||
rc = CURLE_COULDNT_RESOLVE_PROXY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
failf(data, "Could not resolve host: %s (%s)", conn->host.dispname,
|
|
||||||
ares_strerror(conn->async.status));
|
|
||||||
rc = CURLE_COULDNT_RESOLVE_HOST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
rc = CURLE_OPERATION_TIMEDOUT;
|
|
||||||
|
|
||||||
/* close the connection, since we can't return failure here without
|
/* close the connection, since we can't return failure here without
|
||||||
cleaning up this connection properly */
|
cleaning up this connection properly.
|
||||||
|
TODO: remove this action from here, it is not a name resolver decision.
|
||||||
|
*/
|
||||||
conn->bits.close = TRUE;
|
conn->bits.close = TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user