]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Do not stop timer in isc_nm_read_stop() in manual timer mode
authorArtem Boldariev <artem@isc.org>
Tue, 16 Jul 2024 13:38:56 +0000 (16:38 +0300)
committerAndoni Duarte Pintado <andoni@isc.org>
Wed, 15 Jan 2025 15:05:56 +0000 (16:05 +0100)
A call to isc_nm_read_stop() would always stop reading timer even in
manual timer control mode which was added with StreamDNS in mind. That
looks like an omission that happened due to how timers are controlled
in StreamDNS where we always stop the timer before pausing reading
anyway (see streamdns_on_complete_dnsmessage()). That would not work
well for HTTP, though, where we might want pause reading without
stopping the timer in the case we want to split incoming data into
multiple chunks to be processed independently.

I suppose that it happened due to NM refactoring in the middle of
StreamDNS development (at the time isc_nm_cancelread() and
isc_nm_pauseread() were removed), as the StreamDNS code seems to be
written as if timers are not stoping during a call to
isc_nm_read_stop().

(cherry picked from commit 4ae4e255cf0aef16d9b1b462e08ff7237352393e)

lib/isc/netmgr/proxystream.c
lib/isc/netmgr/streamdns.c
lib/isc/netmgr/tcp.c
lib/isc/netmgr/tlsstream.c

index 883e8cf9428bde5389845898952063b5f993b91d..8d65ea544480042bbaacbcff76983a8fa168f16c 100644 (file)
@@ -121,6 +121,7 @@ proxystream_on_header_data_cb(const isc_result_t result,
                 * the case of TCP it is disabled by default
                 */
                proxystream_read_stop(sock);
+               isc__nmsocket_timer_stop(sock);
                isc__nmhandle_set_manual_timer(sock->outerhandle, false);
 
                sock->proxy.header_processed = true;
@@ -775,6 +776,7 @@ isc__nm_proxystream_close(isc_nmsocket_t *sock) {
         * external references, we can close everything.
         */
        proxystream_read_stop(sock);
+       isc__nmsocket_timer_stop(sock);
        if (sock->outerhandle != NULL) {
                sock->reading = false;
                isc_nm_read_stop(sock->outerhandle);
index 30b39039861a96e77b0259383ae442e2a005601d..c80b2285c901d0542309166b9c44b1efe966b3dd 100644 (file)
@@ -1009,6 +1009,7 @@ streamdns_close_direct(isc_nmsocket_t *sock) {
 
        if (sock->outerhandle != NULL) {
                sock->streamdns.reading = false;
+               isc__nmsocket_timer_stop(sock);
                isc_nm_read_stop(sock->outerhandle);
                isc_nmhandle_close(sock->outerhandle);
                isc_nmhandle_detach(&sock->outerhandle);
index dc8bc960de32337f405b10e2e409d3beaba9ebca..0ddbef56e21a60d85109e633dcec898d19914c25 100644 (file)
@@ -722,7 +722,9 @@ isc__nm_tcp_read_stop(isc_nmhandle_t *handle) {
 
        isc_nmsocket_t *sock = handle->sock;
 
-       isc__nmsocket_timer_stop(sock);
+       if (!sock->manual_read_timer) {
+               isc__nmsocket_timer_stop(sock);
+       }
        isc__nm_stop_reading(sock);
        sock->reading = false;
 
index c599600f10fc03a5e97c1c402466119e4b47ff2a..8d5fe1fd377320cf9e77123bb576d815b480c49b 100644 (file)
@@ -465,6 +465,7 @@ tls_try_handshake(isc_nmsocket_t *sock, isc_result_t *presult) {
 
                isc__nmsocket_log_tls_session_reuse(sock, sock->tlsstream.tls);
                tlshandle = isc__nmhandle_get(sock, &sock->peer, &sock->iface);
+               isc__nmsocket_timer_stop(sock);
                tls_read_stop(sock);
 
                if (isc__nm_closing(sock->worker)) {
@@ -1154,6 +1155,10 @@ isc__nm_tls_read_stop(isc_nmhandle_t *handle) {
 
        handle->sock->reading = false;
 
+       if (!handle->sock->manual_read_timer) {
+               isc__nmsocket_timer_stop(handle->sock);
+       }
+
        tls_read_stop(handle->sock);
 }
 
@@ -1174,6 +1179,7 @@ isc__nm_tls_close(isc_nmsocket_t *sock) {
         */
        tls_read_stop(sock);
        if (sock->outerhandle != NULL) {
+               isc__nmsocket_timer_stop(sock);
                isc_nm_read_stop(sock->outerhandle);
                isc_nmhandle_close(sock->outerhandle);
                isc_nmhandle_detach(&sock->outerhandle);