Commit Diff


commit - f54d892e4b41b214bfbc655c9d9b72d8b2bf0f07
commit + b7acbe65b9c3861892ccd85dce82d78aeb285f54
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)