From: Matthijs Mekking Date: Thu, 25 Mar 2021 17:12:38 +0000 (+0100) Subject: Simplify when to detach the client X-Git-Tag: v9.17.12~16^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=48b0dc159b9519f8c2ee1d2d529dad40cf2947eb;p=thirdparty%2Fbind9.git Simplify when to detach the client 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. --- diff --git a/lib/ns/query.c b/lib/ns/query.c index ed770d670b2..c7fa531b1e7 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -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 { /*