mirror of https://github.com/nealey/eris.git
more reasonable timeouts
This commit is contained in:
parent
3c4ee62af4
commit
a2179d8453
1
cgi.c
1
cgi.c
|
@ -166,7 +166,6 @@ serve_cgi(char *relpath)
|
||||||
|
|
||||||
alarm(CGI_TIMEOUT);
|
alarm(CGI_TIMEOUT);
|
||||||
cgi_parent(cin[0], cout[1], 0);
|
cgi_parent(cin[0], cout[1], 0);
|
||||||
alarm(0);
|
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
|
|
12
eris.c
12
eris.c
|
@ -48,12 +48,18 @@
|
||||||
/* Wait this long (seconds) for a valid HTTP request */
|
/* Wait this long (seconds) for a valid HTTP request */
|
||||||
#define READTIMEOUT 2
|
#define READTIMEOUT 2
|
||||||
|
|
||||||
/* Wait this long trying to write out the response */
|
/* Wait this long (seconds) for a non-file send to complete */
|
||||||
#define WRITETIMEOUT 20
|
#define WRITETIMEOUT 10
|
||||||
|
|
||||||
|
/* Quit if we can't write at least this many bytes per second */
|
||||||
|
#define MIN_WRITE_RATE 2560
|
||||||
|
|
||||||
/* Wait this long for CGI to complete */
|
/* Wait this long for CGI to complete */
|
||||||
#define CGI_TIMEOUT (5*60)
|
#define CGI_TIMEOUT (5*60)
|
||||||
|
|
||||||
|
/* How long each sendfile call can take */
|
||||||
|
#define SENDFILE_TIMEOUT ((int)(SIZE_MAX / MIN_WRITE_RATE))
|
||||||
|
|
||||||
/* Maximum size of a request header (the whole block) */
|
/* Maximum size of a request header (the whole block) */
|
||||||
#define MAXHEADERLEN 8192
|
#define MAXHEADERLEN 8192
|
||||||
|
|
||||||
|
@ -349,6 +355,7 @@ serve_file(int fd, char *filename, struct stat *st)
|
||||||
size_t count = min(remain, SIZE_MAX);
|
size_t count = min(remain, SIZE_MAX);
|
||||||
ssize_t sent;
|
ssize_t sent;
|
||||||
|
|
||||||
|
alarm(SENDFILE_TIMEOUT);
|
||||||
sent = sendfile(1, fd, &range_start, count);
|
sent = sendfile(1, fd, &range_start, count);
|
||||||
if (-1 == sent) {
|
if (-1 == sent) {
|
||||||
fake_sendfile(1, fd, &range_start, count);
|
fake_sendfile(1, fd, &range_start, count);
|
||||||
|
@ -730,6 +737,7 @@ handle_request()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Serve the file */
|
/* Serve the file */
|
||||||
|
alarm(WRITETIMEOUT);
|
||||||
cork(1);
|
cork(1);
|
||||||
find_serve_file(fspath);
|
find_serve_file(fspath);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
Loading…
Reference in New Issue