mirror of
https://github.com/git/git
synced 2024-11-04 16:17:49 +00:00
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>
This commit is contained in:
parent
fa6c383309
commit
36ffba1c7b
1 changed files with 2 additions and 2 deletions
|
@ -220,7 +220,7 @@ int demultiplex_sideband(const char *me, int status,
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_addch(scratch, *brk);
|
strbuf_addch(scratch, *brk);
|
||||||
xwrite(2, scratch->buf, scratch->len);
|
write_in_full(2, scratch->buf, scratch->len);
|
||||||
strbuf_reset(scratch);
|
strbuf_reset(scratch);
|
||||||
|
|
||||||
b = brk + 1;
|
b = brk + 1;
|
||||||
|
@ -247,7 +247,7 @@ int demultiplex_sideband(const char *me, int status,
|
||||||
die("%s", scratch->buf);
|
die("%s", scratch->buf);
|
||||||
if (scratch->len) {
|
if (scratch->len) {
|
||||||
strbuf_addch(scratch, '\n');
|
strbuf_addch(scratch, '\n');
|
||||||
xwrite(2, scratch->buf, scratch->len);
|
write_in_full(2, scratch->buf, scratch->len);
|
||||||
}
|
}
|
||||||
strbuf_release(scratch);
|
strbuf_release(scratch);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue