Commit Diff


commit - f25e229e88a01c4a65fa80f4d5e35cd34309cbf9
commit + ba91039c1a0a3d55f4850e26c24730cbf4b5c239
blob - 84ef3291493887b755234fd478a3f7a7ca500d19
blob + 39b1d2a54632934de2bfaf127e20f0b0f725f4c8
--- gotd/gotd.c
+++ gotd/gotd.c
@@ -305,6 +305,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
@@ -339,7 +353,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;
 
@@ -347,16 +360,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,