From 038ce90f2ff91587f2d61993f5c4c23d6fdca144 Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Sun, 16 Oct 2016 16:20:32 -0700 Subject: pkt-line: add packet_flush_gently() packet_flush() would die in case of a write error even though for some callers an error would be acceptable. Add packet_flush_gently() which writes a pkt-line flush packet like packet_flush() but does not die in case of an error. The function is used in a subsequent patch. Signed-off-by: Lars Schneider Signed-off-by: Junio C Hamano --- pkt-line.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkt-line.c') diff --git a/pkt-line.c b/pkt-line.c index 3288ff07d..62b89dbe3 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -91,6 +91,14 @@ void packet_flush(int fd) write_or_die(fd, "0000", 4); } +int packet_flush_gently(int fd) +{ + packet_trace("0000", 4, 1); + if (write_in_full(fd, "0000", 4) == 4) + return 0; + return error("flush packet write failed"); +} + void packet_buf_flush(struct strbuf *buf) { packet_trace("0000", 4, 1); -- cgit v1.2.1