Commit Diff


commit - 602eda794f1d6ffa7bf52408686191499e971da3
commit + ae0cca99d4999f67c98e04bf1f806bd1147d9721
blob - e1f90c1960d3e783711dd5f2f29e41b254d35a57
blob + 51069af23874055261175459d6d4d942db02ac41
--- gotd/gotd.c
+++ gotd/gotd.c
@@ -1075,8 +1075,12 @@ gotd_dispatch_auth_child(int fd, short event, void *ar
 	int do_disconnect = 0;
 
 	client = find_client_by_proc_fd(fd);
-	if (client == NULL)
-		fatalx("cannot find client for fd %d", fd);
+	if (client == NULL) {
+		/* Can happen during process teardown. */
+		warnx("cannot find client for fd %d", fd);
+		shut = 1;
+		goto done;
+	}
 
 	if (client->auth == NULL)
 		fatalx("cannot find auth child process for fd %d", fd);
@@ -1218,8 +1222,12 @@ gotd_dispatch_client_session(int fd, short event, void
 	struct imsg imsg;
 
 	client = find_client_by_proc_fd(fd);
-	if (client == NULL)
-		fatalx("cannot find client for fd %d", fd);
+	if (client == NULL) {
+		/* Can happen during process teardown. */
+		warnx("cannot find client for fd %d", fd);
+		shut = 1;
+		goto done;
+	}
 
 	if (event & EV_READ) {
 		if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
@@ -1340,8 +1348,12 @@ gotd_dispatch_repo_child(int fd, short event, void *ar
 	struct imsg imsg;
 
 	client = find_client_by_proc_fd(fd);
-	if (client == NULL)
-		fatalx("cannot find client for fd %d", fd);
+	if (client == NULL) {
+		/* Can happen during process teardown. */
+		warnx("cannot find client for fd %d", fd);
+		shut = 1;
+		goto done;
+	}
 
 	if (event & EV_READ) {
 		if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)