diff options
author | Niklas Keller <me@kelunik.com> | 2019-05-23 16:49:22 +0300 |
---|---|---|
committer | Niklas Keller <me@kelunik.com> | 2019-05-23 16:49:22 +0300 |
commit | c18658e9fec66b2564a3dcc9a24d401d77a0d986 (patch) | |
tree | 11674835c311a829395499bee2ed9af877932680 | |
parent | e0768d199dcdfe7d78a160d31a95418b20d10941 (diff) | |
download | nginx-c18658e9fec66b2564a3dcc9a24d401d77a0d986.tar.gz nginx-c18658e9fec66b2564a3dcc9a24d401d77a0d986.zip |
Upstream hash: fall back to round-robin if hash key is empty.
-rw-r--r-- | src/http/modules/ngx_http_upstream_hash_module.c | 4 | ||||
-rw-r--r-- | src/stream/ngx_stream_upstream_hash_module.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/http/modules/ngx_http_upstream_hash_module.c b/src/http/modules/ngx_http_upstream_hash_module.c index 6c247b560..e741eb237 100644 --- a/src/http/modules/ngx_http_upstream_hash_module.c +++ b/src/http/modules/ngx_http_upstream_hash_module.c @@ -178,7 +178,7 @@ ngx_http_upstream_get_hash_peer(ngx_peer_connection_t *pc, void *data) ngx_http_upstream_rr_peers_rlock(hp->rrp.peers); - if (hp->tries > 20 || hp->rrp.peers->single) { + if (hp->tries > 20 || hp->rrp.peers->single || hp->key.len == 0) { ngx_http_upstream_rr_peers_unlock(hp->rrp.peers); return hp->get_rr_peer(pc, &hp->rrp); } @@ -509,7 +509,7 @@ ngx_http_upstream_get_chash_peer(ngx_peer_connection_t *pc, void *data) ngx_http_upstream_rr_peers_wlock(hp->rrp.peers); - if (hp->tries > 20 || hp->rrp.peers->single) { + if (hp->tries > 20 || hp->rrp.peers->single || hp->key.len == 0) { ngx_http_upstream_rr_peers_unlock(hp->rrp.peers); return hp->get_rr_peer(pc, &hp->rrp); } diff --git a/src/stream/ngx_stream_upstream_hash_module.c b/src/stream/ngx_stream_upstream_hash_module.c index 4fa9a2dce..b764fcbe0 100644 --- a/src/stream/ngx_stream_upstream_hash_module.c +++ b/src/stream/ngx_stream_upstream_hash_module.c @@ -178,7 +178,7 @@ ngx_stream_upstream_get_hash_peer(ngx_peer_connection_t *pc, void *data) ngx_stream_upstream_rr_peers_rlock(hp->rrp.peers); - if (hp->tries > 20 || hp->rrp.peers->single) { + if (hp->tries > 20 || hp->rrp.peers->single || hp->key.len == 0) { ngx_stream_upstream_rr_peers_unlock(hp->rrp.peers); return hp->get_rr_peer(pc, &hp->rrp); } @@ -511,7 +511,7 @@ ngx_stream_upstream_get_chash_peer(ngx_peer_connection_t *pc, void *data) ngx_stream_upstream_rr_peers_wlock(hp->rrp.peers); - if (hp->tries > 20 || hp->rrp.peers->single) { + if (hp->tries > 20 || hp->rrp.peers->single || hp->key.len == 0) { ngx_stream_upstream_rr_peers_unlock(hp->rrp.peers); return hp->get_rr_peer(pc, &hp->rrp); } |