]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Created net_set_tcp_nodelay(), which enables the TCP_NODELAY socket option.
authorStephan Bosch <stephan@dovecot.fi>
Thu, 16 Jun 2016 20:01:06 +0000 (22:01 +0200)
committerStephan Bosch <stephan@dovecot.fi>
Thu, 16 Jun 2016 20:07:27 +0000 (22:07 +0200)
This disables the TCP Nagle algorithm.

src/lib/net.c
src/lib/net.h

index 9aea155617780be97b9625160f8cc5136b11dfab..da43a307d6f8e802e827fe52f73972604e17cedb 100644 (file)
@@ -351,6 +351,13 @@ int net_set_cork(int fd ATTR_UNUSED, bool cork ATTR_UNUSED)
 #endif
 }
 
+int net_set_tcp_nodelay(int fd, bool nodelay)
+{
+       int val = nodelay;
+
+       return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
+}
+
 int net_set_send_buffer_size(int fd, size_t size)
 {
        int opt;
index 3b0c9c768498ecf5ccf20f16f4c470fb35e3f950..07fa69de1f2215268879b22ff9df4e6448e5347a 100644 (file)
@@ -87,6 +87,8 @@ void net_set_nonblock(int fd, bool nonblock);
 /* Set TCP_CORK if supported, ie. don't send out partial frames.
    Returns 0 if ok, -1 if failed. */
 int net_set_cork(int fd, bool cork) ATTR_NOWARN_UNUSED_RESULT;
+/* Set TCP_NODELAY, which disables the Nagle algorithm. */
+int net_set_tcp_nodelay(int fd, bool nodelay);
 
 /* Set socket kernel buffer sizes */
 int net_set_send_buffer_size(int fd, size_t size);