mirror of
https://github.com/nginx/nginx.git
synced 2025-06-12 05:11:37 +08:00
Upstream: remove redundant lock in least_conn.
The recursive call to `ngx_*_upstream_get_least_conn_peer` already sets the peer name on NGX_BUSY, so we can return immediately instead of locking the list of peers again.
This commit is contained in:
parent
e28ef42b97
commit
6199d8bfbf
@ -103,7 +103,7 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
|
||||
|
||||
time_t now;
|
||||
uintptr_t m;
|
||||
ngx_int_t rc, total;
|
||||
ngx_int_t total;
|
||||
ngx_uint_t i, n, p, many;
|
||||
ngx_http_upstream_rr_peer_t *peer, *best;
|
||||
ngx_http_upstream_rr_peers_t *peers;
|
||||
@ -278,13 +278,7 @@ failed:
|
||||
|
||||
ngx_http_upstream_rr_peers_unlock(peers);
|
||||
|
||||
rc = ngx_http_upstream_get_least_conn_peer(pc, rrp);
|
||||
|
||||
if (rc != NGX_BUSY) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
ngx_http_upstream_rr_peers_wlock(peers);
|
||||
return ngx_http_upstream_get_least_conn_peer(pc, rrp);
|
||||
}
|
||||
|
||||
#if (NGX_HTTP_UPSTREAM_ZONE)
|
||||
|
@ -100,7 +100,7 @@ ngx_stream_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
|
||||
|
||||
time_t now;
|
||||
uintptr_t m;
|
||||
ngx_int_t rc, total;
|
||||
ngx_int_t total;
|
||||
ngx_uint_t i, n, p, many;
|
||||
ngx_stream_upstream_rr_peer_t *peer, *best;
|
||||
ngx_stream_upstream_rr_peers_t *peers;
|
||||
@ -274,13 +274,7 @@ failed:
|
||||
|
||||
ngx_stream_upstream_rr_peers_unlock(peers);
|
||||
|
||||
rc = ngx_stream_upstream_get_least_conn_peer(pc, rrp);
|
||||
|
||||
if (rc != NGX_BUSY) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
ngx_stream_upstream_rr_peers_wlock(peers);
|
||||
return ngx_stream_upstream_get_least_conn_peer(pc, rrp);
|
||||
}
|
||||
|
||||
#if (NGX_STREAM_UPSTREAM_ZONE)
|
||||
|
Loading…
Reference in New Issue
Block a user