commit 2bd8d56a2d5e8d637430d608e9944a4b08e20187 from: Stefan Sperling date: Wed Apr 16 10:04:41 2025 UTC stop using EV_PERSIST for fcgi_request and fix error handling commit - f624e3f7a3b025c5bb3f32b8762ba05ddc0ba81d commit + 2bd8d56a2d5e8d637430d608e9944a4b08e20187 blob - 3ec4aee067d2084604a4b3ca1fa315b83811ccc3 blob + c2c1ee12bd8c2ba3ff07a94f5979543839420273 --- 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 - 27a53cfbf3baff7f391f1445c503ba9712923fc6 blob + 162669e54b0d2cd54061611b7096173f4479eb6d --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -326,6 +326,7 @@ TAILQ_HEAD(serverlist, server); enum client_action { CLIENT_CONNECT, + CLIENT_REQUEST, CLIENT_DISCONNECT, }; blob - 008faf6facb0837fc7b7e84fa8accffa90f1dbd7 blob + 545307fa76d787a29d9bccaa41f4477b40f86c9f --- 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);