Skip to content

Commit 34f873d

Browse files
Lukasz Jagiellodenji
Lukasz Jagiello
authored andcommitted
Patch for nginx 1.14.0+
Nginx 1.14 was released recently in this PR working patch for the latest stable nginx.
1 parent 9688451 commit 34f873d

File tree

1 file changed

+236
-0
lines changed

1 file changed

+236
-0
lines changed

check_1.14.0+.patch

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

0 commit comments

Comments
 (0)