summaryrefslogtreecommitdiff
path: root/ares_gethostbyname.c
diff options
context:
space:
mode:
authorSteinar H. Gunderson <sesse@google.com>2007-11-15 09:16:48 (GMT)
committerSteinar H. Gunderson <sesse@google.com>2007-11-15 09:16:48 (GMT)
commitd9dd2397714b34248888c72ccc448bae1dd7355a (patch)
treec45b480721186f785ea4161423985eae47c6b122 /ares_gethostbyname.c
parentb4bdb6d4d7915bf5e1a89b6ae19f7ffbcd2e8144 (diff)
downloadc-ares-d9dd2397714b34248888c72ccc448bae1dd7355a.zip
c-ares-d9dd2397714b34248888c72ccc448bae1dd7355a.tar.gz
c-ares-d9dd2397714b34248888c72ccc448bae1dd7355a.tar.bz2
When looking up in DNS and then in the hosts file, return the error code from DNS if both fail, instead of returning the error code from the hosts file, as today. Patch from the Google tree.
Diffstat (limited to 'ares_gethostbyname.c')
-rw-r--r--ares_gethostbyname.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c
index b96ac6b..8610cba 100644
--- a/ares_gethostbyname.c
+++ b/ares_gethostbyname.c
@@ -57,7 +57,7 @@ struct host_query {
int timeouts;
};
-static void next_lookup(struct host_query *hquery, int status);
+static void next_lookup(struct host_query *hquery, int status_code);
static void host_callback(void *arg, int status, int timeouts,
unsigned char *abuf, int alen);
static void end_hquery(struct host_query *hquery, int status,
@@ -111,13 +111,14 @@ void ares_gethostbyname(ares_channel channel, const char *name, int family,
hquery->timeouts = 0;
/* Start performing lookups according to channel->lookups. */
- next_lookup(hquery, ARES_SUCCESS);
+ next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */);
}
-static void next_lookup(struct host_query *hquery, int status)
+static void next_lookup(struct host_query *hquery, int status_code)
{
const char *p;
struct hostent *host;
+ int status = status_code;
for (p = hquery->remaining_lookups; *p; p++)
{
@@ -142,6 +143,7 @@ static void next_lookup(struct host_query *hquery, int status)
end_hquery(hquery, status, host);
return;
}
+ status = status_code; /* Use original status code */
break;
}
}