commit 19a4446fe1172888071b44c1c70d7b4ed28953278411906c2d9d5dba8bd47cd9 from: Stefan Sperling date: Wed Apr 16 10:04:41 2025 UTC stop using EV_PERSIST for fcgi_request and fix error handling commit - ca5816c4303bacc0a74c48def95bf50cfe1ec9ab9d59582874520f5c0018ff92 commit + 19a4446fe1172888071b44c1c70d7b4ed28953278411906c2d9d5dba8bd47cd9 blob - 9475014eec1eff6d3aa05c34722a9908da582887028c0e450fa68608ff028c17 blob + aa424a13ee75c20c00add506a3e78eda117a98c7638c4af6893664a3acdc420c --- gotwebd/fcgi.c +++ gotwebd/fcgi.c @@ -72,15 +72,19 @@ fcgi_request(int fd, short events, void *arg) switch (errno) { case EINTR: case EAGAIN: + event_add(&c->ev, NULL); return; default: goto fail; } break; - case 0: - log_info("closed connection"); - goto fail; + if (c->sock->client_status == CLIENT_CONNECT) { + log_warnx("client %u closed connection too early", + c->request_id); + goto fail; + } + return; default: break; } @@ -107,6 +111,7 @@ fcgi_request(int fd, short events, void *arg) } } while (parsed > 0 && c->buf_len > 0); + event_add(&c->ev, NULL); return; fail: fcgi_cleanup_request(c); @@ -259,6 +264,7 @@ process_request(struct request *c) c->resp_fd = pipe[1]; c->resp_event = resp_event; + c->sock->client_status = CLIENT_REQUEST; } void blob - 4281d5818cc47aa1505a67bcbeb61ce5c13321e0bf5a23a06566313ffb07b431 blob + 3c4361dde7f245a6a016d093fae9eafe95fa47ce12a2ceabd03268ac72f28a69 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -326,6 +326,7 @@ TAILQ_HEAD(serverlist, server); enum client_action { CLIENT_CONNECT, + CLIENT_REQUEST, CLIENT_DISCONNECT, }; blob - e5b31c6667ee24bdb8b2e6ea0d6779d90b1297e0cab44644bcc8bb81c374b64b blob + 6dd7679a252275c216fb6dcd04b84b0ef599ae239f6a830e6292566717287a04 --- gotwebd/sockets.c +++ gotwebd/sockets.c @@ -764,7 +764,7 @@ sockets_socket_accept(int fd, short event, void *arg) c->sock->client_status = CLIENT_CONNECT; c->request_id = get_request_id(); - event_set(&c->ev, s, EV_READ|EV_PERSIST, fcgi_request, c); + event_set(&c->ev, s, EV_READ, fcgi_request, c); event_add(&c->ev, NULL); evtimer_set(&c->tmo, fcgi_timeout, c);