sideband: avoid short write(2)
The sideband demultiplexor writes the data it receives on sideband with xwrite(). We can lose data if the underlying write(2) results in a short write. If they are limited to unimportant bytes like eye-candy progress meter, it may be OK to lose them, but lets be careful and ensure that we use write_in_full() instead. Note that the original does not check for errors, and this rewrite does not check for one. At least not yet. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Mar 2, 2024 at 11:03 UTC
36ffba1c7be8d831065adab73a7a215f402ef432
1 file changed
+2
-2
sideband.c
+2
-2
@@ -220,7 +220,7 @@ int demultiplex_sideband(const char *me, int status,
220
}
221
222
strbuf_addch(scratch, *brk);
223
- xwrite(2, scratch->buf, scratch->len);
223
+ write_in_full(2, scratch->buf, scratch->len);
224
strbuf_reset(scratch);
225
226
b = brk + 1;
@@ -247,7 +247,7 @@ cleanup:
247
die("%s", scratch->buf);
248
if (scratch->len) {
249
strbuf_addch(scratch, '\n');
250
- xwrite(2, scratch->buf, scratch->len);
250
+ write_in_full(2, scratch->buf, scratch->len);
251
}
252
strbuf_release(scratch);
253
return 1;