mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
Simplify fctx_unlink() and fctx_destroy()
These functions are always called together; this commit combines them.
This commit is contained in:
@@ -609,8 +609,6 @@ static const dns_name_t underscore_name =
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
destroy(dns_resolver_t *res);
|
destroy(dns_resolver_t *res);
|
||||||
static void
|
|
||||||
empty_bucket(dns_resolver_t *res);
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
resquery_send(resquery_t *query);
|
resquery_send(resquery_t *query);
|
||||||
static void
|
static void
|
||||||
@@ -624,9 +622,9 @@ fctx_shutdown(fetchctx_t *fctx);
|
|||||||
static isc_result_t
|
static isc_result_t
|
||||||
fctx_minimize_qname(fetchctx_t *fctx);
|
fctx_minimize_qname(fetchctx_t *fctx);
|
||||||
static void
|
static void
|
||||||
fctx_destroy(fetchctx_t *fctx);
|
fctx_destroy(fetchctx_t *fctx, bool exiting);
|
||||||
static bool
|
static void
|
||||||
fctx_unlink(fetchctx_t *fctx);
|
send_shutdown_events(dns_resolver_t *res);
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
ncache_adderesult(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
|
ncache_adderesult(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
|
||||||
dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t minttl,
|
dns_rdatatype_t covers, isc_stdtime_t now, dns_ttl_t minttl,
|
||||||
@@ -4195,14 +4193,13 @@ cleanup:
|
|||||||
fctx_detach(&fctx);
|
fctx_detach(&fctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
fctx_unlink(fetchctx_t *fctx) {
|
fctx_destroy(fetchctx_t *fctx, bool exiting) {
|
||||||
dns_resolver_t *res;
|
dns_resolver_t *res = NULL;
|
||||||
|
isc_sockaddr_t *sa = NULL, *next_sa = NULL;
|
||||||
|
struct tried *tried = NULL;
|
||||||
unsigned int bucketnum;
|
unsigned int bucketnum;
|
||||||
|
bool bucket_empty = false;
|
||||||
/*
|
|
||||||
* Caller must be holding the bucket lock.
|
|
||||||
*/
|
|
||||||
|
|
||||||
REQUIRE(VALID_FCTX(fctx));
|
REQUIRE(VALID_FCTX(fctx));
|
||||||
REQUIRE(fctx->state == fetchstate_done ||
|
REQUIRE(fctx->state == fetchstate_done ||
|
||||||
@@ -4214,16 +4211,13 @@ fctx_unlink(fetchctx_t *fctx) {
|
|||||||
REQUIRE(atomic_load_acquire(&fctx->pending) == 0);
|
REQUIRE(atomic_load_acquire(&fctx->pending) == 0);
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->validators));
|
REQUIRE(ISC_LIST_EMPTY(fctx->validators));
|
||||||
|
|
||||||
FCTXTRACE("unlink");
|
FCTXTRACE("destroy");
|
||||||
|
|
||||||
isc_refcount_destroy(&fctx->references);
|
|
||||||
|
|
||||||
res = fctx->res;
|
res = fctx->res;
|
||||||
bucketnum = fctx->bucketnum;
|
bucketnum = fctx->bucketnum;
|
||||||
|
|
||||||
LOCK(&res->buckets[bucketnum].lock);
|
LOCK(&res->buckets[bucketnum].lock);
|
||||||
ISC_LIST_UNLINK(res->buckets[bucketnum].fctxs, fctx, link);
|
ISC_LIST_UNLINK(res->buckets[bucketnum].fctxs, fctx, link);
|
||||||
UNLOCK(&res->buckets[bucketnum].lock);
|
|
||||||
|
|
||||||
INSIST(atomic_fetch_sub_release(&res->nfctx, 1) > 0);
|
INSIST(atomic_fetch_sub_release(&res->nfctx, 1) > 0);
|
||||||
|
|
||||||
@@ -4232,29 +4226,16 @@ fctx_unlink(fetchctx_t *fctx) {
|
|||||||
if (atomic_load_acquire(&res->buckets[bucketnum].exiting) &&
|
if (atomic_load_acquire(&res->buckets[bucketnum].exiting) &&
|
||||||
ISC_LIST_EMPTY(res->buckets[bucketnum].fctxs))
|
ISC_LIST_EMPTY(res->buckets[bucketnum].fctxs))
|
||||||
{
|
{
|
||||||
return (true);
|
bucket_empty = true;
|
||||||
}
|
}
|
||||||
|
UNLOCK(&res->buckets[bucketnum].lock);
|
||||||
|
|
||||||
return (false);
|
if (bucket_empty && exiting &&
|
||||||
}
|
isc_refcount_decrement(&res->activebuckets) == 1) {
|
||||||
|
LOCK(&res->lock);
|
||||||
static void
|
send_shutdown_events(res);
|
||||||
fctx_destroy(fetchctx_t *fctx) {
|
UNLOCK(&res->lock);
|
||||||
isc_sockaddr_t *sa, *next_sa;
|
}
|
||||||
struct tried *tried;
|
|
||||||
|
|
||||||
REQUIRE(VALID_FCTX(fctx));
|
|
||||||
REQUIRE(fctx->state == fetchstate_done ||
|
|
||||||
fctx->state == fetchstate_init);
|
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->events));
|
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->queries));
|
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->finds));
|
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->altfinds));
|
|
||||||
REQUIRE(atomic_load_acquire(&fctx->pending) == 0);
|
|
||||||
REQUIRE(ISC_LIST_EMPTY(fctx->validators));
|
|
||||||
REQUIRE(!ISC_LINK_LINKED(fctx, link));
|
|
||||||
|
|
||||||
FCTXTRACE("destroy");
|
|
||||||
|
|
||||||
isc_refcount_destroy(&fctx->references);
|
isc_refcount_destroy(&fctx->references);
|
||||||
|
|
||||||
@@ -6856,10 +6837,7 @@ fctx__detach(fetchctx_t **fctxp, const char *file, unsigned int line,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (refs == 1) {
|
if (refs == 1) {
|
||||||
if (fctx_unlink(fctx)) {
|
fctx_destroy(fctx, true);
|
||||||
empty_bucket(fctx->res);
|
|
||||||
}
|
|
||||||
fctx_destroy(fctx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9749,17 +9727,6 @@ send_shutdown_events(dns_resolver_t *res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
empty_bucket(dns_resolver_t *res) {
|
|
||||||
RTRACE("empty_bucket");
|
|
||||||
|
|
||||||
if (isc_refcount_decrement(&res->activebuckets) == 1) {
|
|
||||||
LOCK(&res->lock);
|
|
||||||
send_shutdown_events(res);
|
|
||||||
UNLOCK(&res->lock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spillattimer_countdown(isc_task_t *task, isc_event_t *event) {
|
spillattimer_countdown(isc_task_t *task, isc_event_t *event) {
|
||||||
dns_resolver_t *res = event->ev_arg;
|
dns_resolver_t *res = event->ev_arg;
|
||||||
@@ -10456,13 +10423,7 @@ unlock:
|
|||||||
UNLOCK(&res->buckets[bucketnum].lock);
|
UNLOCK(&res->buckets[bucketnum].lock);
|
||||||
|
|
||||||
if (dodestroy) {
|
if (dodestroy) {
|
||||||
/*
|
fctx_destroy(fctx, false);
|
||||||
* We don't care about the result of
|
|
||||||
* fctx_unlink() since we know we're not
|
|
||||||
* exiting.
|
|
||||||
*/
|
|
||||||
(void)fctx_unlink(fctx);
|
|
||||||
fctx_destroy(fctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
|
Reference in New Issue
Block a user