From 4d6408b82362c71ea04520083a3c6f4336ea4a1d Mon Sep 17 00:00:00 2001 From: Diego Fronza Date: Mon, 29 Mar 2021 14:04:12 -0300 Subject: [PATCH] Fix following up lookup failure if more resolvers are available _query_detach function was incorrectly unliking the query object from the lookup->q query list, this made it impossible to follow a query lookup failure with the next one in the list (possibly using a separate resolver), as the link to the next query in the list was dissolved. Fix by unliking the node only when the query object is about to be destroyed, i.e. there is no more references to the object. --- bin/dig/dighost.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 9473219c2a..a4a2ebdaf1 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -1692,14 +1692,13 @@ _query_detach(dig_query_t **queryp, const char *file, unsigned int line) { query_detach(&lookup->current_query); } - if (ISC_LINK_LINKED(query, link)) { - ISC_LIST_UNLINK(lookup->q, query, link); - } - debug("%s:%u:query_detach(%p) = %" PRIuFAST32, file, line, query, isc_refcount_current(&query->references) - 1); if (isc_refcount_decrement(&query->references) == 1) { + if (ISC_LINK_LINKED(query, link)) { + ISC_LIST_UNLINK(lookup->q, query, link); + } destroy_query(query, file, line); } }