]> git.ipfire.org Git - thirdparty/bind9.git/commit
Keep idle reused outgoing TCP connections under read
authorOndřej Surý <ondrej@isc.org>
Sun, 21 Jun 2026 07:24:14 +0000 (09:24 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 24 Jun 2026 11:52:46 +0000 (13:52 +0200)
commitfebeac215d4e055da9830ce14e47c4a9cf71bb5c
treeb012f646b2fffde94f97fb4e3c96a9f553fb3429
parenta65ece36484699eb8eeac08e54bd99174736b974
Keep idle reused outgoing TCP connections under read

A reused TCP/TLS dispatch with no outstanding responses was left in the
reuse pool with no read pending, so a peer closing the idle connection
went unnoticed: the socket lingered in CLOSE-WAIT and the dead dispatch
was later handed to a new query, which failed and the fetch timed out.
Keep a read pending on an idle connected dispatch, bounded by an idle
timeout, so the close is seen promptly and the connection is dropped
from the pool instead of reused.

The idle read may only be (re)armed while the dispatch is still
connected; arming it on a dispatch that is already shutting down
re-reads a dying handle and double-schedules a netmgr job.

On shutdown, close the connection as soon as the dispatch reaches its
terminal state instead of waiting for the last reference to drop, so an
unexpected read (or a peer-side close) cannot leave the socket in
CLOSE-WAIT while a reference still lingers.
bin/named/main.c
lib/dns/dispatch.c
tests/dns/dispatch_test.c