mirror of
https://github.com/isc-projects/bind9.git
synced 2026-03-03 14:00:47 -05:00
Merge branch '1149-fix-crashes-during-resolver-shutdown' into 'master'
Restore locking in dns_resolver_shutdown and dns_resolver_attach Closes #1149 See merge request isc-projects/bind9!2164
This commit is contained in:
commit
fb40bc061f
1 changed files with 13 additions and 5 deletions
|
|
@ -476,15 +476,15 @@ struct dns_resolver {
|
|||
isc_timermgr_t * timermgr;
|
||||
isc_taskmgr_t * taskmgr;
|
||||
dns_view_t * view;
|
||||
bool frozen;
|
||||
bool frozen;
|
||||
unsigned int options;
|
||||
dns_dispatchmgr_t * dispatchmgr;
|
||||
dns_dispatchset_t * dispatches4;
|
||||
bool exclusivev4;
|
||||
bool exclusivev4;
|
||||
dns_dispatchset_t * dispatches6;
|
||||
isc_dscp_t querydscp4;
|
||||
isc_dscp_t querydscp6;
|
||||
bool exclusivev6;
|
||||
bool exclusivev6;
|
||||
unsigned int nbuckets;
|
||||
fctxbucket_t * buckets;
|
||||
zonebucket_t * dbuckets;
|
||||
|
|
@ -524,7 +524,7 @@ struct dns_resolver {
|
|||
unsigned int spillat; /* clients-per-query */
|
||||
unsigned int zspill; /* fetches-per-zone */
|
||||
|
||||
dns_badcache_t * badcache; /* Bad cache. */
|
||||
dns_badcache_t * badcache; /* Bad cache. */
|
||||
|
||||
/* Locked by primelock. */
|
||||
dns_fetch_t * primefetch;
|
||||
|
|
@ -9384,7 +9384,9 @@ rctx_resend(respctx_t *rctx, dns_adbaddrinfo_t *addrinfo) {
|
|||
}
|
||||
|
||||
fctx_done(fctx, result, __LINE__);
|
||||
LOCK(&fctx->res->buckets[fctx->bucketnum].lock);
|
||||
bucket_empty = fctx_decreference(fctx);
|
||||
UNLOCK(&fctx->res->buckets[fctx->bucketnum].lock);
|
||||
if (bucket_empty) {
|
||||
empty_bucket(fctx->res);
|
||||
}
|
||||
|
|
@ -10278,8 +10280,10 @@ dns_resolver_attach(dns_resolver_t *source, dns_resolver_t **targetp) {
|
|||
|
||||
RRTRACE(source, "attach");
|
||||
|
||||
LOCK(&source->lock);
|
||||
REQUIRE(!atomic_load_acquire(&source->exiting));
|
||||
isc_refcount_increment(&source->references);
|
||||
UNLOCK(&source->lock);
|
||||
|
||||
*targetp = source;
|
||||
}
|
||||
|
|
@ -10326,6 +10330,7 @@ dns_resolver_shutdown(dns_resolver_t *res) {
|
|||
|
||||
RTRACE("shutdown");
|
||||
|
||||
LOCK(&res->lock);
|
||||
if (atomic_compare_exchange_strong(&res->exiting, &is_false, true)) {
|
||||
RTRACE("exiting");
|
||||
|
||||
|
|
@ -10357,6 +10362,7 @@ dns_resolver_shutdown(dns_resolver_t *res) {
|
|||
NULL, true);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
}
|
||||
UNLOCK(&res->lock);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -10372,8 +10378,10 @@ dns_resolver_detach(dns_resolver_t **resp) {
|
|||
*resp = NULL;
|
||||
|
||||
if (isc_refcount_decrement(&res->references) == 1) {
|
||||
LOCK(&res->lock);
|
||||
INSIST(atomic_load_acquire(&res->exiting));
|
||||
INSIST(res->activebuckets == 0);
|
||||
UNLOCK(&res->lock);
|
||||
destroy(res);
|
||||
}
|
||||
}
|
||||
|
|
@ -10732,9 +10740,9 @@ dns_resolver_destroyfetch(dns_fetch_t **fetchp) {
|
|||
RUNTIME_CHECK(event->fetch != fetch);
|
||||
}
|
||||
}
|
||||
UNLOCK(&res->buckets[bucketnum].lock);
|
||||
|
||||
bucket_empty = fctx_decreference(fctx);
|
||||
UNLOCK(&res->buckets[bucketnum].lock);
|
||||
|
||||
isc_mem_putanddetach(&fetch->mctx, fetch, sizeof(*fetch));
|
||||
*fetchp = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue