Commit 904df868d68e12778fedf815fe73a70919d71b19

Stefan Sperling 2018-11-04T21:31:51

avoid unnecessary imsg_flush() in got_privsep_send_commit()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);