From 50ba81cd230f9054fa7c45cb4202ce8720c502b3 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 28 Sep 2007 14:46:51 +0000 Subject: 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.) --- ares_query.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ares_query.c') diff --git a/ares_query.c b/ares_query.c index 0cd6557..c5fc124 100644 --- a/ares_query.c +++ b/ares_query.c @@ -37,7 +37,7 @@ struct qquery { void *arg; }; -static void qcallback(void *arg, int status, unsigned char *abuf, int alen); +static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen); void ares__rc4(rc4_key* key, unsigned char *buffer_ptr, int buffer_len) { @@ -110,7 +110,8 @@ void ares_query(ares_channel channel, const char *name, int dnsclass, &qlen); if (status != ARES_SUCCESS) { - callback(arg, status, NULL, 0); + if (qbuf != NULL) free(qbuf); + callback(arg, status, 0, NULL, 0); return; } @@ -121,7 +122,7 @@ void ares_query(ares_channel channel, const char *name, int dnsclass, if (!qquery) { ares_free_string(qbuf); - callback(arg, ARES_ENOMEM, NULL, 0); + callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } qquery->callback = callback; @@ -132,14 +133,14 @@ void ares_query(ares_channel channel, const char *name, int dnsclass, ares_free_string(qbuf); } -static void qcallback(void *arg, int status, unsigned char *abuf, int alen) +static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen) { struct qquery *qquery = (struct qquery *) arg; unsigned int ancount; int rcode; if (status != ARES_SUCCESS) - qquery->callback(qquery->arg, status, abuf, alen); + qquery->callback(qquery->arg, status, timeouts, abuf, alen); else { /* Pull the response code and answer count from the packet. */ @@ -168,7 +169,7 @@ static void qcallback(void *arg, int status, unsigned char *abuf, int alen) status = ARES_EREFUSED; break; } - qquery->callback(qquery->arg, status, abuf, alen); + qquery->callback(qquery->arg, status, timeouts, abuf, alen); } free(qquery); } -- cgit v1.2.3