From: Steven Hartland Date: Sun, 10 Apr 2016 01:30:51 +0000 (+0000) Subject: Disable nagel algorithm X-Git-Tag: v1.6.0~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F706%2Fhead;p=thirdparty%2Frrdtool-1.x.git Disable nagel algorithm Disable TCP's nagal algorithm which was causing massive slowdown in processing rrdcached requests. Also check for other setsockopt call errors. --- diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index a574bde9..ffdcfe51 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -78,6 +78,8 @@ #include #include #include +#include +#include #include #else @@ -3457,12 +3459,30 @@ static int open_listen_socket_network(const listen_socket_t *sock) /* {{{ */ continue; } - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + status = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + if (status != 0) { + fprintf(stderr, "rrdcached: setsockopt(SO_REUSEADDR) failed: %s\n", + rrd_strerror(errno)); + return (-1); + } + /* Nagle will cause significant delay in processing requests so + * disable it. */ + status = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); + if (status != 0) { + fprintf(stderr, "rrdcached: setsockopt(TCP_NODELAY) failed: %s\n", + rrd_strerror(errno)); + return (-1); + } #ifdef IPV6_V6ONLY /* Prevent EADDRINUSE bind errors on dual-stack configurations * with IPv4-mapped-on-IPv6 enabled */ if (AF_INET6 == ai_ptr->ai_family) - setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)); + status = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)); + if (status != 0) { + fprintf(stderr, "rrdcached: setsockopt(IPV6_V6ONLY) failed: %s\n", + rrd_strerror(errno)); + return (-1); + } #endif /* IPV6_V6ONLY */ status = bind (fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);