summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-07-15 00:46:01 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-07-23 19:02:29 -0400
commitb6d08187627021e01173cc129ba7cc790465d5fd (patch)
tree020d7f66fc6c3d4c65fe8add7719a78c2dd133c9
parent45b970e69b144c7eaa5508fbb55728cb7c731caf (diff)
downloadlighttpd1.4-b6d08187627021e01173cc129ba7cc790465d5fd.tar.gz
lighttpd1.4-b6d08187627021e01173cc129ba7cc790465d5fd.zip
[core] spread load on socket backend procs
connection attempts in progress count towards proc load so that bursts of new connections do not all queue for current least busy proc (makes a difference only for local backends with more than one proc)
-rw-r--r--src/gw_backend.c11
-rw-r--r--src/gw_backend.h1
2 files changed, 3 insertions, 9 deletions
diff --git a/src/gw_backend.c b/src/gw_backend.c
index 0037ed14..c32c70cb 100644
--- a/src/gw_backend.c
+++ b/src/gw_backend.c
@@ -226,7 +226,6 @@ static int gw_extension_insert(gw_exts *ext, buffer *key, gw_host *fh) {
}
static void gw_proc_connect_success(server *srv, gw_host *host, gw_proc *proc, int debug) {
- gw_proc_load_inc(srv, host, proc);
gw_proc_tag_inc(srv, host, proc, CONST_STR_LEN(".connected"));
if (debug) {
@@ -1105,7 +1104,6 @@ static void handler_ctx_clear(gw_handler_ctx *hctx) {
hctx->fd = -1;
hctx->fde_ndx = -1;
- hctx->got_proc = 0;
hctx->reconnects = 0;
hctx->request_id = 0;
hctx->send_content_body = 1;
@@ -1628,11 +1626,7 @@ static void gw_backend_close(server *srv, gw_handler_ctx *hctx) {
if (hctx->host) {
if (hctx->proc) {
- if (hctx->got_proc) {
- /* after the connect the process gets a load */
- hctx->got_proc = 0;
- gw_proc_release(srv, hctx->host, hctx->proc, hctx->conf.debug);
- }
+ gw_proc_release(srv, hctx->host, hctx->proc, hctx->conf.debug);
hctx->proc = NULL;
}
@@ -1703,6 +1697,8 @@ static handler_t gw_write_request(server *srv, gw_handler_ctx *hctx) {
if (proc->load < hctx->proc->load) hctx->proc = proc;
}
+ gw_proc_load_inc(srv, hctx->host, hctx->proc);
+
hctx->fd = fdevent_socket_nb_cloexec(hctx->host->family,SOCK_STREAM,0);
if (-1 == hctx->fd) {
if (errno == EMFILE || errno == EINTR) {
@@ -1757,7 +1753,6 @@ static handler_t gw_write_request(server *srv, gw_handler_ctx *hctx) {
}
gw_proc_connect_success(srv, hctx->host, hctx->proc, hctx->conf.debug);
- hctx->got_proc = 1;
gw_set_state(srv, hctx, GW_STATE_PREPARE_WRITE);
/* fall through */
diff --git a/src/gw_backend.h b/src/gw_backend.h
index d196939e..2787c97c 100644
--- a/src/gw_backend.h
+++ b/src/gw_backend.h
@@ -309,7 +309,6 @@ typedef struct gw_handler_ctx {
int fde_ndx; /* index into the fd-event buffer */
pid_t pid;
- int got_proc;
int reconnects; /* number of reconnect attempts */
int request_id;