aboutsummaryrefslogtreecommitdiffstats
path: root/package/uhttpd/src/uhttpd-cgi.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-03-27 00:00:33 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-03-27 00:00:33 +0000
commit99e8e7cf2f2c856ac67b2b0455a8b10b659a1ab5 (patch)
treeefa53486b6d67774f4641dea35ec97e78744b298 /package/uhttpd/src/uhttpd-cgi.c
parent78c616da82979a2bbf96a8792680278cf641a23a (diff)
downloadmaster-187ad058-99e8e7cf2f2c856ac67b2b0455a8b10b659a1ab5.tar.gz
master-187ad058-99e8e7cf2f2c856ac67b2b0455a8b10b659a1ab5.tar.bz2
master-187ad058-99e8e7cf2f2c856ac67b2b0455a8b10b659a1ab5.zip
[package] uhttpd:
- make script timeout configurable - catch SIGCHLD to properly interrupt select() - flag listen and client sockets as close-on-exec git-svn-id: svn://svn.openwrt.org/openwrt/trunk@20500 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/uhttpd/src/uhttpd-cgi.c')
-rw-r--r--package/uhttpd/src/uhttpd-cgi.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/package/uhttpd/src/uhttpd-cgi.c b/package/uhttpd/src/uhttpd-cgi.c
index 5565197ca7..4a30f2fc9a 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;
}