From: Stephan Bosch Date: Thu, 16 Jun 2016 20:01:06 +0000 (+0200) Subject: lib: Created net_set_tcp_nodelay(), which enables the TCP_NODELAY socket option. X-Git-Tag: 2.3.0.rc1~3489 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2dca65ba6192532de99e668cd68ccf6015e77788;p=thirdparty%2Fdovecot%2Fcore.git lib: Created net_set_tcp_nodelay(), which enables the TCP_NODELAY socket option. This disables the TCP Nagle algorithm. --- diff --git a/src/lib/net.c b/src/lib/net.c index 9aea155617..da43a307d6 100644 --- a/src/lib/net.c +++ b/src/lib/net.c @@ -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; diff --git a/src/lib/net.h b/src/lib/net.h index 3b0c9c7684..07fa69de1f 100644 --- a/src/lib/net.h +++ b/src/lib/net.h @@ -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);