]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
TCP: make it possible to set Nagle's algorithms state via handle
authorArtem Boldariev <artem@boldariev.com>
Thu, 25 Aug 2022 19:18:15 +0000 (22:18 +0300)
committerArtem Boldariev <artem@boldariev.com>
Tue, 20 Dec 2022 20:13:53 +0000 (22:13 +0200)
This commit adds ability to turn the Nagle's algorithm on or off via
connections handle. It adds the isc_nmhandle_set_tcp_nodelay()
function as the public interface for this functionality.

lib/isc/include/isc/netmgr.h
lib/isc/netmgr/netmgr.c

index 729012ac6342c42b10d97e6ece0239b246394ac6..3f0e90d8085a5bbe6fea7cede7c229f174eec875 100644 (file)
@@ -744,3 +744,15 @@ isc_nm_timer_start(isc_nm_timer_t *, uint64_t);
 
 void
 isc_nm_timer_stop(isc_nm_timer_t *);
+
+isc_result_t
+isc_nmhandle_set_tcp_nodelay(isc_nmhandle_t *handle, const bool value);
+/*%<
+ * Disables/Enables Nagle's algorithm on a TCP socket for a
+ * transport backed by TCP (sets TCP_NODELAY if 'value' equals 'true'
+ * or vice versa).
+ *
+ * Requires:
+ *
+ * \li 'handle' is a valid netmgr handle object.
+ */
index 9fdf77a96ada9a71cbda285e434af0d823fa8eae..1cd09c1c48bbe0819aa60391560c29f04668fb45 100644 (file)
@@ -3013,6 +3013,31 @@ isc__nmhandle_get_selected_alpn(isc_nmhandle_t *handle,
        };
 }
 
+isc_result_t
+isc_nmhandle_set_tcp_nodelay(isc_nmhandle_t *handle, const bool value) {
+       isc_result_t result = ISC_R_FAILURE;
+       isc_nmsocket_t *sock;
+
+       REQUIRE(VALID_NMHANDLE(handle));
+       sock = handle->sock;
+       REQUIRE(VALID_NMSOCK(sock));
+
+       switch (sock->type) {
+       case isc_nm_tcpsocket: {
+               uv_os_fd_t tcp_fd = (uv_os_fd_t)-1;
+               (void)uv_fileno((uv_handle_t *)&sock->uv_handle.tcp, &tcp_fd);
+               RUNTIME_CHECK(tcp_fd != (uv_os_fd_t)-1);
+               result = isc__nm_socket_tcp_nodelay((uv_os_sock_t)tcp_fd,
+                                                   value);
+       } break;
+       default:
+               UNREACHABLE();
+               break;
+       };
+
+       return (result);
+}
+
 #ifdef NETMGR_TRACE
 /*
  * Dump all active sockets in netmgr. We output to stderr