forked from yaoweibin/nginx_upstream_check_module
-
Notifications
You must be signed in to change notification settings - Fork 23
/
nginx-sticky-module.patch
58 lines (54 loc) · 1.67 KB
/
nginx-sticky-module.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
}
}
}