From 8fecc9dc1ec32b2259dc760dfeedce38c68d4cd1 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Tue, 21 Jun 2022 11:54:50 +0000 Subject: [PATCH] dig +nssearch: send more queries even if sending the previous one fails In the NSSEARCH followup lookup, when one of the queries fails to be sent, DiG doesn't start the next query. This is a mistake, because in NSSEARCH mode the queries are independent and DiG shouldn't stop the lookup process just because sending a query to one of the name servers returns an error code. Restructure the `send_done()` function to unconditionally send the next query in NSSEARCH mode, if it exists. (cherry picked from commit 49ac879dfad91ac08201be3e351450fd9d83b9f5) --- bin/dig/dighost.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index b1b2b605e6..6a3eec31f0 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2673,7 +2673,6 @@ setup_lookup(dig_lookup_t *lookup) { static void send_done(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) { dig_query_t *query = (dig_query_t *)arg; - dig_query_t *next = NULL; dig_lookup_t *l = NULL; REQUIRE(DIG_VALID_QUERY(query)); @@ -2704,39 +2703,31 @@ send_done(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) { return; } else if (eresult != ISC_R_SUCCESS) { debug("send failed: %s", isc_result_totext(eresult)); - query_detach(&query); - lookup_detach(&l); - UNLOCK_LOOKUP; - return; } if (l->ns_search_only && !l->trace_root) { + dig_query_t *next = ISC_LIST_NEXT(query, link); bool tcp_mode = l->tcp_mode; - debug("sending next, since searching"); - next = ISC_LIST_NEXT(query, link); - query_detach(&query); lookup_detach(&l); if (next == NULL) { clear_current_lookup(); } else { + debug("sending next, since searching"); + if (tcp_mode) { start_tcp(next); } else { start_udp(next); } } - - check_if_done(); - UNLOCK_LOOKUP; - return; + } else { + query_detach(&query); + lookup_detach(&l); } - query_detach(&query); - lookup_detach(&l); - check_if_done(); UNLOCK_LOOKUP; }