]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Shutdown all active TCP connections on error
authorOndřej Surý <ondrej@sury.org>
Fri, 26 Nov 2021 08:14:58 +0000 (09:14 +0100)
committerEvan Hunt <each@isc.org>
Wed, 1 Dec 2021 19:45:55 +0000 (11:45 -0800)
When outgoing TCP connection was prematurely terminated (f.e. with
connection reset), the dispatch code would not cleanup the resources
used by such connection leading to dangling dns_dispentry_t entries.

lib/dns/dispatch.c

index e52d7970a7e9364a2b498a46d3b755b52e060732..0893c39894a6a663b30b25fec7325b216ef31876 100644 (file)
@@ -688,6 +688,16 @@ tcp_recv(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
                             "shutting down due to TCP "
                             "receive error: %s: %s",
                             buf, isc_result_totext(eresult));
+               /*
+                * If there are any active responses, shut them all down.
+                */
+               for (resp = ISC_LIST_HEAD(disp->active); resp != NULL;
+                    resp = next) {
+                       next = ISC_LIST_NEXT(resp, alink);
+                       dispentry_attach(resp, &(dns_dispentry_t *){ NULL });
+                       ISC_LIST_UNLINK(disp->active, resp, alink);
+                       ISC_LIST_APPEND(resps, resp, rlink);
+               }
                goto done;
        }