Mercurial > hg > nginx-quic
diff src/http/ngx_http_upstream_round_robin.c @ 6099:6ff0ebd6fbf4
Upstream: track the number of active connections to upstreams.
This also simplifies the implementation of the least_conn module.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Fri, 10 Apr 2015 13:16:23 +0300 |
parents | 575175ebf4b4 |
children | c44459611d91 |
line wrap: on
line diff
--- a/src/http/ngx_http_upstream_round_robin.c +++ b/src/http/ngx_http_upstream_round_robin.c @@ -434,6 +434,8 @@ ngx_http_upstream_get_round_robin_peer(n pc->socklen = peer->socklen; pc->name = &peer->name; + peer->conns++; + /* ngx_unlock_mutex(peers->mutex); */ return NGX_OK; @@ -563,13 +565,16 @@ ngx_http_upstream_free_round_robin_peer( /* TODO: NGX_PEER_KEEPALIVE */ + peer = &rrp->peers->peer[rrp->current]; + if (rrp->peers->single) { + + peer->conns--; + pc->tries = 0; return; } - peer = &rrp->peers->peer[rrp->current]; - if (state & NGX_PEER_FAILED) { now = ngx_time(); @@ -602,6 +607,8 @@ ngx_http_upstream_free_round_robin_peer( } } + peer->conns--; + if (pc->tries) { pc->tries--; }