Event loops: a relayed client's buffers given back while empty

A connection's two data buffers are malloc()'d with it (bufalloc())
instead of being part of struct clientparam, which is CLIENTBUFSIZE*2
smaller. The callbacks' relay of a client whose fiber gave up its stack
frees a side's buffer while it is empty and makes it again to read, and
gives both back before sockmap() or the child's tail goes on: a pool of
idle relayed connections holds no buffers. Fibers and threads keep
theirs as before.

mix scenarios, callbacks (-L -L2), peak memory before/after, throughput
the same:
  Intel: relay 972/632 MB, connect 981/581, socks 992/594
  ARM:   relay 1000/673 MB, connect 1000/615, socks 1020/629

struct clientparam's clibufdata and srvbufdata are pointers now:
plugins built against the old structure are not compatible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-26 23:47:24 +03:00
1 parent 80c3863055
commit 7963494b1c
7 files changed
+96 -6

No files matched your search

+7
View File
@@ -145,6 +145,13 @@ static struct udpsession *udpnew(struct udpstate *st){
return NULL;
}
memset(param, 0, sizeof(*param));
if(bufalloc(param)){
buffree(param);
free(param);
free(ss);
_3proxy_sem_unlock(srv->childslots);
return NULL;
}
memcpy(param, st->u.defparam, offsetof(struct clientparam, filters));
param->clibuf = param->clibufdata;
param->srvbuf = param->srvbufdata;