aboutsummaryrefslogtreecommitdiffstats
path: root/src/tipideed/stream.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-03-22 18:34:44 +0000
committerLaurent Bercot <ska@appnovation.com>2025-03-22 18:34:44 +0000
commita003745deaf4a84c173dd5625a4d22e6d4f6c405 (patch)
treedb780978b54ade4938c68fd5da3950ef21da7154 /src/tipideed/stream.c
parentbfdd8182f9a098d400c83fd43c70cbb2ccc94264 (diff)
downloadtipidee-a003745deaf4a84c173dd5625a4d22e6d4f6c405.tar.gz
Make sure to flush before stream_fixed
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tipideed/stream.c')
-rw-r--r--src/tipideed/stream.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/tipideed/stream.c b/src/tipideed/stream.c
index c391631..b4d9237 100644
--- a/src/tipideed/stream.c
+++ b/src/tipideed/stream.c
@@ -88,21 +88,20 @@ void stream_fixed (int fd, size_t n, char const *fn)
tain deadline ;
struct iovec v[2] ;
size_t r ;
- if (!n) goto flushit ;
- fillit:
- buffer_wpeek(buffer_1, v) ;
- siovec_trunc(v, 2, n) ;
- tain_add_g(&deadline, &g.cgitto) ;
- r = timed_readv_g(fd, v, 2, &deadline) ;
- if (r == -1) strerr_diefu2sys(111, "read from resource ", fn) ;
- if (!r) strerr_dief3x(111, "resource ", fn, " provided less content than advertised in Content-Length") ;
- buffer_wseek(buffer_1, r) ;
- n -= r ;
- flushit:
- tain_add_g(&deadline, &g.writetto) ;
- if (!buffer_timed_flush_g(buffer_1, &deadline))
- strerr_diefu1sys(111, "write to stdout") ;
- if (n) goto fillit ;
+ while (n)
+ {
+ buffer_wpeek(buffer_1, v) ;
+ siovec_trunc(v, 2, n) ;
+ tain_add_g(&deadline, &g.cgitto) ;
+ r = timed_readv_g(fd, v, 2, &deadline) ;
+ if (r == -1) strerr_diefu2sys(111, "read from resource ", fn) ;
+ if (!r) strerr_dief3x(111, "resource ", fn, " provided less content than advertised in Content-Length") ;
+ buffer_wseek(buffer_1, r) ;
+ n -= r ;
+ tain_add_g(&deadline, &g.writetto) ;
+ if (!buffer_timed_flush_g(buffer_1, &deadline))
+ strerr_diefu1sys(111, "write to stdout") ;
+ }
}
void stream_infinite (int fd, char const *fn)