mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-08 23:02:05 -04:00
Restore more locking in the lib/dns/resolver.c code
1. Restore locking in the fctx_decreference() code, because the insides of the function needs to be protected when fctx->references drops to 0. 2. Restore locking in the dns_resolver_attach() code, because two variables are accessed at the same time and there's slight chance of data race.
This commit is contained in:
parent
317e36d47e
commit
a4141fcf98
1 changed files with 5 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -10736,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