]> 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 07:10:20 +0000 (09:10 +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.

(cherry picked from commit bc3e713317df838b4bbe6582b357cd8d78e585cd)

lib/isc/netmgr/tcpdns.c
lib/isc/netmgr/tlsdns.c

index d7ec755bec6860d1b6cfb8f62d6cc62889d16c4b..639ff7af0207ad072377dce8c60c49357868ee62 100644 (file)
@@ -1284,6 +1284,13 @@ isc__nm_async_tcpdnssend(isc__networker_t *worker, isc__netievent_t *ev0) {
                goto fail;
        }
 
+       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(&uvreq->uv_req.write, &sock->uv_handle.stream, bufs, nbufs,
                     tcpdns_send_cb);
        if (r < 0) {
index b41c35384242a7cb4d6a30398d350d20781a2502..dbcd34b8ed9ef799378c95085df0d17e3f679fbd 100644 (file)
@@ -1377,6 +1377,14 @@ tls_cycle_output(isc_nmsocket_t *sock) {
                        break;
                }
 
+               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,
                             &req->uvbuf, 1, tls_write_cb);
                if (r < 0) {