From: Vsevolod Stakhov Date: Wed, 8 Oct 2025 09:54:56 +0000 (+0100) Subject: [Minor] Fuzzy TCP: enable TCP_NODELAY for reduced latency X-Git-Tag: 3.14.0~84^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4999f8d625d8e8e898a7675addcb4a8c41ed804;p=thirdparty%2Frspamd.git [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. --- 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;