commit 3b8dccc5ebf6eaef854a522e02f0f98c93b153ea from: Stefan Sperling date: Wed Apr 16 11:42:03 2025 UTC track per-request connection state in struct request, not struct socket commit - 18f076f0b48c5d6f6f064767e8515367897638ab commit + 3b8dccc5ebf6eaef854a522e02f0f98c93b153ea blob - 7224c9dcd78c7d77207edf7b6b3b93eaf437e069 blob + d3afc4bb0e9b2573b45e030fed2e911baafd4007 --- gotwebd/fcgi.c +++ gotwebd/fcgi.c @@ -79,7 +79,7 @@ fcgi_request(int fd, short events, void *arg) } break; case 0: - if (c->sock->client_status == CLIENT_CONNECT) { + if (c->client_status == CLIENT_CONNECT) { log_warnx("client %u closed connection too early", c->request_id); goto fail; @@ -263,7 +263,7 @@ process_request(struct request *c) c->resp_fd = pipe[1]; c->resp_event = resp_event; - c->sock->client_status = CLIENT_REQUEST; + c->client_status = CLIENT_REQUEST; } void @@ -412,7 +412,7 @@ send_response(struct request *c, int type, const uint8 while (tot > 0) { nw = writev(c->fd, iov, nitems(iov)); if (nw == 0) { - c->sock->client_status = CLIENT_DISCONNECT; + c->client_status = CLIENT_DISCONNECT; break; } if (nw == -1) { @@ -422,7 +422,7 @@ send_response(struct request *c, int type, const uint8 continue; } log_warn("%s: write failure", __func__); - c->sock->client_status = CLIENT_DISCONNECT; + c->client_status = CLIENT_DISCONNECT; return -1; } @@ -449,7 +449,7 @@ int fcgi_send_response(struct request *c, int type, const void *data, size_t len) { - if (c->sock->client_status == CLIENT_DISCONNECT) + if (c->client_status == CLIENT_DISCONNECT) return -1; while (len > FCGI_CONTENT_SIZE) { blob - 72ffa40edb56b983084fef786f25489677aa63ff blob + 1973199772dbd6e269f7b884a5607f7e7d7f0414 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -270,6 +270,7 @@ struct request { int https; uint8_t request_started; + int client_status; }; TAILQ_HEAD(requestlist, request); @@ -347,8 +348,6 @@ struct socket { struct event evt; struct event ev; struct event pause; - - int client_status; }; TAILQ_HEAD(socketlist, socket); blob - 63d93602309aa8ee8cc25e77c1ca5765ae3c4d43 blob + 43828ff049e42b2a6c38f8967c902d0666127101 --- gotwebd/sockets.c +++ gotwebd/sockets.c @@ -339,7 +339,7 @@ request_done(struct imsg *imsg) return; } - if (c->sock->client_status == CLIENT_REQUEST) + if (c->client_status == CLIENT_REQUEST) fcgi_create_end_record(c); fcgi_cleanup_request(c); } @@ -765,7 +765,7 @@ sockets_socket_accept(int fd, short event, void *arg) c->buf_pos = 0; c->buf_len = 0; c->request_started = 0; - c->sock->client_status = CLIENT_CONNECT; + c->client_status = CLIENT_CONNECT; c->request_id = get_request_id(); event_set(&c->ev, s, EV_READ, fcgi_request, c);