]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix BIND hanging when browsers end HTTP/2 streams prematurely
authorArtem Boldariev <artem@boldariev.com>
Fri, 2 Jul 2021 15:25:17 +0000 (18:25 +0300)
committerArtem Boldariev <artem@boldariev.com>
Fri, 9 Jul 2021 12:42:44 +0000 (15:42 +0300)
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

index fe495b5db3ee209d0288ce6bda33582cd625fa16..fe9f73bd70e143b115fd5d8023b25737358e4ebb 100644 (file)
@@ -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);
 }