[9.20] chg: dev: Shutdown the fetch context after canceling the last fetch

Shutdown the fetch context immediately after the last fetch has been canceled from
that particular fetch context.

Backport of MR !9958

Merge branch 'backport-ondrej/shutdown-the-fetch-context-early-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!9977
This commit is contained in:
Ondřej Surý 2025-01-22 14:05:12 +00:00
commit 55b7cc9596

View file

@ -10604,6 +10604,7 @@ fail:
void
dns_resolver_cancelfetch(dns_fetch_t *fetch) {
fetchctx_t *fctx = NULL;
bool last_fetch = false;
REQUIRE(DNS_FETCH_VALID(fetch));
fctx = fetch->private;
@ -10634,11 +10635,15 @@ dns_resolver_cancelfetch(dns_fetch_t *fetch) {
}
}
/*
* The fctx continues running even if no fetches remain;
* the answer is still cached.
*/
if (ISC_LIST_EMPTY(fctx->resps)) {
last_fetch = true;
}
UNLOCK(&fctx->lock);
if (last_fetch) {
fetchctx_ref(fctx);
isc_async_run(fctx->loop, fctx_shutdown, fctx);
}
}
void