From 7b6945fb60fc477a602a14e41ef35cea0b438710 Mon Sep 17 00:00:00 2001 From: Artem Boldariev Date: Fri, 2 Jul 2021 18:25:17 +0300 Subject: [PATCH] Fix BIND hanging when browsers end HTTP/2 streams prematurely The commit fixes BIND hanging when browsers end HTTP/2 streams prematurely (for example, by sending RST_STREAM). It ensures that isc__nmsocket_prep_destroy() will be called for an HTTP/2 stream, allowing it to be properly disposed. The problem was impossible to reproduce using dig or DoH benchmarking software (e.g. flamethrower) because these do not tend to end HTTP/2 streams prematurely. --- lib/isc/netmgr/http.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index fe495b5db3..fe9f73bd70 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -611,6 +611,22 @@ on_server_stream_close_callback(int32_t stream_id, ISC_LIST_UNLINK(session->sstreams, &sock->h2, link); session->nsstreams--; + + /* + * By making a call to isc__nmsocket_prep_destroy(), we ensure that + * the socket gets marked as inactive, allowing the HTTP/2 data + * associated with it to be properly disposed of eventually. + * + * An HTTP/2 stream socket will normally be marked as inactive in + * the normal course of operation. However, when browsers terminate + * HTTP/2 streams prematurely (e.g. by sending RST_STREAM), + * corresponding sockets can remain marked as active, retaining + * references to the HTTP/2 data (most notably the session objects), + * preventing them from being correctly freed and leading to BIND + * hanging on shutdown. Calling isc__nmsocket_prep_destroy() + * ensures that this will not happen. + */ + isc__nmsocket_prep_destroy(sock); isc__nmsocket_detach(&sock); return (rv); }