diff --git a/src/http/modules/ngx_http_upstream_hash_module.c b/src/http/modules/ngx_http_upstream_hash_module.c index 530d205acd..18d6c6ec67 100644 --- a/src/http/modules/ngx_http_upstream_hash_module.c +++ b/src/http/modules/ngx_http_upstream_hash_module.c @@ -562,6 +562,15 @@ ngx_http_upstream_get_chash_peer(ngx_peer_connection_t *pc, void *data) continue; } +#if (NGX_HTTP_UPSTREAM_CHECK) + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get chash peer, check_index: %ui", + peer->check_index); + if (ngx_http_upstream_check_peer_down(peer->check_index)) { + continue; + } +#endif + if (peer->max_fails && peer->fails >= peer->max_fails && now - peer->checked <= peer->fail_timeout) diff --git a/src/http/modules/ngx_http_upstream_random_module.c b/src/http/modules/ngx_http_upstream_random_module.c index 6f169c8f6a..87d1ec3137 100644 --- a/src/http/modules/ngx_http_upstream_random_module.c +++ b/src/http/modules/ngx_http_upstream_random_module.c @@ -8,6 +8,9 @@ #include #include +#if (NGX_HTTP_UPSTREAM_CHECK) +#include "ngx_http_upstream_check_module.h" +#endif typedef struct { ngx_http_upstream_rr_peer_t *peer; @@ -250,6 +253,17 @@ ngx_http_upstream_get_random_peer(ngx_peer_connection_t *pc, void *data) goto next; } +#if (NGX_HTTP_UPSTREAM_CHECK) + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get random peer, check_index: %ui", + peer->check_index); + + if (ngx_http_upstream_check_peer_down(peer->check_index)) { + ngx_http_upstream_rr_peer_unlock(peers, peer); + goto next; + } +#endif + if (peer->max_fails && peer->fails >= peer->max_fails && now - peer->checked <= peer->fail_timeout) @@ -351,6 +365,16 @@ ngx_http_upstream_get_random2_peer(ngx_peer_connection_t *pc, void *data) goto next; } +#if (NGX_HTTP_UPSTREAM_CHECK) + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get random peer, check_index: %ui", + peer->check_index); + + if (ngx_http_upstream_check_peer_down(peer->check_index)) { + goto next; + } +#endif + if (peer->max_fails && peer->fails >= peer->max_fails && now - peer->checked <= peer->fail_timeout)