]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Throttle the reading when writes are asynchronous
authorOndřej Surý <ondrej@isc.org>
Tue, 2 Jul 2024 18:17:49 +0000 (20:17 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 3 Jul 2024 06:45:39 +0000 (08:45 +0200)
Be more aggressive when throttling the reading - when we can't send the
outgoing TCP synchronously with uv_try_write(), we start throttling the
reading immediately instead of waiting for the send buffers to fill up.

This should not affect behaved clients that read the data from the TCP
on the other end.

lib/isc/netmgr/tcp.c

index 71eee4a2d9cf40c2ca90ed5c10395630a790cafa..c6bb2812ffa8036de708161044a6d42fef9be980 100644 (file)
@@ -1145,6 +1145,13 @@ tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
                }
        }
 
+       isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_NETMGR,
+                     ISC_LOG_DEBUG(3),
+                     "throttling TCP connection, the other side is not "
+                     "reading the data, switching to uv_write()");
+       sock->reading_throttled = true;
+       isc__nm_stop_reading(sock);
+
        r = uv_write(&req->uv_req.write, &sock->uv_handle.stream, bufs, nbufs,
                     tcp_send_cb);
        if (r < 0) {