summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9>2009-07-23 23:06:49 +0000
committerstbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9>2009-07-23 23:06:49 +0000
commit61a35285f6217da13ff30ff260ae73583b4b5773 (patch)
tree9364c8686e42194c71787dc1297d2a0659894d8f
parentf91129894b7b814500e81e50829d1d6c2ce97cab (diff)
downloadlighttpd-61a35285f6217da13ff30ff260ae73583b4b5773.tar.gz
Add proxy-core.max-backlog-size (set to 0 to disable backlog, thx e-razor)
git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@2602 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--NEWS1
-rw-r--r--src/mod_proxy_core.c15
-rw-r--r--src/mod_proxy_core.h1
3 files changed, 13 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 31dae69a..ed930465 100644
--- a/NEWS
+++ b/NEWS
@@ -138,6 +138,7 @@ NEWS
* Allow all comparisons for $SERVER["socket"] - only bind for "=="
* Fix mod_deflate bzip2 compression level (thx peto, fixes #2035)
* Add proxy-core.disable-time (used for all disable-times), default value 1 sec (fixes #1038)
+ * Add proxy-core.max-backlog-size (set to 0 to disable backlog, thx e-razor)
- 1.5.0-r19.. -
* -F option added for spawn-fcgi
diff --git a/src/mod_proxy_core.c b/src/mod_proxy_core.c
index 38ac11cd..f71ba2c0 100644
--- a/src/mod_proxy_core.c
+++ b/src/mod_proxy_core.c
@@ -41,6 +41,7 @@
#define CONFIG_PROXY_CORE_CHECK_LOCAL PROXY_CORE ".check-local"
#define CONFIG_PROXY_CORE_SPLIT_HOSTNAMES PROXY_CORE ".split-hostnames"
#define CONFIG_PROXY_CORE_DISABLE_TIME PROXY_CORE ".disable-time"
+#define CONFIG_PROXY_CORE_MAX_BACKLOG_SIZE PROXY_CORE ".max-backlog-size"
static int mod_proxy_wakeup_connections(server *srv, plugin_data *p, plugin_config *p_conf);
@@ -271,6 +272,7 @@ SETDEFAULTS_FUNC(mod_proxy_core_set_defaults) {
{ CONFIG_PROXY_CORE_MAX_KEEP_ALIVE, NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 10 */
{ CONFIG_PROXY_CORE_SPLIT_HOSTNAMES, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 11 */
{ CONFIG_PROXY_CORE_DISABLE_TIME, NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 12 */
+ { CONFIG_PROXY_CORE_MAX_BACKLOG_SIZE, NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 13 */
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
};
@@ -299,6 +301,7 @@ SETDEFAULTS_FUNC(mod_proxy_core_set_defaults) {
s->split_hostnames = 1;
s->max_keep_alive_requests = 0;
s->disable_time = 1;
+ s->max_backlog_size = 4;
cv[0].destination = p->backends_arr;
cv[1].destination = &(s->debug);
@@ -310,6 +313,7 @@ SETDEFAULTS_FUNC(mod_proxy_core_set_defaults) {
cv[10].destination = &(s->max_keep_alive_requests);
cv[11].destination = &(s->split_hostnames);
cv[12].destination = &(s->disable_time);
+ cv[13].destination = &(s->max_backlog_size);
buffer_reset(p->balance_buf);
@@ -1213,6 +1217,10 @@ static int proxy_recycle_backend_connection(server *srv, plugin_data *p, proxy_s
static handler_t mod_proxy_core_backlog_connection(server *srv, connection *con, plugin_data *p, proxy_session *sess) {
proxy_request *req;
+ if (sess->sent_to_backlog >= p->conf.max_backlog_size) {
+ return HANDLER_ERROR;
+ }
+
/* connection pool is full, queue the request for now */
req = proxy_request_init();
req->added_ts = srv->cur_ts;
@@ -1223,10 +1231,6 @@ static handler_t mod_proxy_core_backlog_connection(server *srv, connection *con,
COUNTER_INC(p->conf.backlog_size);
sess->sent_to_backlog++;
- if (sess->sent_to_backlog > 4) {
- return HANDLER_ERROR;
- }
-
return HANDLER_GO_ON;
}
@@ -2049,6 +2053,7 @@ static int mod_proxy_core_patch_connection(server *srv, connection *con, plugin_
PATCH_OPTION(split_hostnames);
PATCH_OPTION(max_keep_alive_requests);
PATCH_OPTION(disable_time);
+ PATCH_OPTION(max_backlog_size);
/* skip the first, the global context */
for (i = 1; i < srv->config_context->used; i++) {
@@ -2090,6 +2095,8 @@ static int mod_proxy_core_patch_connection(server *srv, connection *con, plugin_
PATCH_OPTION(max_keep_alive_requests);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_PROXY_CORE_DISABLE_TIME))) {
PATCH_OPTION(disable_time);
+ } else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_PROXY_CORE_MAX_BACKLOG_SIZE))) {
+ PATCH_OPTION(max_backlog_size);
}
}
}
diff --git a/src/mod_proxy_core.h b/src/mod_proxy_core.h
index 743e3472..a3685539 100644
--- a/src/mod_proxy_core.h
+++ b/src/mod_proxy_core.h
@@ -33,6 +33,7 @@ typedef struct {
unsigned short split_hostnames;
unsigned short max_keep_alive_requests;
unsigned short disable_time;
+ unsigned short max_backlog_size;
proxy_balance_t balancer;
struct proxy_protocol *protocol;