Index: ngx_http_sticky_module.c
===================================================================
--- ngx_http_sticky_module.c	(revision 45)
+++ ngx_http_sticky_module.c	(working copy)
@@ -10,6 +10,11 @@
 
 #include "ngx_http_sticky_misc.h"
 
+#if (NGX_HTTP_UPSTREAM_CHECK)
+#include "ngx_http_upstream_check_module.h"
+#endif
+
+
 /* define a peer */
 typedef struct {
 	ngx_http_upstream_rr_peer_t *rr_peer;
@@ -287,6 +292,16 @@
 					return NGX_BUSY;
 				}
 
+#if (NGX_HTTP_UPSTREAM_CHECK)
+                ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
+                               "get sticky peer, check_index: %ui",
+                               peer->check_index);
+
+                if (ngx_http_upstream_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) {
@@ -303,6 +318,14 @@
 			/* ensure the peer is not marked as down */
 			if (!peer->down) {
 
+#if (NGX_HTTP_UPSTREAM_CHECK)
+                ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
+                               "get sticky peer, check_index: %ui",
+                               peer->check_index);
+
+                if (!ngx_http_upstream_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;
@@ -317,6 +340,9 @@
 					/* mark the peer as tried */
 					iphp->rrp.tried[n] |= m;
 				}
+#if (NGX_HTTP_UPSTREAM_CHECK)
+                }
+#endif
 			}
 		}
 	}
