]> git.kaiwu.me - nginx.git/commitdiff
Upstream: fixed unlocked access to peer->conns.
authorRuslan Ermilov <ru@nginx.com>
Sun, 19 Apr 2015 19:41:09 +0000 (22:41 +0300)
committerRuslan Ermilov <ru@nginx.com>
Sun, 19 Apr 2015 19:41:09 +0000 (22:41 +0300)
src/http/ngx_http_upstream_round_robin.c

index 52da545a13021a9aa20ebfa1e601d2da05d76eea..487b0e3ccfe25ad65791b0b8ee1c528647edb62f 100644 (file)
@@ -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();