Commit Diff


commit - fae44376ce5481472e61e403f0b171e7ca6b48f8
commit + eac60ea119ebb338c6f38e73d3918b7e893d56b1
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 *