aboutsummaryrefslogtreecommitdiff
path: root/src/stream/ngx_stream_upstream_least_conn_module.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stream/ngx_stream_upstream_least_conn_module.c')
-rw-r--r--src/stream/ngx_stream_upstream_least_conn_module.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/stream/ngx_stream_upstream_least_conn_module.c b/src/stream/ngx_stream_upstream_least_conn_module.c
index 1213bb53b..739b20a9f 100644
--- a/src/stream/ngx_stream_upstream_least_conn_module.c
+++ b/src/stream/ngx_stream_upstream_least_conn_module.c
@@ -150,6 +150,10 @@ ngx_stream_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
continue;
}
+ if (peer->max_conns && peer->conns >= peer->max_conns) {
+ continue;
+ }
+
/*
* select peer with least number of connections; if there are
* multiple peers with the same number of connections, select
@@ -205,6 +209,10 @@ ngx_stream_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
continue;
}
+ if (peer->max_conns && peer->conns >= peer->max_conns) {
+ continue;
+ }
+
peer->current_weight += peer->effective_weight;
total += peer->effective_weight;
@@ -292,6 +300,7 @@ ngx_stream_upstream_least_conn(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
uscf->flags = NGX_STREAM_UPSTREAM_CREATE
|NGX_STREAM_UPSTREAM_WEIGHT
+ |NGX_STREAM_UPSTREAM_MAX_CONNS
|NGX_STREAM_UPSTREAM_MAX_FAILS
|NGX_STREAM_UPSTREAM_FAIL_TIMEOUT
|NGX_STREAM_UPSTREAM_DOWN