diff --git a/ngx_http_sticky_module.c b/ngx_http_sticky_module.c index 9967428..f13d4b5 100644 --- a/ngx_http_sticky_module.c +++ b/ngx_http_sticky_module.c @@ -299,6 +299,16 @@ static ngx_int_t ngx_http_get_sticky_peer(ngx_peer_connection_t *pc, void *data) return NGX_BUSY; } +#if (NGX_UPSTREAM_CHECK_MODULE) + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get sticky peer, check_index: %ui", + peer->check_index); + + if (ngx_http_check_peer_down(peer->check_index)) { + return NGX_BUSY; + } +#endif + /* if it's been ignored for long enought (fail_timeout), reset timeout */ /* do this check before testing peer->fails ! :) */ if (now - peer->accessed > peer->fail_timeout) { @@ -315,6 +325,14 @@ static ngx_int_t ngx_http_get_sticky_peer(ngx_peer_connection_t *pc, void *data) /* ensure the peer is not marked as down */ if (!peer->down) { +#if (NGX_UPSTREAM_CHECK_MODULE) + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get sticky peer, check_index: %ui", + peer->check_index); + + if (!ngx_http_check_peer_down(peer->check_index)) { +#endif + /* if it's not failedi, use it */ if (peer->max_fails == 0 || peer->fails < peer->max_fails) { selected_peer = (ngx_int_t)n; @@ -329,6 +347,9 @@ static ngx_int_t ngx_http_get_sticky_peer(ngx_peer_connection_t *pc, void *data) /* mark the peer as tried */ iphp->rrp.tried[n] |= m; } +#if (NGX_UPSTREAM_CHECK_MODULE) + } +#endif } } }