Relays: buffers let go while spliced on a connection's last mapping

sockmap() of fibers and threads kept both buffers for as long as it
mapped, even with a direction spliced. On a connection's last mapping
(maptail set), as the callbacks already do, a direction spliced lets its
empty buffer go: bufdrop(), shared with the callbacks now. It is made
again before a read into it, back to copying or draining what TLS held,
and both are there again once sockmap() returns, for whatever comes
after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-27 18:37:52 +03:00
1 parent 1201031404
commit cbc7245925
4 files changed
+28 -7

No files matched your search

+14
View File
@@ -102,6 +102,20 @@ void buffree(struct clientparam * param){
param->clibufdata = param->srvbufdata = NULL;
}
/* An empty own buffer let go, while the connection's last mapping has
no use for it, its direction spliced; bufget() makes it again. */
void bufdrop(struct clientparam * param, DIRECTION which){
unsigned char **own = which? &param->srvbufdata : &param->clibufdata;
unsigned char **buf = which? &param->srvbuf : &param->clibuf;
unsigned *in = which? &param->srvinbuf : &param->cliinbuf;
unsigned *off = which? &param->srvoffset : &param->clioffset;
if(!*own || *buf != *own || *in != *off) return;
free(*own);
*own = *buf = NULL;
*in = *off = 0;
}
/* Starts an empty buffer over from its beginning, and goes back to the
connection's own buffer if a filter needed a bigger one. Does nothing
while anything is left unread. */