summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-02-04 01:26:47 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2019-02-04 03:01:33 -0500
commitaa2d0fb087c7e6c6bbdd6a4a33869e0a8eb61924 (patch)
treefc37e3e64d1960a2a2bebfe70664851c2ed5020c
parent653b0dac7c2434d958c0b11bc5ea8876dff4cde8 (diff)
downloadlighttpd1.4-aa2d0fb087c7e6c6bbdd6a4a33869e0a8eb61924.tar.gz
lighttpd1.4-aa2d0fb087c7e6c6bbdd6a4a33869e0a8eb61924.zip
[core] srv->max_fds_lowat and srv->max_fds_hiwat
-rw-r--r--src/base.h2
-rw-r--r--src/server.c7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/base.h b/src/base.h
index b3c508c8..da7d6ed7 100644
--- a/src/base.h
+++ b/src/base.h
@@ -388,6 +388,8 @@ struct server {
int con_closed;
int max_fds; /* max possible fds */
+ int max_fds_lowat;/* low watermark */
+ int max_fds_hiwat;/* high watermark */
int cur_fds; /* currently used fds */
int want_fds; /* waiting fds */
int sockets_disabled;
diff --git a/src/server.c b/src/server.c
index 88a2b81a..59e46501 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1690,6 +1690,9 @@ static int server_main (server * const srv, int argc, char **argv) {
return -1;
}
+ srv->max_fds_lowat = srv->max_fds * 8 / 10;
+ srv->max_fds_hiwat = srv->max_fds * 9 / 10;
+
/* libev backend overwrites our SIGCHLD handler and calls waitpid on SIGCHLD; we want our own SIGCHLD handling. */
#ifdef HAVE_SIGACTION
sigaction(SIGCHLD, &act, NULL);
@@ -1986,7 +1989,7 @@ static int server_main_loop (server * const srv) {
} else if (srv->sockets_disabled) {
/* our server sockets are disabled, why ? */
- if ((srv->cur_fds + srv->want_fds < srv->max_fds * 8 / 10) && /* we have enough unused fds */
+ if ((srv->cur_fds + srv->want_fds < srv->max_fds_lowat) && /* we have enough unused fds */
(srv->conns->used <= srv->max_conns * 9 / 10)) {
server_sockets_set_event(srv, FDEVENT_IN);
log_error_write(srv, __FILE__, __LINE__, "s", "[note] sockets enabled again");
@@ -1994,7 +1997,7 @@ static int server_main_loop (server * const srv) {
srv->sockets_disabled = 0;
}
} else {
- if ((srv->cur_fds + srv->want_fds > srv->max_fds * 9 / 10) || /* out of fds */
+ if ((srv->cur_fds + srv->want_fds > srv->max_fds_hiwat) || /* out of fds */
(srv->conns->used >= srv->max_conns)) { /* out of connections */
/* disable server-fds */
server_sockets_set_event(srv, 0);