Commit Diff


commit - 1453347d2463ce1b2700dd9fa810f30f2a443e5e
commit + 2ab714554f1fd2273c9705450cf192dabb4f6b9d
blob - 782f94ad26528e54d59fa5855bd1a0a4f674588b
blob + 135b8b683601bf61cba1c6e83ed9d36da871f90d
--- lib/privsep.c
+++ lib/privsep.c
@@ -94,9 +94,15 @@ read_imsg(struct imsgbuf *ibuf)
 	const struct got_error *err;
 	size_t n;
 
-	err = poll_fd(ibuf->fd, POLLIN, INFTIM);
-	if (err)
-		return err;
+	/*
+	 * There is no imsg API function to tell us whether the
+	 * read buffer still contains pending data :-(
+	 */
+	if (ibuf->r.wpos < IMSG_HEADER_SIZE) {
+		err = poll_fd(ibuf->fd, POLLIN, INFTIM);
+		if (err)
+			return err;
+	}
 
 	n = imsg_read(ibuf);
 	if (n == -1) {