shithub: neoventi

Download patch

ref: d95c2f24d7ff9f1eaacb11ac2ffb7ca69f1d3197
parent: a0e37090b748a9c271dca0d8d972ef61037837d7
author: Noam Preil <noam@pixelhero.dev>
date: Thu Jul 4 18:11:03 EDT 2024

server: fix connection cleanup

--- a/server.c
+++ b/server.c
@@ -171,35 +171,27 @@
 	}
 }
 
-static int
-inittrampoline(VtConn *conn)
+static void
+handleproc(void *fd)
 {
-	switch(setjmp(conn->bounce)){
+	char buf[MaxPacketSize];
+	VtConn conn;
+	conn.fd = (int)(usize)fd;
+	switch(setjmp(conn.bounce)){
 	case 0:
-		return 1;
+		vthello(conn, buf);
+		vtloop(conn, buf);
+		break;
 	case 1:
 		fprint(2, "abandoning client: %r\n");
+		break;
 	case 2:
-		exits(nil);
-		return 0;
+		// Deliberate disconnect, don't log.
+		break;
 	default:
-		fprint(2, "internal error: unexpected bounce code\n");
-		return 0;
+		sysfatal("internal error: unexpected bounce code");
 	}
-}
-
-static void
-handleproc(void *fd)
-{
-	char buf[MaxPacketSize];
-	VtConn conn;
-	conn.fd = (int)(usize)fd;
-	if(!inittrampoline(&conn)){
-		close(conn.fd);
-		return;
-	}
-	vthello(conn, buf);
-	vtloop(conn, buf);
+	close(conn.fd);
 }
 
 static void