From: Ondřej Surý Date: Fri, 26 Nov 2021 08:14:58 +0000 (+0100) Subject: Shutdown all active TCP connections on error X-Git-Tag: v9.17.21~7^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9230473324827311beabfc7d80c06f3f9697b45a;p=thirdparty%2Fbind9.git Shutdown all active TCP connections on error 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. --- diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index e52d7970a7e..0893c39894a 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -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; }