Ensure dig lookup is detached on UDP connect failure

dig could hang when UDP connect failed due to a dangling lookup object.
This commit is contained in:
Evan Hunt
2021-04-06 16:49:14 -07:00
committed by Ondřej Surý
parent 72ef5f465d
commit d2ea8f4245

View File

@@ -1541,12 +1541,13 @@ _destroy_lookup(dig_lookup_t *lookup) {
dig_server_t *s;
void *ptr;
REQUIRE(lookup != NULL);
REQUIRE(ISC_LIST_EMPTY(lookup->q));
debug("destroy_lookup");
isc_refcount_destroy(&lookup->references);
REQUIRE(ISC_LIST_EMPTY(lookup->q));
s = ISC_LIST_HEAD(lookup->my_server_list);
while (s != NULL) {
debug("freeing server %p belonging to %p", s, lookup);
@@ -2897,10 +2898,14 @@ udp_ready(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
query_detach(&query);
return;
} else if (eresult != ISC_R_SUCCESS) {
dig_lookup_t *l = query->lookup;
if (eresult != ISC_R_CANCELED) {
debug("udp setup failed: %s",
isc_result_totext(eresult));
}
lookup_detach(&l);
query_detach(&query);
return;
}