Skip to content

Commit d40b9f9

Browse files
committed
added the patch for nginx-1.5.12+
1 parent ff5e637 commit d40b9f9

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed

check_1.5.12+.patch

+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
2+
index 041883f..5dac45c 100644
3+
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
4+
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
5+
@@ -9,6 +9,10 @@
6+
#include <ngx_core.h>
7+
#include <ngx_http.h>
8+
9+
+#if (NGX_UPSTREAM_CHECK_MODULE)
10+
+#include "ngx_http_upstream_check_handler.h"
11+
+#endif
12+
+
13+
14+
typedef struct {
15+
/* the round robin data must be first */
16+
@@ -212,6 +216,15 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
17+
goto next_try;
18+
}
19+
20+
+#if (NGX_UPSTREAM_CHECK_MODULE)
21+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
22+
+ "get ip_hash peer, check_index: %ui",
23+
+ peer->check_index);
24+
+ if (ngx_http_check_peer_down(peer->check_index)) {
25+
+ goto next_try;
26+
+ }
27+
+#endif
28+
+
29+
if (peer->max_fails
30+
&& peer->fails >= peer->max_fails
31+
&& now - peer->checked <= peer->fail_timeout)
32+
diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c b/src/http/modules/ngx_http_upstream_least_conn_module.c
33+
index dbef95d..e080682 100644
34+
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c
35+
+++ b/src/http/modules/ngx_http_upstream_least_conn_module.c
36+
@@ -9,6 +9,10 @@
37+
#include <ngx_core.h>
38+
#include <ngx_http.h>
39+
40+
+#if (NGX_UPSTREAM_CHECK_MODULE)
41+
+#include "ngx_http_upstream_check_handler.h"
42+
+#endif
43+
+
44+
45+
typedef struct {
46+
ngx_uint_t *conns;
47+
@@ -203,6 +207,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
48+
continue;
49+
}
50+
51+
+#if (NGX_UPSTREAM_CHECK_MODULE)
52+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
53+
+ "get least_conn peer, check_index: %ui",
54+
+ peer->check_index);
55+
+
56+
+ if (ngx_http_check_peer_down(peer->check_index)) {
57+
+ continue;
58+
+ }
59+
+#endif
60+
+
61+
if (peer->max_fails
62+
&& peer->fails >= peer->max_fails
63+
&& now - peer->checked <= peer->fail_timeout)
64+
@@ -256,6 +270,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
65+
continue;
66+
}
67+
68+
+#if (NGX_UPSTREAM_CHECK_MODULE)
69+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
70+
+ "get least_conn peer, check_index: %ui",
71+
+ peer->check_index);
72+
+
73+
+ if (ngx_http_check_peer_down(peer->check_index)) {
74+
+ continue;
75+
+ }
76+
+#endif
77+
+
78+
if (lcp->conns[i] * best->weight != lcp->conns[p] * peer->weight) {
79+
continue;
80+
}
81+
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
82+
index 85ff558..c500530 100644
83+
--- a/src/http/ngx_http_upstream_round_robin.c
84+
+++ b/src/http/ngx_http_upstream_round_robin.c
85+
@@ -9,6 +9,9 @@
86+
#include <ngx_core.h>
87+
#include <ngx_http.h>
88+
89+
+#if (NGX_UPSTREAM_CHECK_MODULE)
90+
+#include "ngx_http_upstream_check_handler.h"
91+
+#endif
92+
93+
static ngx_http_upstream_rr_peer_t *ngx_http_upstream_get_peer(
94+
ngx_http_upstream_rr_peer_data_t *rrp);
95+
@@ -85,6 +88,14 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
96+
peers->peer[n].max_fails = server[i].max_fails;
97+
peers->peer[n].fail_timeout = server[i].fail_timeout;
98+
peers->peer[n].down = server[i].down;
99+
+#if (NGX_UPSTREAM_CHECK_MODULE)
100+
+ if (!server[i].down) {
101+
+ peers->peer[n].check_index =
102+
+ ngx_http_check_add_peer(cf, us, &server[i].addrs[j]);
103+
+ } else {
104+
+ peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
105+
+ }
106+
+#endif
107+
n++;
108+
}
109+
}
110+
@@ -139,6 +150,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
111+
backup->peer[n].max_fails = server[i].max_fails;
112+
backup->peer[n].fail_timeout = server[i].fail_timeout;
113+
backup->peer[n].down = server[i].down;
114+
+
115+
+#if (NGX_UPSTREAM_CHECK_MODULE)
116+
+ if (!server[i].down) {
117+
+ backup->peer[n].check_index =
118+
+ ngx_http_check_add_peer(cf, us, &server[i].addrs[j]);
119+
+ }
120+
+ else {
121+
+ backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
122+
+ }
123+
+#endif
124+
+
125+
n++;
126+
}
127+
}
128+
@@ -196,6 +218,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
129+
peers->peer[i].current_weight = 0;
130+
peers->peer[i].max_fails = 1;
131+
peers->peer[i].fail_timeout = 10;
132+
+#if (NGX_UPSTREAM_CHECK_MODULE)
133+
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
134+
+#endif
135+
}
136+
137+
us->peer.data = peers;
138+
@@ -302,6 +327,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
139+
peers->peer[0].current_weight = 0;
140+
peers->peer[0].max_fails = 1;
141+
peers->peer[0].fail_timeout = 10;
142+
+#if (NGX_UPSTREAM_CHECK_MODULE)
143+
+ peers->peer[0].check_index = (ngx_uint_t) NGX_ERROR;
144+
+#endif
145+
146+
} else {
147+
148+
@@ -342,6 +370,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
149+
peers->peer[i].current_weight = 0;
150+
peers->peer[i].max_fails = 1;
151+
peers->peer[i].fail_timeout = 10;
152+
+#if (NGX_UPSTREAM_CHECK_MODULE)
153+
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
154+
+#endif
155+
}
156+
}
157+
158+
@@ -399,6 +430,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
159+
goto failed;
160+
}
161+
162+
+#if (NGX_UPSTREAM_CHECK_MODULE)
163+
+ if (ngx_http_check_peer_down(peer->check_index)) {
164+
+ goto failed;
165+
+ }
166+
+#endif
167+
+
168+
} else {
169+
170+
/* there are several peers */
171+
@@ -498,6 +535,12 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp)
172+
continue;
173+
}
174+
175+
+#if (NGX_UPSTREAM_CHECK_MODULE)
176+
+ if (ngx_http_check_peer_down(peer->check_index)) {
177+
+ continue;
178+
+ }
179+
+#endif
180+
+
181+
if (peer->max_fails
182+
&& peer->fails >= peer->max_fails
183+
&& now - peer->checked <= peer->fail_timeout)
184+
diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h
185+
index ea90ab9..ccff3c2 100644
186+
--- a/src/http/ngx_http_upstream_round_robin.h
187+
+++ b/src/http/ngx_http_upstream_round_robin.h
188+
@@ -30,6 +30,10 @@ typedef struct {
189+
ngx_uint_t max_fails;
190+
time_t fail_timeout;
191+
192+
+#if (NGX_UPSTREAM_CHECK_MODULE)
193+
+ ngx_uint_t check_index;
194+
+#endif
195+
+
196+
ngx_uint_t down; /* unsigned down:1; */
197+
198+
#if (NGX_HTTP_SSL)

0 commit comments

Comments
 (0)