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

Stefan Sperling <stsp@stsp.name>
Re: -portable gotd progress
Sun, 20 Aug 2023 22:49:55 +0200

Download raw body.

On Sun, Aug 20, 2023 at 04:35:35PM +0200, Stefan Sperling wrote:
> The next problem to solve for gotd on Linux is an "unexpected end of file"
> error printed by gotsh after a successful send operation.

The patch below fixes the above problem for me.
This is a race condition which could potentialy also trigger on OpenBSD
though I have never seen it there. In the session process we can end up
disconnecting the client before all pending Git protocol messages have
been sent. This issue depends on how fast the process kill cascade runs
once we decide to kill the repo_write process after sending the last Git
protocol message. The session->client libevent handler must be allowed
to flush all pending messages before the client gets disconnected.
Otherwise pending messages will be discarded in disconnect().

Getting the gotd regression test suite running on Linux is the next step.
Any volunteers? ;)

diff /home/stsp/src/got
commit - beb5455b68cf2c6513db813b7e36635a5685f95e
path + /home/stsp/src/got
blob - b3d7c90be3c833b735c00213a56ae5b0cef546d9
file + gotd/session.c
--- gotd/session.c
+++ gotd/session.c
@@ -83,6 +83,7 @@ static struct gotd_session_client {
 	char				*packidx_path;
 	int				 nref_updates;
 	int				 accept_flush_pkt;
+	int				 flush_disconnect;
 } gotd_session_client;
 void gotd_session_sighdlr(int sig, short event, void *arg);
@@ -545,7 +546,7 @@ done:
 		if (client->nref_updates == 0) {
-			*shut = 1;
+			client->flush_disconnect = 1;
@@ -1056,6 +1057,11 @@ session_dispatch_client(int fd, short events, void *ar
+		if (client->flush_disconnect) {
+			disconnect(client);
+			return;
+		}
 	if ((events & EV_READ) == 0)