Commit Diff


commit - fa94c02250118210d63c5161d74c7783e009edcb
commit + 1ca965ba4c9a64871f00758c02f279d158cd6820
blob - 740edfb7ecbcb748c9f113112c47194c0b2ec07a
blob + c80ad832621e5ed43a6e3ba784c8db0b99ff1ce4
--- gotd/gotd.c
+++ gotd/gotd.c
@@ -314,6 +314,7 @@ static void
 proc_done(struct gotd_child_proc *proc)
 {
 	struct gotd_client *client;
+	int do_disconnect = 0;
 
 	TAILQ_REMOVE(&procs, proc, entry);
 
@@ -321,12 +322,18 @@ proc_done(struct gotd_child_proc *proc)
 	if (client == NULL)
 		client = find_client_by_proc_fd(proc->pipe[0]);
 	if (client != NULL) {
-		if (proc == client->repo)
+		if (proc == client->repo) {
 			client->repo = NULL;
-		if (proc == client->auth)
+			do_disconnect = 1;
+		}
+		if (proc == client->auth) {
 			client->auth = NULL;
-		if (proc == client->session)
+			do_disconnect = 1;
+		}
+		if (proc == client->session) {
 			client->session = NULL;
+			do_disconnect = 1;
+		}
 		if (proc == client->gotsys)
 			client->gotsys = NULL;
 	}
@@ -343,6 +350,9 @@ proc_done(struct gotd_child_proc *proc)
 	}
 
 	free(proc);
+
+	if (do_disconnect)
+		disconnect(client);
 }
 
 static void