]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Fuzzy TCP: enable TCP_NODELAY for reduced latency
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 8 Oct 2025 09:54:56 +0000 (10:54 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 8 Oct 2025 09:54:56 +0000 (10:54 +0100)
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

index aad5ae34364b50b432b67e547d433938c8045e48..d11339feb93c4e2363dc88d84b3fe91b97b1ab4b 100644 (file)
@@ -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;