Relays: no buffers made again after a connection's last mapping

sockmap() made both buffers again as it returned, for whatever came
after it, and the callbacks before the end: after the last mapping there
is only the end, the log line and a refusal sent from a buffer of its
own, with no use for them. They are made again only for a mapping that
is not the last, and for a fiber mapping on after a reload; the
functions reading a side's buffer make it if it is not there, and a
worker taken from the pool for its next connection gets its own again.

proxy.c's other last mappings, a CONNECT through a parent and an answer
ending as the server closes, are marked so too (maplast(), proxytail),
as the CONNECT of its own was: their end, and with callbacks the fiber,
is the loop's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-27 19:12:49 +03:00
1 parent f991edbb3a
commit f2cc447f73
5 files changed
+53 -27

No files matched your search

+7 -1
View File
@@ -173,6 +173,8 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
return (int)param->clibuf[param->clioffset++];
}
if(param->climark == -2) return EOF; /* nothing more until it is cleared */
/* let go on a connection's last mapping */
if(!param->clibuf && bufget(param, CLIENT)) return EOF;
if(param->climark >= 0){
/* what was read since the mark stays, moved to the start */
keep = param->cliinbuf - (unsigned)param->climark;
@@ -197,13 +199,16 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
buffer, at the end of the stream, or when nothing comes in time; returns
how much is there, at most size. */
unsigned long sockfillbuf(struct clientparam * param, DIRECTION which, unsigned long size, int timeosec){
unsigned char *buf = which? param->srvbuf : param->clibuf;
unsigned char *buf;
unsigned *inbuf = which? &param->srvinbuf : &param->cliinbuf;
unsigned *offset = which? &param->srvoffset : &param->clioffset;
unsigned bufsize = which? param->srvbufsize : param->clibufsize;
unsigned want;
int len;
/* let go on a connection's last mapping */
if(!(which? param->srvbuf : param->clibuf) && bufget(param, which)) return 0;
buf = which? param->srvbuf : param->clibuf;
if(*offset){
memmove(buf, buf + *offset, *inbuf - *offset);
*inbuf -= *offset;
@@ -232,6 +237,7 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){
return (int)param->srvbuf[param->srvoffset++];
}
bufrelease(param, SERVER);
if(!param->srvbuf && bufget(param, SERVER)) return EOF;
if ((len = sockrecvfrom(param, param->remsock, (struct sockaddr *)&param->sinsr, param->srvbuf, param->srvbufsize, timeosec*1000 + timeousec))<=0) return EOF;
param->srvinbuf = len;
param->srvoffset = 1;