From: Evan Hunt Date: Mon, 2 Dec 2013 21:34:23 +0000 (-0800) Subject: [master] dig could miss tcp connections when cleaning up X-Git-Tag: v9.10.0a2~202 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=fb507315d4a921ffa9e2fd617cb3439ec8c15ca8;p=thirdparty%2Fbind9.git [master] dig could miss tcp connections when cleaning up 3679. [bug] dig could fail to clean up TCP sockets still waiting on connect(). [RT #35074] --- diff --git a/CHANGES b/CHANGES index 68725759807..2989c185b80 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 0b25bdd6020..32d2b33ca90 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -1325,6 +1325,7 @@ setup_libs(void) { result = isc_mem_create(0, 0, &mctx); check_result(result, "isc_mem_create"); + isc_mem_setname(mctx, "dig", NULL); result = isc_log_create(mctx, &lctx, &logconfig); check_result(result, "isc_log_create"); @@ -1343,6 +1344,7 @@ setup_libs(void) { 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"); @@ -3735,18 +3737,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);