From b00e3b9a9cc37494511912d06082600a80c6fe7d Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Mon, 12 Oct 2026 00:39:06 +0300 Subject: [PATCH] splice() per direction, pipes per connection, automatic mode -s takes the directions to splice: -s1 what the server sends (downloads), -s2 what the client sends (uploads), -s3 both. -s alone (-s7) splices both only where it pays, as -s5 and -s6 do for one direction: - a body of known length is spliced if at least 16K of it is left to read once what is already buffered is counted, so an answer read whole with its headers is just copied; - a stream of unknown length starts copied, is spliced after 2 reads in a row of at least 16K, and goes back to copying after 3 splices in a row of less than 4K, once its pipe is empty. Pipes are made when a direction first splices and kept with the connection for its next mappings, so a kept-alive connection no longer makes and closes two pipes per request; one left holding data by an error or a timeout is closed. The direction not spliced keeps its buffer. Before, -s spliced both directions and every mapping made both pipes, which made small answers slower than without splice: with kept-alive 50K answers 2 pipe2() and 4 close() per request, now none. Also corrects the default buffer size in the -b help (65536 for TCP). Co-Authored-By: Claude Opus 5.5 --- doc/html/highload.html | 13 ++- man/3proxy.cfg.5 | 17 ++-- src/proxy.h | 7 +- src/proxymain.c | 17 +++- src/sockmap.c | 190 +++++++++++++++++++++++++++++------------ src/structures.h | 5 ++ 6 files changed, 179 insertions(+), 70 deletions(-) diff --git a/doc/html/highload.html b/doc/html/highload.html index c2b1be7..aa182c3 100644 --- a/doc/html/highload.html +++ b/doc/html/highload.html @@ -34,7 +34,7 @@ Each connected client requires: