diff options
| author | Ruslan Ermilov <ru@nginx.com> | 2015-04-10 13:16:23 +0300 |
|---|---|---|
| committer | Ruslan Ermilov <ru@nginx.com> | 2015-04-10 13:16:23 +0300 |
| commit | 18fa775b1060a663e15473161c795992926e60e1 (patch) | |
| tree | 573c21f6804ea6b8098dfc37c4d3fe8da38ff5b5 /src/http/ngx_http_upstream_round_robin.c | |
| parent | b25f0ddcf1202a475dee0d0bb6b93c1272c99d17 (diff) | |
| download | nginx-18fa775b1060a663e15473161c795992926e60e1.tar.gz nginx-18fa775b1060a663e15473161c795992926e60e1.tar.bz2 | |
Upstream: track the number of active connections to upstreams.
This also simplifies the implementation of the least_conn module.
Diffstat (limited to 'src/http/ngx_http_upstream_round_robin.c')
| -rw-r--r-- | src/http/ngx_http_upstream_round_robin.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c index 2d0649b7f..61c042f70 100644 --- 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(ngx_peer_connection_t *pc, void *data) 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(ngx_peer_connection_t *pc, void *data, /* 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(ngx_peer_connection_t *pc, void *data, } } + peer->conns--; + if (pc->tries) { pc->tries--; } |
