]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add net_set_tcp_quickack()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 6 Nov 2019 12:36:58 +0000 (14:36 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 12 Nov 2019 07:30:50 +0000 (07:30 +0000)
src/lib/net.c
src/lib/net.h

index 25645c39bb9b8ef8a6023137587be99efc44d163..7eeed6319fbf7902794e5fa0fb47cc452ff69883 100644 (file)
@@ -366,6 +366,18 @@ int net_set_tcp_nodelay(int fd, bool nodelay)
        return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
 }
 
+int net_set_tcp_quickack(int fd, bool quickack)
+{
+#ifdef TCP_QUICKACK
+       int val = quickack;
+
+       return setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &val, sizeof(val));
+#else
+       errno = ENOPROTOOPT;
+       return -1;
+#endif
+}
+
 int net_set_send_buffer_size(int fd, size_t size)
 {
        int opt;
index 84d2f45b017d5af68c079db60f0455eb08b08571..7f8abb7181315da2dfc794c392998bcbc0a19ef3 100644 (file)
@@ -98,6 +98,10 @@ void net_set_nonblock(int fd, bool nonblock);
 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 TCP_QUICKACK, which tells the kernel to not delay ACKs. Note that the
+   kernel can (and will) re-enable delayed ACKs while processing the TCP stack.
+   This means that this function needs to be called repeatedly. */
+int net_set_tcp_quickack(int fd, bool quickack);
 
 /* Set socket kernel buffer sizes */
 int net_set_send_buffer_size(int fd, size_t size);