4317. [bug] Age all unused servers on fetch timeout. [RT #41597]

(cherry picked from commit d372f426ca)
This commit is contained in:
Mark Andrews 2016-02-12 12:32:58 +11:00
parent 653c466529
commit 8a550860b8
2 changed files with 37 additions and 25 deletions

View file

@ -1,3 +1,5 @@
4317. [bug] Age all unused servers on fetch timeout. [RT #41597]
4315. [bug] Check that configured view class isn't a meta class.
[RT #41572].

View file

@ -866,7 +866,8 @@ resquery_destroy(resquery_t **queryp) {
static void
fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
isc_time_t *finish, isc_boolean_t no_response)
isc_time_t *finish, isc_boolean_t no_response,
isc_boolean_t age_untried)
{
fetchctx_t *fctx;
resquery_t *query;
@ -948,14 +949,14 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
* Age RTTs of servers not tried.
*/
isc_stdtime_get(&now);
if (finish != NULL)
if (finish != NULL || age_untried)
for (addrinfo = ISC_LIST_HEAD(fctx->forwaddrs);
addrinfo != NULL;
addrinfo = ISC_LIST_NEXT(addrinfo, publink))
if (UNMARKED(addrinfo))
dns_adb_agesrtt(fctx->adb, addrinfo, now);
if (finish != NULL && TRIEDFIND(fctx))
if ((finish != NULL || age_untried) && TRIEDFIND(fctx))
for (find = ISC_LIST_HEAD(fctx->finds);
find != NULL;
find = ISC_LIST_NEXT(find, publink))
@ -966,7 +967,7 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
dns_adb_agesrtt(fctx->adb, addrinfo,
now);
if (finish != NULL && TRIEDALT(fctx)) {
if ((finish != NULL || age_untried) && TRIEDALT(fctx)) {
for (addrinfo = ISC_LIST_HEAD(fctx->altaddrs);
addrinfo != NULL;
addrinfo = ISC_LIST_NEXT(addrinfo, publink))
@ -1037,7 +1038,9 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
}
static void
fctx_cancelqueries(fetchctx_t *fctx, isc_boolean_t no_response) {
fctx_cancelqueries(fetchctx_t *fctx, isc_boolean_t no_response,
isc_boolean_t age_untried)
{
resquery_t *query, *next_query;
FCTXTRACE("cancelqueries");
@ -1046,7 +1049,8 @@ fctx_cancelqueries(fetchctx_t *fctx, isc_boolean_t no_response) {
query != NULL;
query = next_query) {
next_query = ISC_LIST_NEXT(query, link);
fctx_cancelquery(&query, NULL, NULL, no_response);
fctx_cancelquery(&query, NULL, NULL, no_response,
age_untried);
}
}
@ -1113,9 +1117,11 @@ fctx_cleanupaltaddrs(fetchctx_t *fctx) {
}
static inline void
fctx_stopeverything(fetchctx_t *fctx, isc_boolean_t no_response) {
fctx_stopeverything(fetchctx_t *fctx, isc_boolean_t no_response,
isc_boolean_t age_untried)
{
FCTXTRACE("stopeverything");
fctx_cancelqueries(fctx, no_response);
fctx_cancelqueries(fctx, no_response, age_untried);
fctx_cleanupfinds(fctx);
fctx_cleanupaltfinds(fctx);
fctx_cleanupforwaddrs(fctx);
@ -1354,7 +1360,8 @@ log_edns(fetchctx_t *fctx) {
static void
fctx_done(fetchctx_t *fctx, isc_result_t result, int line) {
dns_resolver_t *res;
isc_boolean_t no_response;
isc_boolean_t no_response = ISC_FALSE;
isc_boolean_t age_untried = ISC_FALSE;
REQUIRE(line >= 0);
@ -1368,11 +1375,11 @@ fctx_done(fetchctx_t *fctx, isc_result_t result, int line) {
*/
log_edns(fctx);
no_response = ISC_TRUE;
} else
no_response = ISC_FALSE;
} else if (result == ISC_R_TIMEDOUT)
age_untried = ISC_TRUE;
fctx->reason = NULL;
fctx_stopeverything(fctx, no_response);
fctx_stopeverything(fctx, no_response, age_untried);
LOCK(&res->buckets[fctx->bucketnum].lock);
@ -1422,7 +1429,8 @@ process_sendevent(resquery_t *query, isc_event_t *event) {
*/
add_bad(fctx, query->addrinfo, sevent->result,
badns_unreachable);
fctx_cancelquery(&query, NULL, NULL, ISC_TRUE);
fctx_cancelquery(&query, NULL, NULL, ISC_TRUE,
ISC_FALSE);
retry = ISC_TRUE;
break;
@ -1431,7 +1439,8 @@ process_sendevent(resquery_t *query, isc_event_t *event) {
"unexpected event result; responding",
sevent->result);
fctx_cancelquery(&query, NULL, NULL, ISC_FALSE);
fctx_cancelquery(&query, NULL, NULL, ISC_FALSE,
ISC_FALSE);
break;
}
}
@ -2327,7 +2336,8 @@ resquery_connected(isc_task_t *task, isc_event_t *event) {
FCTXTRACE("query canceled: idle timer failed; "
"responding");
fctx_cancelquery(&query, NULL, NULL, ISC_FALSE);
fctx_cancelquery(&query, NULL, NULL, ISC_FALSE,
ISC_FALSE);
fctx_done(fctx, result, __LINE__);
break;
}
@ -2366,7 +2376,7 @@ resquery_connected(isc_task_t *task, isc_event_t *event) {
FCTXTRACE("query canceled: "
"resquery_send() failed; responding");
fctx_cancelquery(&query, NULL, NULL, ISC_FALSE);
fctx_cancelquery(&query, NULL, NULL, ISC_FALSE, ISC_FALSE);
fctx_done(fctx, result, __LINE__);
}
break;
@ -2385,7 +2395,7 @@ resquery_connected(isc_task_t *task, isc_event_t *event) {
* No route to remote.
*/
isc_socket_detach(&query->tcpsocket);
fctx_cancelquery(&query, NULL, NULL, ISC_TRUE);
fctx_cancelquery(&query, NULL, NULL, ISC_TRUE, ISC_FALSE);
retry = ISC_TRUE;
break;
@ -2395,7 +2405,7 @@ resquery_connected(isc_task_t *task, isc_event_t *event) {
sevent->result);
isc_socket_detach(&query->tcpsocket);
fctx_cancelquery(&query, NULL, NULL, ISC_FALSE);
fctx_cancelquery(&query, NULL, NULL, ISC_FALSE, ISC_FALSE);
break;
}
}
@ -3374,7 +3384,7 @@ fctx_try(fetchctx_t *fctx, isc_boolean_t retrying, isc_boolean_t badcache) {
if (addrinfo == NULL) {
/* We have no more addresses. Start over. */
fctx_cancelqueries(fctx, ISC_TRUE);
fctx_cancelqueries(fctx, ISC_TRUE, ISC_FALSE);
fctx_cleanupfinds(fctx);
fctx_cleanupaltfinds(fctx);
fctx_cleanupforwaddrs(fctx);
@ -3592,7 +3602,7 @@ fctx_timeout(isc_task_t *task, isc_event_t *event) {
isc_time_compare(&tevent->due, &query->start) >= 0)
{
FCTXTRACE("query timed out; no response");
fctx_cancelquery(&query, NULL, NULL, ISC_TRUE);
fctx_cancelquery(&query, NULL, NULL, ISC_TRUE, ISC_FALSE);
}
fctx->attributes &= ~FCTX_ATTR_ADDRWAIT;
@ -3686,7 +3696,7 @@ fctx_doshutdown(isc_task_t *task, isc_event_t *event) {
* fetch. To avoid deadlock with the ADB, we must do this
* before we lock the bucket lock.
*/
fctx_stopeverything(fctx, ISC_FALSE);
fctx_stopeverything(fctx, ISC_FALSE, ISC_FALSE);
LOCK(&res->buckets[bucketnum].lock);
@ -7952,7 +7962,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
*
* XXXRTH Don't cancel the query if waiting for validation?
*/
fctx_cancelquery(&query, &devent, finish, no_response);
fctx_cancelquery(&query, &devent, finish, no_response, ISC_FALSE);
if (keep_trying) {
if (result == DNS_R_FORMERR)
@ -8023,7 +8033,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
fctx->ns_ttl = fctx->nameservers.ttl;
fctx->ns_ttl_ok = ISC_TRUE;
fctx_cancelqueries(fctx, ISC_TRUE);
fctx_cancelqueries(fctx, ISC_TRUE, ISC_FALSE);
fctx_cleanupfinds(fctx);
fctx_cleanupaltfinds(fctx);
fctx_cleanupforwaddrs(fctx);
@ -8056,7 +8066,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
* DNSSEC validator to validate the answer.
*/
FCTXTRACE("wait for validator");
fctx_cancelqueries(fctx, ISC_TRUE);
fctx_cancelqueries(fctx, ISC_TRUE, ISC_FALSE);
/*
* We must not retransmit while the validator is working;
* it has references to the current rmessage.
@ -8067,7 +8077,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
} else if (result == DNS_R_CHASEDSSERVERS) {
unsigned int n;
add_bad(fctx, addrinfo, result, broken_type);
fctx_cancelqueries(fctx, ISC_TRUE);
fctx_cancelqueries(fctx, ISC_TRUE, ISC_FALSE);
fctx_cleanupfinds(fctx);
fctx_cleanupforwaddrs(fctx);