diff --git a/lib/ns/query.c b/lib/ns/query.c index 2da89d096a..48182fe80a 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -5943,6 +5943,13 @@ query_lookup(query_ctx_t *qctx) { dns_cache_updatestats(qctx->view->cache, result); } + if (dns_rdataset_isassociated(qctx->rdataset) && + dns_rdataset_count(qctx->rdataset) > 0 && !STALE(qctx->rdataset)) + { + /* Found non-stale usable rdataset. */ + goto gotanswer; + } + /* * If DNS_DBFIND_STALEOK is set this means we are dealing with a * lookup following a failed lookup and it is okay to serve a stale @@ -6109,6 +6116,7 @@ query_lookup(query_ctx_t *qctx) { qctx->rdataset->attributes |= DNS_RDATASETATTR_STALE_ADDED; } +gotanswer: result = query_gotanswer(qctx, result); cleanup: