From 36c59ff375ea2399961df54403676e8e8457f4b6 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 22 Nov 2015 02:12:52 +0100
Subject: Enable TCP_NODELAY
---
common.c | 1 +
degesch.c | 6 ++++++
kike.c | 7 +++++++
3 files changed, 14 insertions(+)
diff --git a/common.c b/common.c
index 43e53b9..da937a1 100644
--- a/common.c
+++ b/common.c
@@ -33,6 +33,7 @@
#include
#include
#include
+#include
/// Shorthand to set an error and return failure from the function
#define FAIL(...) \
diff --git a/degesch.c b/degesch.c
index 80e3d2c..bc70a7a 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4732,6 +4732,12 @@ irc_finish_connection (struct server *s, int socket)
{
struct app_context *ctx = s->ctx;
+ // Most of our output comes from the user one full command at a time and we
+ // use output buffering, so it makes a lot of sense to avoid these delays
+ int yes = 1;
+ soft_assert (setsockopt (socket, IPPROTO_TCP, TCP_NODELAY,
+ &yes, sizeof yes) != -1);
+
set_blocking (socket, false);
s->socket = socket;
s->transport = get_config_boolean (s->config, "tls")
diff --git a/kike.c b/kike.c
index 4fabced..6cc3bcb 100644
--- a/kike.c
+++ b/kike.c
@@ -3421,6 +3421,13 @@ irc_try_fetch_client (struct server_context *ctx, int listen_fd)
c->ping_timer.dispatcher = on_client_ping_timer;
c->ping_timer.user_data = c;
+ // A little bit questionable once the traffic gets high enough (IMO),
+ // but it reduces silly latencies that we don't need because we already
+ // do buffer our output
+ int yes = 1;
+ soft_assert (setsockopt (fd, IPPROTO_TCP, TCP_NODELAY,
+ &yes, sizeof yes) != -1);
+
set_blocking (fd, false);
client_update_poller (c, NULL);
client_set_kill_timer (c);
--
cgit v1.2.3-70-g09d2