From 8c9b818a24045c15f40fc415cd1dde78c438555a Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 27 Mar 2010 00:00:33 +0000 Subject: uhttpd: - make script timeout configurable - catch SIGCHLD to properly interrupt select() - flag listen and client sockets as close-on-exec SVN-Revision: 20500 --- package/uhttpd/src/uhttpd-cgi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'package/uhttpd/src/uhttpd-cgi.c') diff --git a/package/uhttpd/src/uhttpd-cgi.c b/package/uhttpd/src/uhttpd-cgi.c index 5565197..4a30f2f 100644 --- a/package/uhttpd/src/uhttpd-cgi.c +++ b/package/uhttpd/src/uhttpd-cgi.c @@ -372,7 +372,7 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf FD_SET(rfd[0], &reader); FD_SET(wfd[1], &writer); - timeout.tv_sec = 15; + timeout.tv_sec = cl->server->conf->script_timeout; timeout.tv_usec = 0; /* wait until we can read or write or both */ @@ -538,11 +538,18 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf } } - /* no activity for 15 seconds... looks dead */ + /* timeout exceeded or interrupted by SIGCHLD */ else { - ensure(uh_http_sendhf(cl, 504, "Gateway Timeout", - "The CGI script took too long to produce a response")); + if( (errno != EINTR) && ! header_sent ) + { + ensure(uh_http_sendhf(cl, 504, "Gateway Timeout", + "The CGI script took too long to produce " + "a response")); + } + + /* send final chunk if we're in chunked transfer mode */ + ensure(uh_http_send(cl, req, "", 0)); break; } -- cgit v1.1