Disable Nagle in iprop master and slave
authorViktor Dukhovni <viktor@twosigma.com>
Sat, 21 Sep 2019 22:29:12 +0000 (18:29 -0400)
committerNico Williams <nico@cryptonector.com>
Thu, 3 Oct 2019 20:52:15 +0000 (15:52 -0500)
configure.ac
include/config.h.w32
lib/kadm5/ipropd_master.c
lib/kadm5/ipropd_slave.c
lib/kadm5/kadm5_locl.h

index e7611d2de99d277be512c9cec33656f7015c765a..d07fd8a016b57e97c78b2d3cd85da2f9d0c808ed 100644 (file)
@@ -355,6 +355,7 @@ AC_CHECK_HEADERS([\
        maillock.h                              \
        netgroup.h                              \
        netinet/in6_machtypes.h                 \
+       netinet/tcp.h                           \
        pthread.h                               \
        pty.h                                   \
        sac.h                                   \
index 0d6e6a3ef55feb8293144e240af1fc3940e18367..c6c71d53746785c1987ce98abbf219de59571e7f 100644 (file)
@@ -653,6 +653,9 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
 /* Define to 1 if you have the <netinet/in.h> header file. */
 /* #define HAVE_NETINET_IN_H 1 */
 
+/* Define to 1 if you have the <netinet/tcp.h> header file. */
+/* #define HAVE_NETINET_TCP_H 1 */
+
 /* Define to 1 if you have the <netinet/in_systm.h> header file. */
 /* #define HAVE_NETINET_IN_SYSTM_H 1 */
 
index 053d45754ec021ac2d244f397b34d7448e0bd222..8639af66e92f20bc96b4b0dba68e3501e3a0f5f9 100644 (file)
@@ -319,6 +319,20 @@ add_slave (krb5_context context, krb5_keytab keytab, slave **root,
      * own krb5_recvauth().
      */
     socket_set_nonblocking(s->fd, 1);
+
+    /*
+     * We write message lengths separately from the payload, and may do
+     * back-to-back small writes when flushing pending input and then a new
+     * update.  Avoid Nagle delays.
+     */
+#if defined(IPPROTO_TCP) && defined(TCP_NODELAY)
+    {
+        int nodelay = 1;
+        (void) setsockopt(s->fd, IPPROTO_TCP, TCP_NODELAY,
+                          (void *)&nodelay, sizeof(nodelay));
+    }
+#endif
+
     krb5_free_principal (context, server);
     if (ret) {
        krb5_warn (context, ret, "krb5_recvauth");
index 9f0b38d0af2f0fce2006af503b7b8597c71bf4d3..933ce32e33dba865558990349c50980744474a9f 100644 (file)
@@ -99,6 +99,15 @@ connect_to_master (krb5_context context, const char *master,
     if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one)) < 0)
         krb5_warn(context, errno, "setsockopt(SO_KEEPALIVE) failed");
 
+    /*
+     * We write message lengths separately from the payload, avoid Nagle
+     * delays.
+     */
+#if defined(IPPROTO_TCP) && defined(TCP_NODELAY)
+    (void) setsockopt(s, IPPROTO_TCP, TCP_NODELAY,
+                      (void *)&one, sizeof(one));
+#endif
+
     return s;
 }
 
index ef5b83ee4894b267c83623e8b0b47f5620cfc1c8..cb0b1b4cb1a065ae3b106436d45ef0d0401fa024 100644 (file)
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_NETINET_TCP_H
+#include <netinet/tcp.h>
+#endif
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif