Skip to content

Commit db04af6

Browse files
committed
Respin patch against nginx v1.11.5
Fixes: yaoweibin#118
1 parent f3bdb7b commit db04af6

File tree

1 file changed

+239
-0
lines changed

1 file changed

+239
-0
lines changed

check_1.11.5+.patch

+239
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
diff --git src/http/modules/ngx_http_upstream_hash_module.c src/http/modules/ngx_http_upstream_hash_module.c
2+
--- src/http/modules/ngx_http_upstream_hash_module.c
3+
+++ src/http/modules/ngx_http_upstream_hash_module.c
4+
@@ -9,6 +9,9 @@
5+
#include <ngx_core.h>
6+
#include <ngx_http.h>
7+
8+
+#if (NGX_HTTP_UPSTREAM_CHECK)
9+
+#include "ngx_http_upstream_check_module.h"
10+
+#endif
11+
12+
typedef struct {
13+
uint32_t hash;
14+
@@ -235,6 +238,16 @@ ngx_http_upstream_get_hash_peer(ngx_peer_connection_t *pc, void *data)
15+
goto next;
16+
}
17+
18+
+#if (NGX_HTTP_UPSTREAM_CHECK)
19+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
20+
+ "get hash peer, check_index: %ui",
21+
+ peer->check_index);
22+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
23+
+ goto next;
24+
+ }
25+
+#endif
26+
+
27+
+
28+
if (peer->max_fails
29+
&& peer->fails >= peer->max_fails
30+
&& now - peer->checked <= peer->fail_timeout)
31+
@@ -538,6 +551,15 @@ ngx_http_upstream_get_chash_peer(ngx_peer_connection_t *pc, void *data)
32+
continue;
33+
}
34+
35+
+#if (NGX_HTTP_UPSTREAM_CHECK)
36+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
37+
+ "get consistent_hash peer, check_index: %ui",
38+
+ peer->check_index);
39+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
40+
+ continue;
41+
+ }
42+
+#endif
43+
+
44+
if (peer->server.len != server->len
45+
|| ngx_strncmp(peer->server.data, server->data, server->len)
46+
!= 0)
47+
diff --git src/http/modules/ngx_http_upstream_ip_hash_module.c src/http/modules/ngx_http_upstream_ip_hash_module.c
48+
--- src/http/modules/ngx_http_upstream_ip_hash_module.c
49+
+++ src/http/modules/ngx_http_upstream_ip_hash_module.c
50+
@@ -9,6 +9,9 @@
51+
#include <ngx_core.h>
52+
#include <ngx_http.h>
53+
54+
+#if (NGX_HTTP_UPSTREAM_CHECK)
55+
+#include "ngx_http_upstream_check_module.h"
56+
+#endif
57+
58+
typedef struct {
59+
/* the round robin data must be first */
60+
@@ -205,6 +208,15 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
61+
goto next;
62+
}
63+
64+
+#if (NGX_HTTP_UPSTREAM_CHECK)
65+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
66+
+ "get ip_hash peer, check_index: %ui",
67+
+ peer->check_index);
68+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
69+
+ goto next;
70+
+ }
71+
+#endif
72+
+
73+
if (peer->max_fails
74+
&& peer->fails >= peer->max_fails
75+
&& now - peer->checked <= peer->fail_timeout)
76+
diff --git src/http/modules/ngx_http_upstream_least_conn_module.c src/http/modules/ngx_http_upstream_least_conn_module.c
77+
--- src/http/modules/ngx_http_upstream_least_conn_module.c
78+
+++ src/http/modules/ngx_http_upstream_least_conn_module.c
79+
@@ -9,6 +9,10 @@
80+
#include <ngx_core.h>
81+
#include <ngx_http.h>
82+
83+
+#if (NGX_HTTP_UPSTREAM_CHECK)
84+
+#include "ngx_http_upstream_check_module.h"
85+
+#endif
86+
+
87+
88+
static ngx_int_t ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r,
89+
ngx_http_upstream_srv_conf_t *us);
90+
@@ -147,6 +151,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
91+
continue;
92+
}
93+
94+
+#if (NGX_HTTP_UPSTREAM_CHECK)
95+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
96+
+ "get least_conn peer, check_index: %ui",
97+
+ peer->check_index);
98+
+
99+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
100+
+ continue;
101+
+ }
102+
+#endif
103+
+
104+
if (peer->max_fails
105+
&& peer->fails >= peer->max_fails
106+
&& now - peer->checked <= peer->fail_timeout)
107+
@@ -202,6 +216,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
108+
continue;
109+
}
110+
111+
+#if (NGX_HTTP_UPSTREAM_CHECK)
112+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
113+
+ "get least_conn peer, check_index: %ui",
114+
+ peer->check_index);
115+
+
116+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
117+
+ continue;
118+
+ }
119+
+#endif
120+
+
121+
if (peer->conns * best->weight != best->conns * peer->weight) {
122+
continue;
123+
}
124+
diff --git src/http/ngx_http_upstream_round_robin.c src/http/ngx_http_upstream_round_robin.c
125+
--- src/http/ngx_http_upstream_round_robin.c
126+
+++ src/http/ngx_http_upstream_round_robin.c
127+
@@ -9,6 +9,9 @@
128+
#include <ngx_core.h>
129+
#include <ngx_http.h>
130+
131+
+#if (NGX_HTTP_UPSTREAM_CHECK)
132+
+#include "ngx_http_upstream_check_module.h"
133+
+#endif
134+
135+
#define ngx_http_upstream_tries(p) ((p)->number \
136+
+ ((p)->next ? (p)->next->number : 0))
137+
@@ -97,7 +100,14 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
138+
peer[n].fail_timeout = server[i].fail_timeout;
139+
peer[n].down = server[i].down;
140+
peer[n].server = server[i].name;
141+
-
142+
+#if (NGX_HTTP_UPSTREAM_CHECK)
143+
+ if (!server[i].down) {
144+
+ peer[n].check_index =
145+
+ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
146+
+ } else {
147+
+ peer[n].check_index = (ngx_uint_t) NGX_ERROR;
148+
+ }
149+
+#endif
150+
*peerp = &peer[n];
151+
peerp = &peer[n].next;
152+
n++;
153+
@@ -161,7 +171,15 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
154+
peer[n].fail_timeout = server[i].fail_timeout;
155+
peer[n].down = server[i].down;
156+
peer[n].server = server[i].name;
157+
-
158+
+#if (NGX_HTTP_UPSTREAM_CHECK)
159+
+ if (!server[i].down) {
160+
+ peer[n].check_index =
161+
+ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
162+
+ }
163+
+ else {
164+
+ peer[n].check_index = (ngx_uint_t) NGX_ERROR;
165+
+ }
166+
+#endif
167+
*peerp = &peer[n];
168+
peerp = &peer[n].next;
169+
n++;
170+
@@ -228,6 +246,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
171+
peer[i].max_conns = 0;
172+
peer[i].max_fails = 1;
173+
peer[i].fail_timeout = 10;
174+
+#if (NGX_HTTP_UPSTREAM_CHECK)
175+
+ peer[i].check_index = (ngx_uint_t) NGX_ERROR;
176+
+#endif
177+
*peerp = &peer[i];
178+
peerp = &peer[i].next;
179+
}
180+
@@ -344,6 +365,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
181+
peer[0].max_conns = 0;
182+
peer[0].max_fails = 1;
183+
peer[0].fail_timeout = 10;
184+
+#if (NGX_HTTP_UPSTREAM_CHECK)
185+
+ peer[0].check_index = (ngx_uint_t) NGX_ERROR;
186+
+#endif
187+
peers->peer = peer;
188+
189+
} else {
190+
@@ -378,6 +402,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
191+
peer[i].max_conns = 0;
192+
peer[i].max_fails = 1;
193+
peer[i].fail_timeout = 10;
194+
+#if (NGX_HTTP_UPSTREAM_CHECK)
195+
+ peer[i].check_index = (ngx_uint_t) NGX_ERROR;
196+
+#endif
197+
*peerp = &peer[i];
198+
peerp = &peer[i].next;
199+
}
200+
@@ -443,6 +470,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
201+
goto failed;
202+
}
203+
204+
+#if (NGX_HTTP_UPSTREAM_CHECK)
205+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
206+
+ goto failed;
207+
+ }
208+
+#endif
209+
+
210+
rrp->current = peer;
211+
212+
} else {
213+
@@ -537,6 +570,12 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp)
214+
continue;
215+
}
216+
217+
+#if (NGX_HTTP_UPSTREAM_CHECK)
218+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
219+
+ continue;
220+
+ }
221+
+#endif
222+
+
223+
if (peer->max_fails
224+
&& peer->fails >= peer->max_fails
225+
&& now - peer->checked <= peer->fail_timeout)
226+
diff --git src/http/ngx_http_upstream_round_robin.h src/http/ngx_http_upstream_round_robin.h
227+
--- src/http/ngx_http_upstream_round_robin.h
228+
+++ src/http/ngx_http_upstream_round_robin.h
229+
@@ -38,6 +38,10 @@ struct ngx_http_upstream_rr_peer_s {
230+
ngx_msec_t slow_start;
231+
ngx_msec_t start_time;
232+
233+
+#if (NGX_HTTP_UPSTREAM_CHECK)
234+
+ ngx_uint_t check_index;
235+
+#endif
236+
+
237+
ngx_uint_t down;
238+
239+
#if (NGX_HTTP_SSL || NGX_COMPAT)

0 commit comments

Comments
 (0)