avoid unnecessary imsg_flush() in got_privsep_send_commit()
diff --git a/lib/privsep.c b/lib/privsep.c
index f274634..325eec8 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -446,10 +446,12 @@ got_privsep_send_commit(struct imsgbuf *ibuf, struct got_commit_object *commit)
goto done;
}
- err = flush_imsg(ibuf);
- if (err)
- goto done;
-
+ if (logmsg_len == 0 ||
+ logmsg_len + len > MAX_IMSGSIZE - IMSG_HEADER_SIZE) {
+ err = flush_imsg(ibuf);
+ if (err)
+ goto done;
+ }
err = send_commit_logmsg(ibuf, commit, logmsg_len);
done:
free(buf);