From 9b7bda5da21b5301b321292927b335f0a7fa2585 Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Tue, 27 Oct 2026 18:38:02 +0300 Subject: [PATCH] HTTP proxy: no buffers held while waiting for the next request A connection kept alive waited for its next request holding both of its buffers, empty: most of the memory of an HTTP proxy under load. They are let go before the wait and made again as something comes, but for a request httpsrv keeps there to hand over. Co-Authored-By: Claude Opus 5.5 --- src/proxy.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/proxy.c b/src/proxy.c index 8b20172..d453ee7 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -611,10 +611,18 @@ for(;;){ fds[0].events = POLLIN; fds[1].fd = param->remsock; fds[1].events = POLLIN; + /* a connection waiting for its next request holds no buffer while it + waits, but for a request kept by httpsrv: they are made again as it + comes */ + if(param->climark < 0){ + bufdrop(param, CLIENT); + bufdrop(param, SERVER); + } res = sockpoll(¶m->srv->so, param->sostate, fds, 2, param->srv->timeouts[STRING_S]*1000); if(res<=0) { RETURN(555); } + if(bufalloc(param)) RETURN(21); if((fds[1].revents & (POLLIN|POLLHUP|POLLERR|POLLNVAL)) && sockreadable(param->remsock)) { if(param->transparent || (!param->redirected && param->redirtype == R_HTTP)) RETURN(555); ckeepalive = 0;