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.
This commit is contained in:
Artem Boldariev
2021-07-02 18:25:17 +03:00
parent 094fcc10e7
commit 7b6945fb60

View 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);
}