Unlike the equivalent change on the client side which caused a
dramatic performance improvement, there is no noticable difference
from this patch in my testing.
---
server/sockets.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/server/sockets.c b/server/sockets.c
index 2c71970..b25405c 100644
--- a/server/sockets.c
+++ b/server/sockets.c
@@ -37,13 +37,15 @@
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
+#include <poll.h>
+#include <errno.h>
+#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
#include <netdb.h>
-#include <poll.h>
-#include <errno.h>
-#include <assert.h>
#ifdef HAVE_LIBSELINUX
#include <selinux/selinux.h>
@@ -273,6 +275,7 @@ accept_connection (int listen_sock)
pthread_t thread;
struct thread_data *thread_data;
static size_t instance_num = 1;
+ const int flag = 1;
thread_data = malloc (sizeof *thread_data);
if (!thread_data) {
@@ -293,6 +296,11 @@ accept_connection (int listen_sock)
return;
}
+ /* Disable Nagle's algorithm on this socket. However we don't want
+ * to fail if this doesn't work.
+ */
+ setsockopt (thread_data->sock, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof flag);
+
/* Start a thread to handle this connection. Note we always do this
* even for non-threaded plugins. There are mutexes in plugins.c
* which ensure that non-threaded plugins are handled correctly.
--
2.21.0