Mercurial > dovecot > core-2.2
changeset 21041:13a159cfd232
lib: Created net_set_tcp_nodelay(), which enables the TCP_NODELAY socket option.
This disables the TCP Nagle algorithm.
author | Stephan Bosch <stephan@dovecot.fi> |
---|---|
date | Thu, 16 Jun 2016 22:01:06 +0200 |
parents | 9b04af4cbe62 |
children | 770b5fe8cc16 |
files | src/lib/net.c src/lib/net.h |
diffstat | 2 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/net.c Mon May 23 02:36:10 2016 +0200 +++ b/src/lib/net.c Thu Jun 16 22:01:06 2016 +0200 @@ -376,6 +376,13 @@ #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;
--- a/src/lib/net.h Mon May 23 02:36:10 2016 +0200 +++ b/src/lib/net.h Thu Jun 16 22:01:06 2016 +0200 @@ -92,6 +92,8 @@ /* 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);