aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2015-04-19 22:41:09 +0300
committerRuslan Ermilov <ru@nginx.com>2015-04-19 22:41:09 +0300
commita2dac51398b4442437bccbdf01c103ae958600a7 (patch)
tree110434cae77f65e7803ec77f459e2213cb0c9390
parent9b411460f967aa018e31dd3cd6f1e66ff3bfba5c (diff)
downloadnginx-a2dac51398b4442437bccbdf01c103ae958600a7.tar.gz
nginx-a2dac51398b4442437bccbdf01c103ae958600a7.zip
Upstream: fixed unlocked access to peer->conns.
-rw-r--r--src/http/ngx_http_upstream_round_robin.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index 52da545a1..487b0e3cc 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -599,17 +599,20 @@ ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data,
peer = rrp->current;
+ ngx_http_upstream_rr_peers_rlock(rrp->peers);
+ ngx_http_upstream_rr_peer_lock(rrp->peers, peer);
+
if (rrp->peers->single) {
peer->conns--;
+ ngx_http_upstream_rr_peer_unlock(rrp->peers, peer);
+ ngx_http_upstream_rr_peers_unlock(rrp->peers);
+
pc->tries = 0;
return;
}
- ngx_http_upstream_rr_peers_rlock(rrp->peers);
- ngx_http_upstream_rr_peer_lock(rrp->peers, peer);
-
if (state & NGX_PEER_FAILED) {
now = ngx_time();