]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Extend isc__nm_socket_tcp_nodelay() to accept value
authorArtem Boldariev <artem@boldariev.com>
Thu, 25 Aug 2022 18:59:23 +0000 (21:59 +0300)
committerArtem Boldariev <artem@boldariev.com>
Tue, 20 Dec 2022 20:13:53 +0000 (22:13 +0200)
This makes it possible to both enable and disable Nagle's algorithm
for a TCP socket descriptor, before the change it was possible only to
disable it.

lib/isc/netmgr/http.c
lib/isc/netmgr/netmgr-int.h
lib/isc/netmgr/socket.c

index 962a5b4386c6cbca04cace5f772e1659c2575d9b..c6f7eed961ff925ea650e43a351a317c112f3906 100644 (file)
@@ -2434,7 +2434,7 @@ http_transpost_tcp_nodelay(isc_nmhandle_t *transphandle) {
 
        (void)uv_fileno((uv_handle_t *)&tcpsock->uv_handle.tcp, &tcp_fd);
        RUNTIME_CHECK(tcp_fd != (uv_os_fd_t)-1);
-       (void)isc__nm_socket_tcp_nodelay((uv_os_sock_t)tcp_fd);
+       (void)isc__nm_socket_tcp_nodelay((uv_os_sock_t)tcp_fd, true);
 }
 
 static isc_result_t
index 807bd151a88ddb31e4f4ee175965604aa3457c64..1c229d314abf968c00fc0b4d2b120e4130150f48 100644 (file)
@@ -1861,9 +1861,10 @@ isc__nm_socket_connectiontimeout(uv_os_sock_t fd, int timeout_ms);
  */
 
 isc_result_t
-isc__nm_socket_tcp_nodelay(uv_os_sock_t fd);
+isc__nm_socket_tcp_nodelay(const uv_os_sock_t fd, bool value);
 /*%<
- * Disables Nagle's algorithm on a TCP socket (sets TCP_NODELAY).
+ * Disables/Enables Nagle's algorithm on a TCP socket (sets TCP_NODELAY if
+ * 'value' equals 'true' or vice versa).
  */
 
 isc_result_t
index b2dce27805e2357c32ec5cbb05547cd943f7bb5f..fc9b3ce880ac626404cabb40873c994d73602a95 100644 (file)
@@ -327,9 +327,17 @@ isc__nm_socket_connectiontimeout(uv_os_sock_t fd, int timeout_ms) {
 }
 
 isc_result_t
-isc__nm_socket_tcp_nodelay(uv_os_sock_t fd) {
+isc__nm_socket_tcp_nodelay(uv_os_sock_t fd, bool value) {
 #ifdef TCP_NODELAY
-       if (setsockopt_on(fd, IPPROTO_TCP, TCP_NODELAY) == -1) {
+       int ret;
+
+       if (value) {
+               ret = setsockopt_on(fd, IPPROTO_TCP, TCP_NODELAY);
+       } else {
+               ret = setsockopt_off(fd, IPPROTO_TCP, TCP_NODELAY);
+       }
+
+       if (ret == -1) {
                return (ISC_R_FAILURE);
        } else {
                return (ISC_R_SUCCESS);