"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
fix gotd_imsg_flush()
To:
gameoftrees@openbsd.org
Date:
Sat, 3 Dec 2022 15:36:50 +0100

Download raw body.

Thread
On a repository with more about 450 references, gotd fails to send
the initial reference announcement to clients because it runs into
an EAGAIN error from imsg_flush() during communication between
repo_read and the parent process.

This patch makes it work reliably by retrying queued messages when
imsg_flush() fails with EAGAIN.

ok?

diff /home/stsp/src/got
commit - 35bbeac873a7d5494c91b3bf2cc0b6c7f89ab569
path + /home/stsp/src/got
blob - 3c1a799bc318b9a6294c4a902145a0983b95815b
file + gotd/imsg.c
--- gotd/imsg.c
+++ gotd/imsg.c
@@ -57,18 +57,23 @@ gotd_imsg_flush(struct imsgbuf *ibuf)
 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 *