Commit Diff


commit - 0619bbce0ebd152fcabc1d9f49833c37137918df
commit + b993e8cc5032750ca5c8382d60cf1def7057abea
blob - ce2f81128adb55df591d72ad424883405a96b988
blob + 4b56d0042209d042290978d8010c2f766591ae48
--- gotd/gotd.c
+++ gotd/gotd.c
@@ -302,6 +302,20 @@ proc_done(struct gotd_child_proc *proc)
 	kill_proc(proc, 0);
 	wait_for_child(proc->pid);
 	free(proc);
+}
+
+static void
+kill_repo_proc(struct gotd_client *client)
+{
+	struct gotd_child_proc *proc;
+
+	if (client->repo == NULL)
+		return;
+
+	proc = client->repo;
+	client->repo = NULL;
+
+	proc_done(proc);
 }
 
 static void
@@ -336,7 +350,6 @@ static void
 disconnect(struct gotd_client *client)
 {
 	struct gotd_imsg_disconnect idisconnect;
-	struct gotd_child_proc *proc = client->repo;
 	struct gotd_child_proc *listen_proc = gotd.listen_proc;
 	uint64_t slot;
 
@@ -344,16 +357,7 @@ disconnect(struct gotd_client *client)
 
 	kill_auth_proc(client);
 	kill_session_proc(client);
-
-	if (proc) {
-		event_del(&proc->iev.ev);
-		msgbuf_clear(&proc->iev.ibuf.w);
-		close(proc->iev.ibuf.fd);
-		kill_proc(proc, 0);
-		wait_for_child(proc->pid);
-		free(proc);
-		proc = NULL;
-	}
+	kill_repo_proc(client);
 
 	idisconnect.client_id = client->id;
 	if (gotd_imsg_compose_event(&listen_proc->iev,