From: Evan Hunt Date: Mon, 2 Dec 2013 21:40:41 +0000 (-0800) Subject: [v9_6] dig could miss tcp connections when cleaning up X-Git-Tag: v9.6-ESV-R11b1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2470cd03696ff1b5cc081c508f74058acc5a4d61;p=thirdparty%2Fbind9.git [v9_6] dig could miss tcp connections when cleaning up 3679. [bug] dig could fail to clean up TCP sockets still waiting on connect(). [RT #35074] (cherry picked from commit fb507315d4a921ffa9e2fd617cb3439ec8c15ca8) --- diff --git a/CHANGES b/CHANGES index 15aacf6de4f..a212111ef7a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3679. [bug] dig could fail to clean up TCP sockets still + waiting on connect(). [RT #35074] + 3678. [port] Update config.guess and config.sub. [RT #35060] 3677. [bug] 'nsupdate' leaked memory if 'realm' was used multiple diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index dab4458a1fc..0183945a7c7 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -1151,12 +1151,14 @@ setup_libs(void) { result = isc_mem_create(0, 0, &mctx); check_result(result, "isc_mem_create"); + isc_mem_setname(mctx, "dig", NULL); result = isc_taskmgr_create(mctx, 1, 0, &taskmgr); check_result(result, "isc_taskmgr_create"); result = isc_task_create(taskmgr, 0, &global_task); check_result(result, "isc_task_create"); + isc_task_setname(global_task, "dig", NULL); result = isc_timermgr_create(mctx, &timermgr); check_result(result, "isc_timermgr_create"); @@ -3553,18 +3555,31 @@ cancel_all(void) { if (current_lookup != NULL) { if (current_lookup->timer != NULL) isc_timer_detach(¤t_lookup->timer); - q = ISC_LIST_HEAD(current_lookup->q); - while (q != NULL) { - debug("canceling query %p, belonging to %p", - q, current_lookup); + for (q = ISC_LIST_HEAD(current_lookup->q); + q != NULL; + q = nq) + { nq = ISC_LIST_NEXT(q, link); - if (q->sock != NULL) { + debug("canceling pending query %p, belonging to %p", + q, current_lookup); + if (q->sock != NULL) isc_socket_cancel(q->sock, NULL, ISC_SOCKCANCEL_ALL); - } else { + else + clear_query(q); + } + for (q = ISC_LIST_HEAD(current_lookup->connecting); + q != NULL; + q = nq) + { + nq = ISC_LIST_NEXT(q, clink); + debug("canceling connecting query %p, belonging to %p", + q, current_lookup); + if (q->sock != NULL) + isc_socket_cancel(q->sock, NULL, + ISC_SOCKCANCEL_ALL); + else clear_query(q); - } - q = nq; } } l = ISC_LIST_HEAD(lookup_list);