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 <noreply@anthropic.com>
This commit is contained in:
Vladimir Dubrovin 2026-10-27 18:38:02 +03:00
parent cbc7245925
commit 9b7bda5da2

View File

@ -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(&param->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;