From 7a22821b5870ba543343f0979453298d4acd2ed0 Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Mon, 12 Oct 2026 23:08:18 +0300 Subject: [PATCH] Enable auto mode splice by default --- man/3proxy.cfg.5 | 8 ++++---- src/proxymain.c | 9 +++++---- src/structures.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/man/3proxy.cfg.5 b/man/3proxy.cfg.5 index 34b9e0d..66b4971 100644 --- a/man/3proxy.cfg.5 +++ b/man/3proxy.cfg.5 @@ -208,12 +208,12 @@ it pays: a body of known length if at least 16K of it is left to read, a stream once it carries large reads, back to copying when they turn small. \fB-s1\fR always splices what the server sends to the client (downloads), \fB-s2\fR what the client sends (uploads), \fB-s3\fR both; adding 4 (\fB-s5\fR, \fB-s6\fR, \fB-s7\fR, the last the same as -\fB-s\fR) splices those directions only where it pays. \fB-s0\fR, the default, turns it +\fB-s\fR, and the default) splices those directions only where it pays. \fB-s0\fR turns it off. splice() suits large transfers: they go faster and use less CPU; small requests go slower with it. A spliced direction needs a pipe (two file descriptors), made when first needed and kept for the connection, and more -kernel memory; data filters are not applied to spliced data. Available in builds -with WITHSPLICE, the default on Linux. +kernel memory. A service with data filters does not splice, so that the filters +see all of the data. Available in builds with WITHSPLICE, the default on Linux. .br .B -C (for TCP services) a connection closed by any of the sides terminates the @@ -1458,7 +1458,7 @@ as data filtering will be performed through filtering plugins to avoid data corruption and/or Content-Length changing. A body up to this size is read whole into memory and filtered at once. 0 removes the limit, but then a body -is only filtered whole if it fits in the connection's 32K buffer. +is only filtered whole if it fits in the connection's 16K buffer. Default is 1MB (1048576). .SH SSL/TLS SUPPORT diff --git a/src/proxymain.c b/src/proxymain.c index c81ad32..f33eed9 100644 --- a/src/proxymain.c +++ b/src/proxymain.c @@ -434,8 +434,8 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){ #endif #ifdef WITHSPLICE " -s[N] Use splice(): -s1 server to client, -s2 client to server, -s3 both\n" - " directions; -s (-s7) both, -s5 or -s6 one, only where it pays (large\n" - " transfers) - no filtering for data, off by default\n" + " directions; -s (-s7, the default) both, -s5 or -s6 one, only where it\n" + " pays (large transfers); -s0 never. Not with data filters\n" " -C connection closed by any of the sides terminates the session, by default\n" " the session is kept until both sides close it (TCP half-close)\n" " -U(0-3) (for socks) what to do when the destination changes within an UDP\n" @@ -446,7 +446,7 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){ " -fFORMAT logging format (see documentation)\n" " -l log to stderr\n" " -lFILENAME log to FILENAME\n" - " -b(BUFSIZE) size of network buffer, at most and by default 32768\n" + " -b(BUFSIZE) size of network buffer, at most and by default 16384\n" " -S(STACKSIZE) value to add to default client thread stack size\n" " -t be silent (do not log service start/stop)\n" "\n" @@ -1490,7 +1490,8 @@ void srvinit(struct srvparam * srv, struct clientparam *param){ srv->i_nsfd = srv->o_nsfd = -1; #endif #ifdef WITHSPLICE - srv->usesplice = 0; + /* where it pays: large transfers, -s0 to never */ + srv->usesplice = SPLICE_DOWNLOAD|SPLICE_UPLOAD|SPLICE_AUTO; #endif srv->halfclose = 1; srv->udpauth = 3; diff --git a/src/structures.h b/src/structures.h index e1470d9..56b913f 100644 --- a/src/structures.h +++ b/src/structures.h @@ -199,7 +199,7 @@ int #define MAX_HASH_SIZE (64) #define UDPBUFSIZE 16384 -#define CLIENTBUFSIZE 32768 +#define CLIENTBUFSIZE (16384 + 64) #define CLIENTTMPBUFSIZE 8192 #define HOSTNAMELEN 256 #define USERNAMELEN 128