1 |
zx2c4 14/02/10 03:12:24 |
2 |
|
3 |
Added: upstream-check-1.5.8.patch |
4 |
Log: |
5 |
Provisonal version bump. |
6 |
|
7 |
(Portage version: 2.2.8-r1/cvs/Linux x86_64, signed Manifest commit with key A5DE03AE) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 www-servers/nginx/files/upstream-check-1.5.8.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-servers/nginx/files/upstream-check-1.5.8.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-servers/nginx/files/upstream-check-1.5.8.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: upstream-check-1.5.8.patch |
16 |
=================================================================== |
17 |
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c |
18 |
index 89ccc2b..a552044 100644 |
19 |
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c |
20 |
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c |
21 |
@@ -9,6 +9,10 @@ |
22 |
#include <ngx_core.h> |
23 |
#include <ngx_http.h> |
24 |
|
25 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
26 |
+#include "ngx_http_upstream_check_handler.h" |
27 |
+#endif |
28 |
+ |
29 |
|
30 |
typedef struct { |
31 |
/* the round robin data must be first */ |
32 |
@@ -208,6 +212,12 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data) |
33 |
|
34 |
if (!peer->down) { |
35 |
|
36 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
37 |
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
38 |
+ "get ip_hash peer, check_index: %ui", |
39 |
+ peer->check_index); |
40 |
+ if (!ngx_http_check_peer_down(peer->check_index)) { |
41 |
+#endif |
42 |
if (peer->max_fails == 0 || peer->fails < peer->max_fails) { |
43 |
break; |
44 |
} |
45 |
@@ -216,6 +226,9 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data) |
46 |
peer->checked = now; |
47 |
break; |
48 |
} |
49 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
50 |
+ } |
51 |
+#endif |
52 |
} |
53 |
|
54 |
iphp->rrp.tried[n] |= m; |
55 |
diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c b/src/http/modules/ngx_http_upstream_least_conn_module.c |
56 |
index 21156ae..c57393d 100644 |
57 |
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c |
58 |
+++ b/src/http/modules/ngx_http_upstream_least_conn_module.c |
59 |
@@ -9,6 +9,10 @@ |
60 |
#include <ngx_core.h> |
61 |
#include <ngx_http.h> |
62 |
|
63 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
64 |
+#include "ngx_http_upstream_check_handler.h" |
65 |
+#endif |
66 |
+ |
67 |
|
68 |
typedef struct { |
69 |
ngx_uint_t *conns; |
70 |
@@ -203,6 +207,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data) |
71 |
continue; |
72 |
} |
73 |
|
74 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
75 |
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
76 |
+ "get least_conn peer, check_index: %ui", |
77 |
+ peer->check_index); |
78 |
+ |
79 |
+ if (ngx_http_check_peer_down(peer->check_index)) { |
80 |
+ continue; |
81 |
+ } |
82 |
+#endif |
83 |
+ |
84 |
if (peer->max_fails |
85 |
&& peer->fails >= peer->max_fails |
86 |
&& now - peer->checked <= peer->fail_timeout) |
87 |
@@ -256,6 +270,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data) |
88 |
continue; |
89 |
} |
90 |
|
91 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
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_check_peer_down(peer->check_index)) { |
97 |
+ continue; |
98 |
+ } |
99 |
+#endif |
100 |
+ |
101 |
if (lcp->conns[i] * best->weight != lcp->conns[p] * peer->weight) { |
102 |
continue; |
103 |
} |
104 |
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c |
105 |
index 4b78cff..f077b46 100644 |
106 |
--- a/src/http/ngx_http_upstream_round_robin.c |
107 |
+++ b/src/http/ngx_http_upstream_round_robin.c |
108 |
@@ -9,6 +9,9 @@ |
109 |
#include <ngx_core.h> |
110 |
#include <ngx_http.h> |
111 |
|
112 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
113 |
+#include "ngx_http_upstream_check_handler.h" |
114 |
+#endif |
115 |
|
116 |
static ngx_http_upstream_rr_peer_t *ngx_http_upstream_get_peer( |
117 |
ngx_http_upstream_rr_peer_data_t *rrp); |
118 |
@@ -85,6 +88,16 @@ |
119 |
peers->peer[n].max_fails = server[i].max_fails; |
120 |
peers->peer[n].fail_timeout = server[i].fail_timeout; |
121 |
peers->peer[n].down = server[i].down; |
122 |
+ |
123 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
124 |
+ if (!server[i].down) { |
125 |
+ peers->peer[n].check_index = |
126 |
+ ngx_http_check_add_peer(cf, us, &server[i].addrs[j]); |
127 |
+ } |
128 |
+ else { |
129 |
+ peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR; |
130 |
+ } |
131 |
+#endif |
132 |
n++; |
133 |
} |
134 |
} |
135 |
@@ -139,6 +152,17 @@ |
136 |
backup->peer[n].max_fails = server[i].max_fails; |
137 |
backup->peer[n].fail_timeout = server[i].fail_timeout; |
138 |
backup->peer[n].down = server[i].down; |
139 |
+ |
140 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
141 |
+ if (!server[i].down) { |
142 |
+ backup->peer[n].check_index = |
143 |
+ ngx_http_check_add_peer(cf, us, &server[i].addrs[j]); |
144 |
+ } |
145 |
+ else { |
146 |
+ backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR; |
147 |
+ } |
148 |
+#endif |
149 |
+ |
150 |
n++; |
151 |
} |
152 |
} |
153 |
@@ -196,6 +220,9 @@ |
154 |
peers->peer[i].current_weight = 0; |
155 |
peers->peer[i].max_fails = 1; |
156 |
peers->peer[i].fail_timeout = 10; |
157 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
158 |
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR; |
159 |
+#endif |
160 |
} |
161 |
|
162 |
us->peer.data = peers; |
163 |
@@ -302,6 +329,9 @@ |
164 |
peers->peer[0].current_weight = 0; |
165 |
peers->peer[0].max_fails = 1; |
166 |
peers->peer[0].fail_timeout = 10; |
167 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
168 |
+ peers->peer[0].check_index = (ngx_uint_t) NGX_ERROR; |
169 |
+#endif |
170 |
|
171 |
} else { |
172 |
|
173 |
@@ -342,6 +372,9 @@ |
174 |
peers->peer[i].current_weight = 0; |
175 |
peers->peer[i].max_fails = 1; |
176 |
peers->peer[i].fail_timeout = 10; |
177 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
178 |
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR; |
179 |
+#endif |
180 |
} |
181 |
} |
182 |
|
183 |
@@ -399,6 +432,12 @@ |
184 |
goto failed; |
185 |
} |
186 |
|
187 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
188 |
+ if (ngx_http_check_peer_down(peer->check_index)) { |
189 |
+ goto failed; |
190 |
+ } |
191 |
+#endif |
192 |
+ |
193 |
} else { |
194 |
|
195 |
/* there are several peers */ |
196 |
@@ -498,6 +537,12 @@ |
197 |
continue; |
198 |
} |
199 |
|
200 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
201 |
+ if (ngx_http_check_peer_down(peer->check_index)) { |
202 |
+ continue; |
203 |
+ } |
204 |
+#endif |
205 |
+ |
206 |
if (peer->max_fails |
207 |
&& peer->fails >= peer->max_fails |
208 |
&& now - peer->checked <= peer->fail_timeout) |
209 |
diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h |
210 |
index 3f8cbf8..1613168 100644 |
211 |
--- a/src/http/ngx_http_upstream_round_robin.h |
212 |
+++ b/src/http/ngx_http_upstream_round_robin.h |
213 |
@@ -30,6 +30,10 @@ typedef struct { |
214 |
ngx_uint_t max_fails; |
215 |
time_t fail_timeout; |
216 |
|
217 |
+#if (NGX_UPSTREAM_CHECK_MODULE) |
218 |
+ ngx_uint_t check_index; |
219 |
+#endif |
220 |
+ |
221 |
ngx_uint_t down; /* unsigned down:1; */ |
222 |
|
223 |
#if (NGX_HTTP_SSL) |