summaryrefslogtreecommitdiffstats
path: root/lib/dns/resolver.c
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2010-10-30 21:01:18 +0000
committerdougb <dougb@FreeBSD.org>2010-10-30 21:01:18 +0000
commiteb399bacb260498dc82cc60bff7e32bb7538b8c4 (patch)
tree3b7387d91fd2a2ef9aa09d7a73d475e92199f7d1 /lib/dns/resolver.c
parent6d41f7ac6b360a4d3daf511eefc0708d423832cb (diff)
downloadFreeBSD-src-eb399bacb260498dc82cc60bff7e32bb7538b8c4.zip
FreeBSD-src-eb399bacb260498dc82cc60bff7e32bb7538b8c4.tar.gz
Vendor import of BIND 9.6-ESV-R2
Diffstat (limited to 'lib/dns/resolver.c')
-rw-r--r--lib/dns/resolver.c73
1 files changed, 40 insertions, 33 deletions
diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c
index 244718f..8803a05 100644
--- a/lib/dns/resolver.c
+++ b/lib/dns/resolver.c
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: resolver.c,v 1.384.14.20.8.2 2010/02/25 10:57:12 tbox Exp $ */
+/* $Id: resolver.c,v 1.384.14.20.10.3 2010/06/23 23:46:25 tbox Exp $ */
/*! \file */
@@ -5815,13 +5815,40 @@ answer_response(fetchctx_t *fctx) {
return (result);
}
+static isc_boolean_t
+fctx_decreference(fetchctx_t *fctx) {
+ isc_boolean_t bucket_empty = ISC_FALSE;
+
+ INSIST(fctx->references > 0);
+ fctx->references--;
+ if (fctx->references == 0) {
+ /*
+ * No one cares about the result of this fetch anymore.
+ */
+ if (fctx->pending == 0 && fctx->nqueries == 0 &&
+ ISC_LIST_EMPTY(fctx->validators) && SHUTTINGDOWN(fctx)) {
+ /*
+ * This fctx is already shutdown; we were just
+ * waiting for the last reference to go away.
+ */
+ bucket_empty = fctx_destroy(fctx);
+ } else {
+ /*
+ * Initiate shutdown.
+ */
+ fctx_shutdown(fctx);
+ }
+ }
+ return (bucket_empty);
+}
+
static void
resume_dslookup(isc_task_t *task, isc_event_t *event) {
dns_fetchevent_t *fevent;
dns_resolver_t *res;
fetchctx_t *fctx;
isc_result_t result;
- isc_boolean_t bucket_empty = ISC_FALSE;
+ isc_boolean_t bucket_empty;
isc_boolean_t locked = ISC_FALSE;
unsigned int bucketnum;
dns_rdataset_t nameservers;
@@ -5925,9 +5952,7 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) {
isc_event_free(&event);
if (!locked)
LOCK(&res->buckets[bucketnum].lock);
- fctx->references--;
- if (fctx->references == 0)
- bucket_empty = fctx_destroy(fctx);
+ bucket_empty = fctx_decreference(fctx);
UNLOCK(&res->buckets[bucketnum].lock);
if (bucket_empty)
empty_bucket(res);
@@ -6752,12 +6777,14 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
&fctx->nsfetch);
if (result != ISC_R_SUCCESS)
fctx_done(fctx, result, __LINE__);
- LOCK(&fctx->res->buckets[fctx->bucketnum].lock);
- fctx->references++;
- UNLOCK(&fctx->res->buckets[fctx->bucketnum].lock);
- result = fctx_stopidletimer(fctx);
- if (result != ISC_R_SUCCESS)
- fctx_done(fctx, result, __LINE__);
+ else {
+ LOCK(&fctx->res->buckets[fctx->bucketnum].lock);
+ fctx->references++;
+ UNLOCK(&fctx->res->buckets[fctx->bucketnum].lock);
+ result = fctx_stopidletimer(fctx);
+ if (result != ISC_R_SUCCESS)
+ fctx_done(fctx, result, __LINE__);
+ }
} else {
/*
* We're done.
@@ -7602,7 +7629,7 @@ dns_resolver_destroyfetch(dns_fetch_t **fetchp) {
dns_fetchevent_t *event, *next_event;
fetchctx_t *fctx;
unsigned int bucketnum;
- isc_boolean_t bucket_empty = ISC_FALSE;
+ isc_boolean_t bucket_empty;
REQUIRE(fetchp != NULL);
fetch = *fetchp;
@@ -7630,27 +7657,7 @@ dns_resolver_destroyfetch(dns_fetch_t **fetchp) {
}
}
- INSIST(fctx->references > 0);
- fctx->references--;
- if (fctx->references == 0) {
- /*
- * No one cares about the result of this fetch anymore.
- */
- if (fctx->pending == 0 && fctx->nqueries == 0 &&
- ISC_LIST_EMPTY(fctx->validators) &&
- SHUTTINGDOWN(fctx)) {
- /*
- * This fctx is already shutdown; we were just
- * waiting for the last reference to go away.
- */
- bucket_empty = fctx_destroy(fctx);
- } else {
- /*
- * Initiate shutdown.
- */
- fctx_shutdown(fctx);
- }
- }
+ bucket_empty = fctx_decreference(fctx);
UNLOCK(&res->buckets[bucketnum].lock);
OpenPOWER on IntegriCloud