]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Simplify when to detach the client
authorMatthijs Mekking <matthijs@isc.org>
Thu, 25 Mar 2021 17:12:38 +0000 (18:12 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Fri, 2 Apr 2021 07:14:09 +0000 (09:14 +0200)
With stale-answer-client-timeout, we may send a response to the client,
but we may want to hold on to the network manager handle, because
recursion is going on in the background, or we need to refresh a
stale RRset.

Simplify the setting of 'nodetach':
* During a staleonly lookup we should not detach the nmhandle, so just
  set it prior to 'query_lookup()'.
* During a staleonly "stalefirst" lookup set the 'nodetach' to true
  if we are going to refresh the RRset.

Now there is no longer the need to clear the 'nodetach' if we go
through the "dbfind_stale", "stale_refresh_window", or "stale_only"
paths.

lib/ns/query.c

index ed770d670b2bfed263e45c781a20ce7bc94133f4..c7fa531b1e71a5510079008dba319d3563d341ab 100644 (file)
@@ -5786,7 +5786,6 @@ query_lookup(query_ctx_t *qctx) {
                 * active RRset is not available.
                 */
                qctx->client->query.dboptions |= DNS_DBFIND_STALEONLY;
-               qctx->client->nodetach = true;
        }
 
        dboptions = qctx->client->query.dboptions;
@@ -5891,7 +5890,6 @@ query_lookup(query_ctx_t *qctx) {
                        QUERY_ERROR(qctx, DNS_R_SERVFAIL);
                        return (ns_query_done(qctx));
                }
-               qctx->client->nodetach = false;
        } else if (stale_refresh_window) {
                /*
                 * A recent lookup failed, so during this time window we are
@@ -5911,15 +5909,7 @@ query_lookup(query_ctx_t *qctx) {
                        QUERY_ERROR(qctx, DNS_R_SERVFAIL);
                        return (ns_query_done(qctx));
                }
-               qctx->client->nodetach = false;
        } else if (stale_only) {
-               /*
-                * This is a staleonly lookup: if there wass no stale answer
-                * in cache, treat as we don't have an answer and wait for the
-                * resolver fetch to finish.
-                */
-               qctx->client->nodetach = !stale_found;
-
                if ((qctx->options & DNS_GETDB_STALEFIRST) != 0) {
                        if (!stale_found || result != ISC_R_SUCCESS) {
                                /*
@@ -5952,6 +5942,7 @@ query_lookup(query_ctx_t *qctx) {
                                        "refresh the RRset will still be made",
                                        namebuf);
                                refresh_rrset = STALE(qctx->rdataset);
+                               qctx->client->nodetach = refresh_rrset;
                        }
                } else {
                        /*