From: Timo Sirainen Date: Wed, 6 Nov 2019 12:36:58 +0000 (+0200) Subject: lib: Add net_set_tcp_quickack() X-Git-Tag: 2.3.10~309 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3a3b210da852cb6e2a51d2759f0a58401c7270d;p=thirdparty%2Fdovecot%2Fcore.git lib: Add net_set_tcp_quickack() --- diff --git a/src/lib/net.c b/src/lib/net.c index 25645c39bb..7eeed6319f 100644 --- a/src/lib/net.c +++ b/src/lib/net.c @@ -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; diff --git a/src/lib/net.h b/src/lib/net.h index 84d2f45b01..7f8abb7181 100644 --- a/src/lib/net.h +++ b/src/lib/net.h @@ -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);