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)
This commit is contained in:
Aram Sargsyan 2022-06-21 11:54:50 +00:00
parent 5d47d4e342
commit 8fecc9dc1e

View file

@ -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;
}