properly flush imsg in send_commit_logmsg()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
diff --git a/lib/privsep.c b/lib/privsep.c
index 8da8e2c..f274634 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -377,6 +377,7 @@ static const struct got_error *
send_commit_logmsg(struct imsgbuf *ibuf, struct got_commit_object *commit,
size_t logmsg_len)
{
+ const struct got_error *err = NULL;
size_t offset, remain;
offset = 0;
@@ -385,17 +386,20 @@ send_commit_logmsg(struct imsgbuf *ibuf, struct got_commit_object *commit,
size_t n = MIN(MAX_IMSGSIZE - IMSG_HEADER_SIZE, remain);
if (imsg_compose(ibuf, GOT_IMSG_COMMIT_LOGMSG, 0, 0, -1,
- commit->logmsg + offset, n) == -1)
- return got_error_from_errno();
+ commit->logmsg + offset, n) == -1) {
+ err = got_error_from_errno();
+ break;
+ }
- if (imsg_flush(ibuf) == -1)
- return got_error_from_errno();
+ err = flush_imsg(ibuf);
+ if (err)
+ break;
offset += n;
remain -= n;
}
- return NULL;
+ return err;
}
const struct got_error *