From 6efb578a1412bae959dd6b1755e2c333eb4e4cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 22 Jun 2017 10:56:18 +0200 Subject: [PATCH] daemon: Set TCP_NODELAY and TCP_QUICKACK on remote sockets. * nix/nix-daemon/nix-daemon.cc (acceptConnection): Set TCP_NODELAY and TCP_QUICKACK on REMOTE. --- nix/nix-daemon/nix-daemon.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index 3d8e909901..b20225b3b0 100644 --- a/nix/nix-daemon/nix-daemon.cc +++ b/nix/nix-daemon/nix-daemon.cc @@ -19,6 +19,9 @@ #include #include #include +#include +#include + #include #include #include @@ -839,6 +842,21 @@ static void acceptConnection(int fdSocket) closeOnExec(remote); + { + int enabled = 1; + + /* If we're on a TCP connection, disable Nagle's algorithm so that + data is sent as soon as possible. */ + (void) setsockopt(remote, SOL_TCP, TCP_NODELAY, + &enabled, sizeof enabled); + +#if defined(TCP_QUICKACK) + /* Enable TCP quick-ack if applicable; this might help a little. */ + (void) setsockopt(remote, SOL_TCP, TCP_QUICKACK, + &enabled, sizeof enabled); +#endif + } + pid_t clientPid = -1; bool trusted = false;