]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_8] dig could miss tcp connections when cleaning up
authorEvan Hunt <each@isc.org>
Mon, 2 Dec 2013 21:38:03 +0000 (13:38 -0800)
committerEvan Hunt <each@isc.org>
Mon, 2 Dec 2013 21:38:03 +0000 (13:38 -0800)
3679. [bug] dig could fail to clean up TCP sockets still
waiting on connect(). [RT #35074]

(cherry picked from commit fb507315d4a921ffa9e2fd617cb3439ec8c15ca8)

CHANGES
bin/dig/dighost.c

diff --git a/CHANGES b/CHANGES
index 0e285cbc89b193042065af12a6a3f8957344e00c..064853e04f65461649b2831c39d239cd4af4c805 100644 (file)
--- 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
index 52f81924f0608921433f59b272159c457c375073..06bb082ba3109338c1e344b1c26a141b8d80594c 100644 (file)
@@ -1330,6 +1330,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");
@@ -1348,6 +1349,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");
@@ -3739,18 +3741,31 @@ cancel_all(void) {
        if (current_lookup != NULL) {
                if (current_lookup->timer != NULL)
                        isc_timer_detach(&current_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);