Event loops: the callbacks' relay splices again

A way with no length to keep to (CBALL) was counted down as data was
written, so the check for it failed after the first write: the run of
large reads that switches to splice() never got past one, and a stream
was copied all along. Not counted down any more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir Dubrovin 2026-10-26 13:14:55 +03:00
parent 5f892b38d8
commit 1b6d4925b3

View File

@ -410,7 +410,7 @@ struct cbway {
uint64_t inpipe; /* what the pipe holds */ uint64_t inpipe; /* what the pipe holds */
}; };
/* left of a way with no length to keep to */ /* left of a way with no length to keep to: not counted down */
#define CBALL 0x7fffffffffffffffULL #define CBALL 0x7fffffffffffffffULL
struct cbmap { struct cbmap {
@ -603,7 +603,7 @@ static int cbway(struct cbmap *m, struct cbway *w){
SPLICE_F_NONBLOCK | SPLICE_F_MOVE); SPLICE_F_NONBLOCK | SPLICE_F_MOVE);
if(n > 0){ if(n > 0){
w->inpipe -= n; w->inpipe -= n;
w->left -= n; if(w->left != CBALL) w->left -= n;
cbcount(m, w, 1, n); cbcount(m, w, 1, n);
progress = 1; progress = 1;
} }
@ -669,7 +669,7 @@ static int cbway(struct cbmap *m, struct cbway *w){
n = sf->_sendto(param->sostate, to, (char *)buf + *offset, (int)CBMIN(inb, w->left), 0, NULL, 0); n = sf->_sendto(param->sostate, to, (char *)buf + *offset, (int)CBMIN(inb, w->left), 0, NULL, 0);
if(n > 0){ if(n > 0){
*offset += n; *offset += n;
w->left -= n; if(w->left != CBALL) w->left -= n;
cbcount(m, w, 1, n); cbcount(m, w, 1, n);
bufrelease(param, w->src? SERVER : CLIENT); bufrelease(param, w->src? SERVER : CLIENT);
progress = 1; progress = 1;