From fb24c95ea82352e319f8f1d1ac77a87b16834189 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 16 Dec 2016 19:26:34 +0000 Subject: [PATCH] adns_finish: Cancel parent queries first Here, we should not cancel a query with a parent, because that leaves the parent in a silly state (childw, but no children) which adns__consistency complains about. Instead, search upwards for a parent to cancel. Signed-off-by: Ian Jackson --- src/setup.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/setup.c b/src/setup.c index 26338e8..41c0e67 100644 --- a/src/setup.c +++ b/src/setup.c @@ -792,15 +792,20 @@ int adns_init_logfn(adns_state *newstate_r, adns_initflags flags, return init_files(newstate_r, flags, logfn, logfndata); } +static void cancel_all(adns_query qu) { + if (!qu->parent) adns__cancel(qu); + else cancel_all(qu->parent); +} + void adns_finish(adns_state ads) { int i; adns__consistency(ads,0,cc_enter); for (;;) { - if (ads->udpw.head) adns__cancel(ads->udpw.head); - else if (ads->tcpw.head) adns__cancel(ads->tcpw.head); - else if (ads->childw.head) adns__cancel(ads->childw.head); - else if (ads->output.head) adns__cancel(ads->output.head); - else if (ads->intdone.head) adns__cancel(ads->output.head); + if (ads->udpw.head) cancel_all(ads->udpw.head); + else if (ads->tcpw.head) cancel_all(ads->tcpw.head); + else if (ads->childw.head) cancel_all(ads->childw.head); + else if (ads->output.head) cancel_all(ads->output.head); + else if (ads->intdone.head) cancel_all(ads->output.head); else break; } for (i=0; inudpsockets; i++) close(ads->udpsockets[i].fd); -- 2.30.2