commit 667b49380765081e326af04aef8c6e374ef0fc2bd3fdcd91b7457dd2dc8f9251 from: Stefan Sperling date: Wed Apr 16 11:42:03 2025 UTC track per-request connection state in struct request, not struct socket commit - 62dd118885b4ad9677bc80d8cca4982acb7a234e7b3e4e14f9d5f7d7dbc582c5 commit + 667b49380765081e326af04aef8c6e374ef0fc2bd3fdcd91b7457dd2dc8f9251 blob - e67eb12e0ddd051f1b0a2a4207edfa27f245ada0e5fa2151a4fee3232ee9f3fd blob + 400a5dc5471d90a524a185f7be47c51fad453d48d978a0fde261bd53cb1a02c1 --- 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 - a28a0fef4f7272649db971d45a70f96c487970ad38428eac6822abdfb5fdba59 blob + 0ae75bbd22f4f81cf117765352fabc1b3f2b42268a32d5a40bc3b78e44f3c566 --- 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 - 4050c61438004f7cedd1c6873686a734577d4ca5773b1d3ebf2d8d9cc4601723 blob + 6151ea693c3a58ab19379ea24b433693859a0fdfce84564eaec223798c09c3b3 --- 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);