Commit Diff


commit - fe78d7cec3f01df183b57495dd079225ed14e989
commit + 522b54885b4f7cb277c5858109188e658c10efdb
blob - 3c1a799bc318b9a6294c4a902145a0983b95815b
blob + 9bea56cb0ddb3074ed1ef1574a25a359a1b5eb73
--- gotd/imsg.c
+++ gotd/imsg.c
@@ -57,18 +57,23 @@ gotd_imsg_recv_error(uint32_t *client_id, struct imsg 
 const struct got_error *
 gotd_imsg_flush(struct imsgbuf *ibuf)
 {
-	const struct got_error *err;
+	const struct got_error *err = NULL;
 
-	err = got_poll_fd(ibuf->fd, POLLOUT, INFTIM);
-	if (err)
-		return err;
+	while (ibuf->w.queued > 0) {
+		err = got_poll_fd(ibuf->fd, POLLOUT, INFTIM);
+		if (err)
+			break;
 
-	if (imsg_flush(ibuf) == -1) {
-		imsg_clear(ibuf);
-		return got_error_from_errno("imsg_flush");
-	}
+		if (imsg_flush(ibuf) == -1) {
+			if (errno != EAGAIN) {
+				imsg_clear(ibuf);
+				err = got_error_from_errno("imsg_flush");
+				break;
+			}
+		}
+	}	
 
-	return NULL;
+	return err;
 }
 
 const struct got_error *