aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_upstream_round_robin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/ngx_http_upstream_round_robin.c')
-rw-r--r--src/http/ngx_http_upstream_round_robin.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index 81564b3b3..501584d37 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -92,6 +92,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
peer[n].weight = server[i].weight;
peer[n].effective_weight = server[i].weight;
peer[n].current_weight = 0;
+ peer[n].max_conns = server[i].max_conns;
peer[n].max_fails = server[i].max_fails;
peer[n].fail_timeout = server[i].fail_timeout;
peer[n].down = server[i].down;
@@ -155,6 +156,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
peer[n].weight = server[i].weight;
peer[n].effective_weight = server[i].weight;
peer[n].current_weight = 0;
+ peer[n].max_conns = server[i].max_conns;
peer[n].max_fails = server[i].max_fails;
peer[n].fail_timeout = server[i].fail_timeout;
peer[n].down = server[i].down;
@@ -223,6 +225,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
peer[i].weight = 1;
peer[i].effective_weight = 1;
peer[i].current_weight = 0;
+ peer[i].max_conns = 0;
peer[i].max_fails = 1;
peer[i].fail_timeout = 10;
*peerp = &peer[i];
@@ -337,6 +340,7 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
peer[0].weight = 1;
peer[0].effective_weight = 1;
peer[0].current_weight = 0;
+ peer[0].max_conns = 0;
peer[0].max_fails = 1;
peer[0].fail_timeout = 10;
peers->peer = peer;
@@ -370,6 +374,7 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
peer[i].weight = 1;
peer[i].effective_weight = 1;
peer[i].current_weight = 0;
+ peer[i].max_conns = 0;
peer[i].max_fails = 1;
peer[i].fail_timeout = 10;
*peerp = &peer[i];
@@ -432,6 +437,10 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
goto failed;
}
+ if (peer->max_conns && peer->conns >= peer->max_conns) {
+ goto failed;
+ }
+
rrp->current = peer;
} else {
@@ -533,6 +542,10 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp)
continue;
}
+ if (peer->max_conns && peer->conns >= peer->max_conns) {
+ continue;
+ }
+
peer->current_weight += peer->effective_weight;
total += peer->effective_weight;