From: claudio Date: Fri, 31 Mar 2023 09:55:39 +0000 (+0000) Subject: When the slowcgi timeout fires but no process what yet started terminate X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f889a45c126a063a3a92770fd9e7f52e512b5305;p=openbsd When the slowcgi timeout fires but no process what yet started terminate the session with a HTTP 408 error. OK tb@ --- diff --git a/usr.sbin/bgplgd/slowcgi.c b/usr.sbin/bgplgd/slowcgi.c index f5fabf54ebf..f20eb8afdd7 100644 --- a/usr.sbin/bgplgd/slowcgi.c +++ b/usr.sbin/bgplgd/slowcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.5 2022/10/27 13:24:22 claudio Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.6 2023/03/31 09:55:39 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -159,6 +159,7 @@ void parse_begin_request(uint8_t *, uint16_t, struct request *, void parse_params(uint8_t *, uint16_t, struct request *, uint16_t); void parse_stdin(uint8_t *, uint16_t, struct request *, uint16_t); char *env_get(struct request *, const char *); +void error_response(struct request *, int); void exec_cgi(struct request *); void script_std_in(int, short, void *); void script_err_in(int, short, void *); @@ -505,6 +506,12 @@ slowcgi_timeout(int fd, short events, void *arg) if (c->script_flags & SCRIPT_DONE) return; + if (c->command_pid == 0) { + c->command_status = SIGALRM; + error_response(c, 408); + return; + } + ldebug("timeout fired for pid %d", c->command_pid); if (c->timeout_fired) @@ -887,7 +894,7 @@ http_error(int *res) return "Internal Server Error"; } -static void +void error_response(struct request *c, int res) { const char *type = "text/html";