summaryrefslogtreecommitdiff
path: root/ares_search.c
diff options
context:
space:
mode:
authorSteinar H. Gunderson <sesse@google.com>2007-09-28 14:46:51 +0000
committerSteinar H. Gunderson <sesse@google.com>2007-09-28 14:46:51 +0000
commit50ba81cd230f9054fa7c45cb4202ce8720c502b3 (patch)
tree277c02b995aacc09540ec58270e10cd1845ff2b3 /ares_search.c
parentb669e17544c0ff64d120b8a0df2677c59ccea8fd (diff)
downloadc-ares-50ba81cd230f9054fa7c45cb4202ce8720c502b3.tar.gz
c-ares-50ba81cd230f9054fa7c45cb4202ce8720c502b3.tar.bz2
c-ares-50ba81cd230f9054fa7c45cb4202ce8720c502b3.zip
Make the query callbacks return the number of timeouts that happened during the execution of a query, and update documentation accordingly. (Patch from the Google tree.)
Diffstat (limited to 'ares_search.c')
-rw-r--r--ares_search.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/ares_search.c b/ares_search.c
index 4ff5453..ca703a3 100644
--- a/ares_search.c
+++ b/ares_search.c
@@ -41,10 +41,11 @@ struct search_query {
int status_as_is; /* error status from trying as-is */
int next_domain; /* next search domain to try */
int trying_as_is; /* current query is for name as-is */
+ int timeouts; /* number of timeouts we saw for this request */
};
-static void search_callback(void *arg, int status, unsigned char *abuf,
- int alen);
+static void search_callback(void *arg, int status, int timeouts,
+ unsigned char *abuf, int alen);
static void end_squery(struct search_query *squery, int status,
unsigned char *abuf, int alen);
static int cat_domain(const char *name, const char *domain, char **s);
@@ -64,7 +65,7 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
status = single_domain(channel, name, &s);
if (status != ARES_SUCCESS)
{
- callback(arg, status, NULL, 0);
+ callback(arg, status, 0, NULL, 0);
return;
}
if (s)
@@ -80,7 +81,7 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
squery = malloc(sizeof(struct search_query));
if (!squery)
{
- callback(arg, ARES_ENOMEM, NULL, 0);
+ callback(arg, ARES_ENOMEM, 0, NULL, 0);
return;
}
squery->channel = channel;
@@ -88,7 +89,7 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
if (!squery->name)
{
free(squery);
- callback(arg, ARES_ENOMEM, NULL, 0);
+ callback(arg, ARES_ENOMEM, 0, NULL, 0);
return;
}
squery->dnsclass = dnsclass;
@@ -96,6 +97,7 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
squery->status_as_is = -1;
squery->callback = callback;
squery->arg = arg;
+ squery->timeouts = 0;
/* Count the number of dots in name. */
ndots = 0;
@@ -132,18 +134,20 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
/* failed, free the malloc()ed memory */
free(squery->name);
free(squery);
- callback(arg, status, NULL, 0);
+ callback(arg, status, 0, NULL, 0);
}
}
}
-static void search_callback(void *arg, int status, unsigned char *abuf,
- int alen)
+static void search_callback(void *arg, int status, int timeouts,
+ unsigned char *abuf, int alen)
{
struct search_query *squery = (struct search_query *) arg;
ares_channel channel = squery->channel;
char *s;
+ squery->timeouts += timeouts;
+
/* Stop searching unless we got a non-fatal error. */
if (status != ARES_ENODATA && status != ARES_ESERVFAIL
&& status != ARES_ENOTFOUND)
@@ -184,7 +188,7 @@ static void search_callback(void *arg, int status, unsigned char *abuf,
static void end_squery(struct search_query *squery, int status,
unsigned char *abuf, int alen)
{
- squery->callback(squery->arg, status, abuf, alen);
+ squery->callback(squery->arg, status, squery->timeouts, abuf, alen);
free(squery->name);
free(squery);
}