]> 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 <andoni@isc.org>
Wed, 15 Jan 2025 14:09:17 +0000 (14:09 +0000)
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().

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 ca3ed8b7f4f279066143173661110ad31de0ca09..4f98b508623f3871f2038ce85a0662abcb6becc5 100644 (file)
@@ -759,7 +759,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);