mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
checkpoint
This commit is contained in:
@@ -123,7 +123,7 @@ struct fetchctx {
|
|||||||
unsigned int bucketnum;
|
unsigned int bucketnum;
|
||||||
/* Locked by lock. */
|
/* Locked by lock. */
|
||||||
fetchstate state;
|
fetchstate state;
|
||||||
isc_boolean_t exiting;
|
isc_boolean_t want_shutdown;
|
||||||
unsigned int references;
|
unsigned int references;
|
||||||
isc_event_t control_event;
|
isc_event_t control_event;
|
||||||
ISC_LINK(struct fetchctx) link;
|
ISC_LINK(struct fetchctx) link;
|
||||||
@@ -138,8 +138,9 @@ struct fetchctx {
|
|||||||
dns_message_t * qmessage;
|
dns_message_t * qmessage;
|
||||||
dns_message_t * rmessage;
|
dns_message_t * rmessage;
|
||||||
ISC_LIST(resquery_t) queries;
|
ISC_LIST(resquery_t) queries;
|
||||||
ISC_LIST(dns_adbhandle_t) lookups;
|
ISC_LIST(dns_adbfind_t) finds;
|
||||||
dns_adbhandle_t * lookup;
|
dns_adbfind_t * find;
|
||||||
|
unsigned int pending;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FCTX_MAGIC 0x46212121U /* F!!! */
|
#define FCTX_MAGIC 0x46212121U /* F!!! */
|
||||||
@@ -149,6 +150,7 @@ struct fetchctx {
|
|||||||
#define FCTX_ATTR_HAVEANSWER 0x01
|
#define FCTX_ATTR_HAVEANSWER 0x01
|
||||||
#define FCTX_ATTR_GLUING 0x02
|
#define FCTX_ATTR_GLUING 0x02
|
||||||
#define FCTX_ATTR_ADDRWAIT 0x04
|
#define FCTX_ATTR_ADDRWAIT 0x04
|
||||||
|
#define FCTX_ATTR_SHUTTINGDOWN 0x08
|
||||||
|
|
||||||
#define HAVE_ANSWER(f) (((f)->attributes & FCTX_ATTR_HAVEANSWER) != \
|
#define HAVE_ANSWER(f) (((f)->attributes & FCTX_ATTR_HAVEANSWER) != \
|
||||||
0)
|
0)
|
||||||
@@ -156,6 +158,8 @@ struct fetchctx {
|
|||||||
0)
|
0)
|
||||||
#define ADDRWAIT(f) (((f)->attributes & FCTX_ATTR_ADDRWAIT) != \
|
#define ADDRWAIT(f) (((f)->attributes & FCTX_ATTR_ADDRWAIT) != \
|
||||||
0)
|
0)
|
||||||
|
#define SHUTTINGDOWN(f) (((f)->attributes & FCTX_ATTR_SHUTTINGDOWN) \
|
||||||
|
!= 0)
|
||||||
|
|
||||||
struct dns_fetch {
|
struct dns_fetch {
|
||||||
unsigned int magic;
|
unsigned int magic;
|
||||||
@@ -203,7 +207,7 @@ static void destroy(dns_resolver_t *res);
|
|||||||
static void empty_bucket(dns_resolver_t *res);
|
static void empty_bucket(dns_resolver_t *res);
|
||||||
static void resquery_response(isc_task_t *task, isc_event_t *event);
|
static void resquery_response(isc_task_t *task, isc_event_t *event);
|
||||||
static void fctx_try(fetchctx_t *fctx);
|
static void fctx_try(fetchctx_t *fctx);
|
||||||
|
static isc_boolean_t fctx_destroy(fetchctx_t *fctx);
|
||||||
|
|
||||||
static inline isc_result_t
|
static inline isc_result_t
|
||||||
fctx_starttimer(fetchctx_t *fctx) {
|
fctx_starttimer(fetchctx_t *fctx) {
|
||||||
@@ -274,36 +278,38 @@ fctx_cancelqueries(fetchctx_t *fctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fctx_freelookups(fetchctx_t *fctx) {
|
fctx_cleanupfinds(fetchctx_t *fctx) {
|
||||||
dns_adbhandle_t *lookup, *next_lookup;
|
dns_adbfind_t *find, *next_find;
|
||||||
|
|
||||||
for (lookup = ISC_LIST_HEAD(fctx->lookups);
|
for (find = ISC_LIST_HEAD(fctx->finds);
|
||||||
lookup != NULL;
|
find != NULL;
|
||||||
lookup = next_lookup) {
|
find = next_find) {
|
||||||
next_lookup = ISC_LIST_NEXT(lookup, publink);
|
next_find = ISC_LIST_NEXT(find, publink);
|
||||||
ISC_LIST_UNLINK(fctx->lookups, lookup, publink);
|
ISC_LIST_UNLINK(fctx->finds, find, publink);
|
||||||
dns_adb_destroyfind(&lookup);
|
dns_adb_destroyfind(&find);
|
||||||
}
|
}
|
||||||
fctx->lookup = NULL;
|
fctx->find = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
fctx_done(fetchctx_t *fctx, isc_result_t result) {
|
fctx_stopeverything(fetchctx_t *fctx) {
|
||||||
dns_fetchevent_t *event, *next_event;
|
FCTXTRACE("stopeverything");
|
||||||
isc_task_t *task;
|
fctx_cleanupfinds(fctx);
|
||||||
dns_resolver_t *res;
|
|
||||||
|
|
||||||
FCTXTRACE("done");
|
|
||||||
|
|
||||||
res = fctx->res;
|
|
||||||
|
|
||||||
fctx_freelookups(fctx);
|
|
||||||
fctx_cancelqueries(fctx);
|
fctx_cancelqueries(fctx);
|
||||||
fctx_stoptimer(fctx);
|
fctx_stoptimer(fctx);
|
||||||
|
}
|
||||||
|
|
||||||
LOCK(&res->buckets[fctx->bucketnum].lock);
|
static inline void
|
||||||
|
fctx_sendevents(fetchctx_t *fctx, isc_result_t result) {
|
||||||
|
dns_fetchevent_t *event, *next_event;
|
||||||
|
isc_task_t *task;
|
||||||
|
|
||||||
fctx->state = fetchstate_done;
|
/*
|
||||||
|
* Caller must be holding the appropriate bucket lock.
|
||||||
|
*/
|
||||||
|
REQUIRE(fctx->state == fetchstate_done);
|
||||||
|
|
||||||
|
FCTXTRACE("sendevents");
|
||||||
|
|
||||||
for (event = ISC_LIST_HEAD(fctx->events);
|
for (event = ISC_LIST_HEAD(fctx->events);
|
||||||
event != NULL;
|
event != NULL;
|
||||||
@@ -316,10 +322,22 @@ fctx_done(fetchctx_t *fctx, isc_result_t result) {
|
|||||||
isc_task_sendanddetach(&task, (isc_event_t **)&event);
|
isc_task_sendanddetach(&task, (isc_event_t **)&event);
|
||||||
}
|
}
|
||||||
ISC_LIST_INIT(fctx->events);
|
ISC_LIST_INIT(fctx->events);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
static void
|
||||||
* XXXRTH check for finished state.
|
fctx_done(fetchctx_t *fctx, isc_result_t result) {
|
||||||
*/
|
dns_resolver_t *res;
|
||||||
|
|
||||||
|
FCTXTRACE("done");
|
||||||
|
|
||||||
|
res = fctx->res;
|
||||||
|
|
||||||
|
fctx_stopeverything(fctx);
|
||||||
|
|
||||||
|
LOCK(&res->buckets[fctx->bucketnum].lock);
|
||||||
|
|
||||||
|
fctx->state = fetchstate_done;
|
||||||
|
fctx_sendevents(fctx, result);
|
||||||
|
|
||||||
UNLOCK(&res->buckets[fctx->bucketnum].lock);
|
UNLOCK(&res->buckets[fctx->bucketnum].lock);
|
||||||
}
|
}
|
||||||
@@ -535,32 +553,59 @@ fctx_sendquery(fetchctx_t *fctx, isc_sockaddr_t *address) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fctx_adbhandler(isc_task_t *task, isc_event_t *event) {
|
fctx_finddone(isc_task_t *task, isc_event_t *event) {
|
||||||
fetchctx_t *fctx;
|
fetchctx_t *fctx;
|
||||||
|
dns_adbfind_t *find;
|
||||||
|
dns_resolver_t *res;
|
||||||
isc_boolean_t want_try = ISC_FALSE;
|
isc_boolean_t want_try = ISC_FALSE;
|
||||||
isc_boolean_t want_done = ISC_FALSE;
|
isc_boolean_t want_done = ISC_FALSE;
|
||||||
|
isc_boolean_t bucket_empty = ISC_FALSE;
|
||||||
|
unsigned int bucketnum;
|
||||||
|
|
||||||
|
find = event->sender;
|
||||||
fctx = event->arg;
|
fctx = event->arg;
|
||||||
REQUIRE(VALID_FCTX(fctx));
|
REQUIRE(VALID_FCTX(fctx));
|
||||||
|
res = fctx->res;
|
||||||
|
|
||||||
(void)task;
|
(void)task;
|
||||||
|
|
||||||
FCTXTRACE("adbhandler");
|
FCTXTRACE("finddone");
|
||||||
|
|
||||||
|
INSIST(fctx->pending > 0);
|
||||||
|
fctx->pending--;
|
||||||
|
|
||||||
if (ADDRWAIT(fctx)) {
|
if (ADDRWAIT(fctx)) {
|
||||||
|
/*
|
||||||
|
* The fetch is waiting for a name to be found.
|
||||||
|
*/
|
||||||
fctx->attributes &= ~FCTX_ATTR_ADDRWAIT;
|
fctx->attributes &= ~FCTX_ATTR_ADDRWAIT;
|
||||||
if (event->type == DNS_EVENT_ADBMOREADDRESSES)
|
if (event->type == DNS_EVENT_ADBMOREADDRESSES)
|
||||||
want_try = ISC_TRUE;
|
want_try = ISC_TRUE;
|
||||||
else
|
else if (fctx->pending == 0) {
|
||||||
|
/*
|
||||||
|
* We've got nothing else to wait for and don't
|
||||||
|
* know the answer. There's nothing to do but
|
||||||
|
* fail the fctx.
|
||||||
|
*/
|
||||||
want_done = ISC_TRUE;
|
want_done = ISC_TRUE;
|
||||||
|
}
|
||||||
|
} else if (fctx->pending == 0 && fctx->references == 0 &&
|
||||||
|
SHUTTINGDOWN(fctx)) {
|
||||||
|
bucketnum = fctx->bucketnum;
|
||||||
|
LOCK(&res->buckets[bucketnum].lock);
|
||||||
|
bucket_empty = fctx_destroy(fctx);
|
||||||
|
UNLOCK(&res->buckets[bucketnum].lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_event_free(&event);
|
isc_event_free(&event);
|
||||||
|
dns_adb_destroyfind(&find);
|
||||||
|
|
||||||
if (want_try)
|
if (want_try)
|
||||||
fctx_try(fctx);
|
fctx_try(fctx);
|
||||||
else if (want_done)
|
else if (want_done)
|
||||||
fctx_done(fctx, ISC_R_NOTFOUND);
|
fctx_done(fctx, ISC_R_FAILURE);
|
||||||
|
else if (bucket_empty)
|
||||||
|
empty_bucket(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
@@ -571,20 +616,19 @@ fctx_getaddresses(fetchctx_t *fctx) {
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_resolver_t *res;
|
dns_resolver_t *res;
|
||||||
isc_stdtime_t now;
|
isc_stdtime_t now;
|
||||||
dns_adbhandle_t *lookup;
|
dns_adbfind_t *find;
|
||||||
isc_boolean_t found_something;
|
|
||||||
unsigned int options;
|
unsigned int options;
|
||||||
|
|
||||||
FCTXTRACE("getaddresses");
|
FCTXTRACE("getaddresses");
|
||||||
|
|
||||||
found_something = ISC_FALSE;
|
options = DNS_ADBFIND_WANTEVENT|DNS_ADBFIND_EMPTYEVENT;
|
||||||
options = DNS_ADBFIND_WANTEVENT|DNS_ADBFIND_INET;
|
options |= DNS_ADBFIND_INET;
|
||||||
res = fctx->res;
|
res = fctx->res;
|
||||||
result = isc_stdtime_get(&now);
|
result = isc_stdtime_get(&now);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
return (result);
|
return (result);
|
||||||
|
|
||||||
fctx_freelookups(fctx);
|
fctx_cleanupfinds(fctx);
|
||||||
|
|
||||||
result = dns_rdataset_first(&fctx->nameservers);
|
result = dns_rdataset_first(&fctx->nameservers);
|
||||||
while (result == ISC_R_SUCCESS) {
|
while (result == ISC_R_SUCCESS) {
|
||||||
@@ -603,55 +647,60 @@ fctx_getaddresses(fetchctx_t *fctx) {
|
|||||||
/*
|
/*
|
||||||
* See what we know about this address.
|
* See what we know about this address.
|
||||||
*/
|
*/
|
||||||
lookup = NULL;
|
find = NULL;
|
||||||
result = dns_adb_createfind(res->view->adb,
|
result = dns_adb_createfind(res->view->adb,
|
||||||
res->buckets[fctx->bucketnum].task,
|
res->buckets[fctx->bucketnum].task,
|
||||||
fctx_adbhandler, fctx, &name,
|
fctx_finddone, fctx, &name,
|
||||||
&fctx->domain, options, now,
|
&fctx->domain, options, now,
|
||||||
&lookup);
|
&find);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
return (result);
|
return (result);
|
||||||
if (!ISC_LIST_EMPTY(lookup->list)) {
|
if (!ISC_LIST_EMPTY(find->list)) {
|
||||||
/*
|
/*
|
||||||
* We have at least some of the addresses for the
|
* We have at least some of the addresses for the
|
||||||
* name.
|
* name.
|
||||||
*/
|
*/
|
||||||
found_something = ISC_TRUE;
|
INSIST((find->options & DNS_ADBFIND_WANTEVENT) == 0);
|
||||||
/*
|
/*
|
||||||
* XXXRTH Sort.
|
* XXXRTH Sort.
|
||||||
*/
|
*/
|
||||||
|
ISC_LIST_APPEND(fctx->finds, find, publink);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* We don't know any of the addresses for this
|
* We don't know any of the addresses for this
|
||||||
* name.
|
* name.
|
||||||
*/
|
*/
|
||||||
if (lookup->query_pending == 0) {
|
if ((find->options & DNS_ADBFIND_WANTEVENT) != 0) {
|
||||||
/*
|
/*
|
||||||
* We're not fetching them either. We lose
|
* We're looking for them and will get an
|
||||||
* for this name.
|
* event about it later.
|
||||||
*/
|
*/
|
||||||
dns_adb_destroyfind(&lookup);
|
fctx->pending++;
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* And ADB isn't going to send us any events
|
||||||
|
* either. This query loses.
|
||||||
|
*/
|
||||||
|
dns_adb_destroyfind(&find);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lookup != NULL)
|
|
||||||
ISC_LIST_APPEND(fctx->lookups, lookup, publink);
|
|
||||||
result = dns_rdataset_next(&fctx->nameservers);
|
result = dns_rdataset_next(&fctx->nameservers);
|
||||||
}
|
}
|
||||||
if (result != DNS_R_NOMORE)
|
if (result != DNS_R_NOMORE)
|
||||||
return (result);
|
return (result);
|
||||||
|
|
||||||
if (ISC_LIST_EMPTY(fctx->lookups)) {
|
if (ISC_LIST_EMPTY(fctx->finds) && fctx->pending > 0) {
|
||||||
/*
|
|
||||||
* We've lost completely. We don't know any addresses, and
|
|
||||||
* the ADB has told us it can't get them.
|
|
||||||
*/
|
|
||||||
result = ISC_R_NOTFOUND;
|
|
||||||
} else if (!found_something) {
|
|
||||||
/*
|
/*
|
||||||
* We're fetching the addresses, but don't have any yet.
|
* We're fetching the addresses, but don't have any yet.
|
||||||
* Tell the caller to wait for an answer.
|
* Tell the caller to wait for an answer.
|
||||||
*/
|
*/
|
||||||
result = DNS_R_WAIT;
|
result = DNS_R_WAIT;
|
||||||
|
} else if (ISC_LIST_EMPTY(fctx->finds)) {
|
||||||
|
/*
|
||||||
|
* We've lost completely. We don't know any addresses, and
|
||||||
|
* the ADB has told us it can't get them.
|
||||||
|
*/
|
||||||
|
result = ISC_R_FAILURE;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* We've found some addresses. We might still be looking
|
* We've found some addresses. We might still be looking
|
||||||
@@ -674,7 +723,7 @@ fctx_getaddresses(fetchctx_t *fctx) {
|
|||||||
|
|
||||||
static inline dns_adbaddrinfo_t *
|
static inline dns_adbaddrinfo_t *
|
||||||
fctx_nextaddress(fetchctx_t *fctx) {
|
fctx_nextaddress(fetchctx_t *fctx) {
|
||||||
dns_adbhandle_t *lookup;
|
dns_adbfind_t *find;
|
||||||
dns_adbaddrinfo_t *addrinfo;
|
dns_adbaddrinfo_t *addrinfo;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@@ -683,25 +732,25 @@ fctx_nextaddress(fetchctx_t *fctx) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move to the next lookup.
|
* Move to the next find.
|
||||||
*/
|
*/
|
||||||
lookup = fctx->lookup;
|
find = fctx->find;
|
||||||
if (lookup == NULL)
|
if (find == NULL)
|
||||||
lookup = ISC_LIST_HEAD(fctx->lookups);
|
find = ISC_LIST_HEAD(fctx->finds);
|
||||||
else {
|
else {
|
||||||
lookup = ISC_LIST_NEXT(lookup, publink);
|
find = ISC_LIST_NEXT(find, publink);
|
||||||
if (lookup == NULL)
|
if (find == NULL)
|
||||||
lookup = ISC_LIST_HEAD(fctx->lookups);
|
find = ISC_LIST_HEAD(fctx->finds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the first unmarked addrinfo.
|
* Find the first unmarked addrinfo.
|
||||||
*/
|
*/
|
||||||
addrinfo = NULL;
|
addrinfo = NULL;
|
||||||
while (lookup != fctx->lookup) {
|
while (find != fctx->find) {
|
||||||
count++;
|
count++;
|
||||||
INSIST(count < 1000);
|
INSIST(count < 1000);
|
||||||
for (addrinfo = ISC_LIST_HEAD(lookup->list);
|
for (addrinfo = ISC_LIST_HEAD(find->list);
|
||||||
addrinfo != NULL;
|
addrinfo != NULL;
|
||||||
addrinfo = ISC_LIST_NEXT(addrinfo, publink)) {
|
addrinfo = ISC_LIST_NEXT(addrinfo, publink)) {
|
||||||
if (UNMARKED(addrinfo)) {
|
if (UNMARKED(addrinfo)) {
|
||||||
@@ -711,12 +760,12 @@ fctx_nextaddress(fetchctx_t *fctx) {
|
|||||||
}
|
}
|
||||||
if (addrinfo != NULL)
|
if (addrinfo != NULL)
|
||||||
break;
|
break;
|
||||||
lookup = ISC_LIST_NEXT(lookup, publink);
|
find = ISC_LIST_NEXT(find, publink);
|
||||||
if (lookup != fctx->lookup && lookup == NULL)
|
if (find != fctx->find && find == NULL)
|
||||||
lookup = ISC_LIST_HEAD(fctx->lookups);
|
find = ISC_LIST_HEAD(fctx->finds);
|
||||||
}
|
}
|
||||||
|
|
||||||
fctx->lookup = lookup;
|
fctx->find = find;
|
||||||
|
|
||||||
return (addrinfo);
|
return (addrinfo);
|
||||||
}
|
}
|
||||||
@@ -759,7 +808,7 @@ fctx_try(fetchctx_t *fctx) {
|
|||||||
addrinfo = fctx_nextaddress(fctx);
|
addrinfo = fctx_nextaddress(fctx);
|
||||||
/*
|
/*
|
||||||
* fctx_getaddresses() returned success, so at least one
|
* fctx_getaddresses() returned success, so at least one
|
||||||
* of the lookup lists should be nonempty.
|
* of the find lists should be nonempty.
|
||||||
*/
|
*/
|
||||||
INSIST(addrinfo != NULL);
|
INSIST(addrinfo != NULL);
|
||||||
}
|
}
|
||||||
@@ -788,7 +837,8 @@ fctx_destroy(fetchctx_t *fctx) {
|
|||||||
REQUIRE(fctx->state == fetchstate_done);
|
REQUIRE(fctx->state == fetchstate_done);
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->events));
|
REQUIRE(ISC_LIST_EMPTY(fctx->events));
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->queries));
|
REQUIRE(ISC_LIST_EMPTY(fctx->queries));
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->lookups));
|
REQUIRE(ISC_LIST_EMPTY(fctx->finds));
|
||||||
|
REQUIRE(fctx->pending == 0);
|
||||||
|
|
||||||
FCTXTRACE("destroy");
|
FCTXTRACE("destroy");
|
||||||
|
|
||||||
@@ -845,7 +895,7 @@ fctx_timeout(isc_task_t *task, isc_event_t *event) {
|
|||||||
static void
|
static void
|
||||||
fctx_shutdown(isc_task_t *task, isc_event_t *event) {
|
fctx_shutdown(isc_task_t *task, isc_event_t *event) {
|
||||||
fetchctx_t *fctx = event->arg;
|
fetchctx_t *fctx = event->arg;
|
||||||
isc_boolean_t need_done = ISC_FALSE, bucket_empty = ISC_FALSE;
|
isc_boolean_t bucket_empty = ISC_FALSE;
|
||||||
dns_resolver_t *res;
|
dns_resolver_t *res;
|
||||||
unsigned int bucketnum;
|
unsigned int bucketnum;
|
||||||
|
|
||||||
@@ -857,23 +907,26 @@ fctx_shutdown(isc_task_t *task, isc_event_t *event) {
|
|||||||
|
|
||||||
FCTXTRACE("shutdown");
|
FCTXTRACE("shutdown");
|
||||||
|
|
||||||
|
fctx->attributes |= FCTX_ATTR_SHUTTINGDOWN;
|
||||||
|
|
||||||
LOCK(&res->buckets[bucketnum].lock);
|
LOCK(&res->buckets[bucketnum].lock);
|
||||||
|
|
||||||
INSIST(fctx->state == fetchstate_active ||
|
INSIST(fctx->state == fetchstate_active ||
|
||||||
fctx->state == fetchstate_done);
|
fctx->state == fetchstate_done);
|
||||||
INSIST(fctx->exiting);
|
INSIST(fctx->want_shutdown);
|
||||||
|
|
||||||
if (fctx->state == fetchstate_done) {
|
if (fctx->state != fetchstate_done) {
|
||||||
if (fctx->references == 0)
|
fctx_stopeverything(fctx);
|
||||||
bucket_empty = fctx_destroy(fctx);
|
fctx->state = fetchstate_done;
|
||||||
} else
|
fctx_sendevents(fctx, ISC_R_CANCELED);
|
||||||
need_done = ISC_TRUE;
|
}
|
||||||
|
|
||||||
|
if (fctx->references == 0 && fctx->pending == 0)
|
||||||
|
bucket_empty = fctx_destroy(fctx);
|
||||||
|
|
||||||
UNLOCK(&res->buckets[bucketnum].lock);
|
UNLOCK(&res->buckets[bucketnum].lock);
|
||||||
|
|
||||||
if (need_done)
|
if (bucket_empty)
|
||||||
fctx_done(fctx, ISC_R_CANCELED);
|
|
||||||
else if (bucket_empty)
|
|
||||||
empty_bucket(res);
|
empty_bucket(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -895,7 +948,7 @@ fctx_start(isc_task_t *task, isc_event_t *event) {
|
|||||||
LOCK(&res->buckets[bucketnum].lock);
|
LOCK(&res->buckets[bucketnum].lock);
|
||||||
|
|
||||||
INSIST(fctx->state == fetchstate_init);
|
INSIST(fctx->state == fetchstate_init);
|
||||||
if (fctx->exiting) {
|
if (fctx->want_shutdown) {
|
||||||
/*
|
/*
|
||||||
* We haven't started this fctx yet, and we've been requested
|
* We haven't started this fctx yet, and we've been requested
|
||||||
* to shut it down.
|
* to shut it down.
|
||||||
@@ -1017,10 +1070,11 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
|
|||||||
fctx->references = 0;
|
fctx->references = 0;
|
||||||
fctx->bucketnum = bucketnum;
|
fctx->bucketnum = bucketnum;
|
||||||
fctx->state = fetchstate_init;
|
fctx->state = fetchstate_init;
|
||||||
fctx->exiting = ISC_FALSE;
|
fctx->want_shutdown = ISC_FALSE;
|
||||||
ISC_LIST_INIT(fctx->queries);
|
ISC_LIST_INIT(fctx->queries);
|
||||||
ISC_LIST_INIT(fctx->lookups);
|
ISC_LIST_INIT(fctx->finds);
|
||||||
fctx->lookup = NULL;
|
fctx->find = NULL;
|
||||||
|
fctx->pending = 0;
|
||||||
fctx->attributes = 0;
|
fctx->attributes = 0;
|
||||||
|
|
||||||
fctx->qmessage = NULL;
|
fctx->qmessage = NULL;
|
||||||
@@ -1494,7 +1548,7 @@ mark_related(dns_name_t *name, dns_rdataset_t *rdataset,
|
|||||||
rdataset->attributes |= DNS_RDATASETATTR_CACHE;
|
rdataset->attributes |= DNS_RDATASETATTR_CACHE;
|
||||||
if (external)
|
if (external)
|
||||||
rdataset->attributes |= DNS_RDATASETATTR_EXTERNAL;
|
rdataset->attributes |= DNS_RDATASETATTR_EXTERNAL;
|
||||||
#if 0
|
#if 1
|
||||||
/*
|
/*
|
||||||
* XXXRTH TEMPORARY FOR TESTING!!!
|
* XXXRTH TEMPORARY FOR TESTING!!!
|
||||||
*/
|
*/
|
||||||
@@ -2376,7 +2430,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
|
|||||||
fctx_done(fctx, DNS_R_SERVFAIL);
|
fctx_done(fctx, DNS_R_SERVFAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fctx_freelookups(fctx);
|
fctx_cleanupfinds(fctx);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Try again.
|
* Try again.
|
||||||
@@ -2853,7 +2907,7 @@ dns_resolver_destroyfetch(dns_resolver_t *res, dns_fetch_t **fetchp) {
|
|||||||
* No one cares about the result of this fetch anymore.
|
* No one cares about the result of this fetch anymore.
|
||||||
* Shut it down.
|
* Shut it down.
|
||||||
*/
|
*/
|
||||||
fctx->exiting = ISC_TRUE;
|
fctx->want_shutdown = ISC_TRUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unless we're still initializing (in which case the
|
* Unless we're still initializing (in which case the
|
||||||
|
Reference in New Issue
Block a user