]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Shutdown the fetch context after canceling the last fetch
authorOndřej Surý <ondrej@isc.org>
Wed, 15 Jan 2025 12:02:20 +0000 (13:02 +0100)
committerOndřej Surý <ondrej@isc.org>
Wed, 22 Jan 2025 13:19:20 +0000 (14:19 +0100)
Currently, the fetch context will continue running even when the last
fetch (response) has been removed from the context, so named can process
and cache the answer.  This can lead to a situation where the number of
outgoing recursing clients exceeds the the configured number for
recursive-clients.

Be more stringent about the recursive-clients limit and shutdown the
fetch context immediately after the last fetch has been canceled from
that particular fetch context.

lib/dns/resolver.c

index ce878f15f8f7044ecf03fc1da9083a89151e264f..746fe6d94730f3518becf1c07387f55be4d55245 100644 (file)
@@ -10584,6 +10584,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;
@@ -10614,11 +10615,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