aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_upstream_ip_hash_module.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2015-04-14 19:01:23 +0300
committerRuslan Ermilov <ru@nginx.com>2015-04-14 19:01:23 +0300
commitb0b7b5a356c7dedf4a1867e94d8a36cbb6dc3da1 (patch)
tree70e9cfdad48a96d66bacb942602191256ea41198 /src/http/modules/ngx_http_upstream_ip_hash_module.c
parent3fc23e2542d89712e6104331e95c648fc52a9b35 (diff)
downloadnginx-b0b7b5a356c7dedf4a1867e94d8a36cbb6dc3da1.tar.gz
nginx-b0b7b5a356c7dedf4a1867e94d8a36cbb6dc3da1.zip
Upstreams: locking.
Diffstat (limited to 'src/http/modules/ngx_http_upstream_ip_hash_module.c')
-rw-r--r--src/http/modules/ngx_http_upstream_ip_hash_module.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
index 2c6506d6f..debc0d8e5 100644
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
@@ -161,7 +161,10 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
/* TODO: cached */
+ ngx_http_upstream_rr_peers_wlock(iphp->rrp.peers);
+
if (iphp->tries > 20 || iphp->rrp.peers->single) {
+ ngx_http_upstream_rr_peers_unlock(iphp->rrp.peers);
return iphp->get_rr_peer(pc, &iphp->rrp);
}
@@ -212,8 +215,6 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
"get ip hash peer, hash: %ui %04XA", p, m);
- /* ngx_lock_mutex(iphp->rrp.peers->mutex); */
-
if (peer->down) {
goto next_try;
}
@@ -230,14 +231,12 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
next_try:
iphp->rrp.tried[n] |= m;
-
- /* ngx_unlock_mutex(iphp->rrp.peers->mutex); */
-
pc->tries--;
next:
if (++iphp->tries > 20) {
+ ngx_http_upstream_rr_peers_unlock(iphp->rrp.peers);
return iphp->get_rr_peer(pc, &iphp->rrp);
}
}
@@ -254,7 +253,7 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
peer->checked = now;
}
- /* ngx_unlock_mutex(iphp->rrp.peers->mutex); */
+ ngx_http_upstream_rr_peers_unlock(iphp->rrp.peers);
iphp->rrp.tried[n] |= m;
iphp->hash = hash;