Event loops: the callbacks' pipes emptied before sockmap() takes over

On a reload the relay of the callbacks gives the connection back to
sockmap(), which knows nothing of what its pipes hold, nor of how much
of a body of known length has already gone through: what was in a pipe
would have come out of order, and the whole length of a body been read
again, into what follows it. The pipes are emptied first, the relay
going on meanwhile, and the length left of a body is the one sockmap()
is given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir Dubrovin 2026-10-25 21:27:21 +03:00
parent f486242638
commit e0a6932704

View File

@ -604,8 +604,14 @@ static int cbmaprun(struct cbmap *m){
int round, moved = 0;
/* a reload: sockmap() takes the connection back, which has it go by
the newest configuration's rules, or ends it */
if(param->version < runconf->version) return cbmapend(m, -2);
the newest configuration's rules, or ends it. It knows nothing of
what the pipes hold: they are emptied first. What is left of a body
is what it is to move. */
if(param->version < runconf->version && !m->way[0].inpipe && !m->way[1].inpipe){
if(param->waitclient64) param->waitclient64 = m->way[0].left;
if(param->waitserver64) param->waitserver64 = m->way[1].left;
return cbmapend(m, -2);
}
for(round = 0; round < CBROUNDS; round++){
int progress = cbway(m, &m->way[0]) | cbway(m, &m->way[1]);
int end = !m->halfclose && (m->term_r[0] || m->term_r[1]);