Compare commits

...

1 Commits

Author SHA1 Message Date
Mark Andrews
2b0856c20d make FCTX_ATTR_SHUTTINGDOWN a independent bool 2019-11-29 17:00:00 +11:00

View File

@@ -272,6 +272,7 @@ struct fetchctx {
bool want_shutdown;
bool cloned;
bool spilled;
bool shuttingdown;
isc_event_t control_event;
ISC_LINK(struct fetchctx) link;
ISC_LIST(dns_fetchevent_t) events;
@@ -393,7 +394,6 @@ struct fetchctx {
#define FCTX_ATTR_HAVEANSWER 0x0001
#define FCTX_ATTR_GLUING 0x0002
#define FCTX_ATTR_ADDRWAIT 0x0004
#define FCTX_ATTR_SHUTTINGDOWN 0x0008
#define FCTX_ATTR_WANTCACHE 0x0010
#define FCTX_ATTR_WANTNCACHE 0x0020
#define FCTX_ATTR_NEEDEDNS0 0x0040
@@ -406,8 +406,6 @@ struct fetchctx {
0)
#define ADDRWAIT(f) (((f)->attributes & FCTX_ATTR_ADDRWAIT) != \
0)
#define SHUTTINGDOWN(f) (((f)->attributes & FCTX_ATTR_SHUTTINGDOWN) \
!= 0)
#define WANTCACHE(f) (((f)->attributes & FCTX_ATTR_WANTCACHE) != 0)
#define WANTNCACHE(f) (((f)->attributes & FCTX_ATTR_WANTNCACHE) != 0)
#define NEEDEDNS0(f) (((f)->attributes & FCTX_ATTR_NEEDEDNS0) != 0)
@@ -3050,7 +3048,7 @@ fctx_finddone(isc_task_t *task, isc_event_t *event) {
/*
* The fetch is waiting for a name to be found.
*/
INSIST(!SHUTTINGDOWN(fctx));
INSIST(!fctx->shuttingdown);
if (event->ev_type == DNS_EVENT_ADBMOREADDRESSES) {
fctx->attributes &= ~FCTX_ATTR_ADDRWAIT;
want_try = true;
@@ -3066,7 +3064,7 @@ fctx_finddone(isc_task_t *task, isc_event_t *event) {
want_done = true;
}
}
} else if (SHUTTINGDOWN(fctx) && fctx->pending == 0 &&
} else if (fctx->shuttingdown && fctx->pending == 0 &&
fctx->nqueries == 0 && ISC_LIST_EMPTY(fctx->validators)) {
if (isc_refcount_current(&fctx->references) == 0) {
@@ -4181,10 +4179,13 @@ resume_qmin(isc_task_t *task, isc_event_t *event) {
dns_resolver_destroyfetch(&fctx->qminfetch);
if (SHUTTINGDOWN(fctx)) {
maybe_destroy(fctx, false);
LOCK(&res->buckets[bucketnum].lock);
if (fctx->shuttingdown) {
maybe_destroy(fctx, true);
UNLOCK(&res->buckets[bucketnum].lock);
goto cleanup;
}
UNLOCK(&res->buckets[bucketnum].lock);
/*
* Note: fevent->rdataset must be disassociated and
@@ -4547,7 +4548,7 @@ fctx_doshutdown(isc_task_t *task, isc_event_t *event) {
LOCK(&res->buckets[bucketnum].lock);
fctx->attributes |= FCTX_ATTR_SHUTTINGDOWN;
fctx->shuttingdown = true;
INSIST(fctx->state == fetchstate_active ||
fctx->state == fetchstate_done);
@@ -4601,7 +4602,7 @@ fctx_start(isc_task_t *task, isc_event_t *event) {
* We haven't started this fctx yet, and we've been requested
* to shut it down.
*/
fctx->attributes |= FCTX_ATTR_SHUTTINGDOWN;
fctx->shuttingdown = true;
fctx->state = fetchstate_done;
fctx_sendevents(fctx, ISC_R_CANCELED, __LINE__);
/*
@@ -4793,6 +4794,7 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
fctx->dbucketnum = RES_NOBUCKET;
fctx->state = fetchstate_init;
fctx->want_shutdown = false;
fctx->shuttingdown = false;
fctx->cloned = false;
fctx->depth = depth;
fctx->minimized = false;
@@ -5316,11 +5318,12 @@ maybe_destroy(fetchctx_t *fctx, bool locked) {
dns_validator_t *validator, *next_validator;
bool dodestroy = false;
REQUIRE(SHUTTINGDOWN(fctx));
bucketnum = fctx->bucketnum;
if (!locked)
LOCK(&res->buckets[bucketnum].lock);
REQUIRE(fctx->shuttingdown);
if (fctx->pending != 0 || fctx->nqueries != 0)
goto unlock;
@@ -5416,7 +5419,7 @@ validated(isc_task_t *task, isc_event_t *event) {
* done waiting for validator completions and ADB pending events; if
* so, destroy the fctx.
*/
if (SHUTTINGDOWN(fctx) && !sentresponse) {
if (fctx->shuttingdown && !sentresponse) {
bool bucket_empty;
bucket_empty = maybe_destroy(fctx, true);
UNLOCK(&res->buckets[bucketnum].lock);
@@ -5653,11 +5656,13 @@ validated(isc_task_t *task, isc_event_t *event) {
* the data, destroy now.
*/
dns_db_detachnode(fctx->cache, &node);
if (SHUTTINGDOWN(fctx))
if (fctx->shuttingdown) {
bucket_empty = maybe_destroy(fctx, true);
}
UNLOCK(&res->buckets[bucketnum].lock);
if (bucket_empty)
if (bucket_empty) {
empty_bucket(res);
}
goto cleanup_event;
}
@@ -7027,7 +7032,7 @@ fctx_decreference(fetchctx_t *fctx) {
* No one cares about the result of this fetch anymore.
*/
if (fctx->pending == 0 && fctx->nqueries == 0 &&
ISC_LIST_EMPTY(fctx->validators) && SHUTTINGDOWN(fctx)) {
ISC_LIST_EMPTY(fctx->validators) && fctx->shuttingdown) {
/*
* This fctx is already shutdown; we were just
* waiting for the last reference to go away.