* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: resolver.c,v 1.413.14.8.6.1 2010/06/29 04:49:49 marka Exp $ */
+/* $Id: resolver.c,v 1.413.14.11 2010/07/11 00:12:18 each Exp $ */
/*! \file */
* trying other servers.
*/
if (dns_name_equal(ns_name, &fctx->domain)) {
- log_formerr(fctx, "non-improving referral");
+ log_formerr(fctx, "sideways referral");
return (DNS_R_FORMERR);
}
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;
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);
return (result == ISC_R_SUCCESS ? ISC_TRUE : ISC_FALSE);
}
-#ifdef notyet_betterreferral
-static isc_boolean_t
-betterreferral(fetchctx_t *fctx) {
- isc_result_t result;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- dns_message_t *message = fctx->rmessage;
-
- for (result = dns_message_firstname(message, DNS_SECTION_AUTHORITY);
- result == ISC_R_SUCCESS;
- result = dns_message_nextname(message, DNS_SECTION_AUTHORITY)) {
- name = NULL;
- dns_message_currentname(message, DNS_SECTION_AUTHORITY, &name);
- if (!dns_name_issubdomain(name, &fctx->domain))
- continue;
- for (rdataset = ISC_LIST_HEAD(name->list);
- rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- if (rdataset->type == dns_rdatatype_ns)
- return (ISC_TRUE);
- }
- return (ISC_FALSE);
-}
-#endif
-
static void
resquery_response(isc_task_t *task, isc_event_t *event) {
isc_result_t result = ISC_R_SUCCESS;
* it as a valid answer.
*/
result = answer_response(fctx);
-#ifdef notyet_betterreferral
- } else if (fctx->type != dns_rdatatype_ns &&
- !betterreferral(fctx)) {
-#else
- } else if (fctx->type != dns_rdatatype_ns) {
-#endif
- /*
- * Lame response !!!.
- */
- result = answer_response(fctx);
} else {
-#ifdef notyet_betterreferral
if (fctx->type == dns_rdatatype_ns) {
-#endif
/*
* A BIND 8 server could incorrectly return a
* non-authoritative answer to an NS query
*/
result = noanswer_response(fctx, NULL,
LOOK_FOR_NS_IN_ANSWER);
-#ifdef notyet_betterreferral
} else {
/*
* Some other servers may still somehow include
result = noanswer_response(fctx, NULL,
LOOK_FOR_GLUE_IN_ANSWER);
}
-#endif
if (result != DNS_R_DELEGATION) {
/*
* At this point, AA is not set, the response
&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.
void
dns_resolver_freeze(dns_resolver_t *res) {
-
/*
* Freeze resolver.
*/
REQUIRE(VALID_RESOLVER(res));
- REQUIRE(!res->frozen);
res->frozen = ISC_TRUE;
}
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;
}
}
- 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);