From c4999f8d625d8e8e898a7675addcb4a8c41ed804 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 8 Oct 2025 10:54:56 +0100 Subject: [PATCH] [Minor] Fuzzy TCP: enable TCP_NODELAY for reduced latency Disables Nagle's algorithm on fuzzy TCP connections to minimize latency for request-response traffic patterns. This prevents small packets from being buffered, which is optimal for the fuzzy check protocol. --- src/plugins/fuzzy_check.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index aad5ae3436..d11339feb9 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -643,6 +643,18 @@ fuzzy_tcp_connect_async(struct fuzzy_rule *rule, return NULL; } + /* Set TCP_NODELAY to disable Nagle's algorithm - reduces latency for request-response traffic */ +#ifdef TCP_NODELAY + { + int nodelay = 1; + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay)) == -1) { + msg_warn_task("fuzzy_tcp: cannot set TCP_NODELAY for %s: %s", + rspamd_inet_address_to_string_pretty(addr), + strerror(errno)); + } + } +#endif + /* Create connection structure */ conn = fuzzy_tcp_connection_new(rule, task->event_loop); conn->fd = fd; -- 2.47.3