[vlc-commits] tls: disable the Nagle algorithm

Rémi Denis-Courmont git at videolan.org
Sun Mar 5 11:59:36 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar  5 12:58:20 2017 +0200| [e5aa35282c550f57524a88951040416148f7355e] | committer: Rémi Denis-Courmont

tls: disable the Nagle algorithm

Users of vlc_tls_t coalesce sends in user-space correctly. That being
the case, the Nagle algorithm just increases latency for no benefits.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e5aa35282c550f57524a88951040416148f7355e
---

 configure.ac      | 2 +-
 src/network/tls.c | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index a1ef955..ad4586a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -817,7 +817,7 @@ AC_CHECK_HEADER([syslog.h], [have_syslog="yes"], [have_syslog="no"])
 AM_CONDITIONAL([HAVE_SYSLOG], [test "$have_syslog" = "yes"])
 
 dnl  BSD
-AC_CHECK_HEADERS([netinet/udplite.h sys/param.h sys/mount.h])
+AC_CHECK_HEADERS([netinet/tcp.h netinet/udplite.h sys/param.h sys/mount.h])
 
 dnl  GNU/Linux
 AC_CHECK_HEADERS([features.h getopt.h linux/dccp.h linux/magic.h mntent.h sys/eventfd.h])
diff --git a/src/network/tls.c b/src/network/tls.c
index d7962ad..3210cfe 100644
--- a/src/network/tls.c
+++ b/src/network/tls.c
@@ -39,6 +39,12 @@
 #ifdef HAVE_SYS_UIO_H
 # include <sys/uio.h>
 #endif
+#ifdef HAVE_NETINET_TCP_H
+# include <netinet/tcp.h>
+#endif
+#ifndef SOL_TCP
+# define SOL_TCP IPPROTO_TCP
+#endif
 
 #include <vlc_common.h>
 #include "libvlc.h"
@@ -434,6 +440,9 @@ static vlc_tls_t *vlc_tls_SocketAddrInfo(const struct addrinfo *restrict info)
 
     setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int));
 
+    if (info->ai_socktype == SOCK_STREAM && info->ai_protocol == IPPROTO_TCP)
+        setsockopt(fd, SOL_TCP, TCP_NODELAY, &(int){ 1 }, sizeof (int));
+
     vlc_tls_t *sk = vlc_tls_SocketAlloc(fd, info->ai_addr, info->ai_addrlen);
     if (unlikely(sk == NULL))
         net_Close(fd);



More information about the vlc-commits mailing list