@@ -5,18 +5,18 @@ index fd9ecbe..d3849b6 100644
5
5
@@ -9,6 +9,10 @@
6
6
#include <ngx_core.h>
7
7
#include <ngx_http.h>
8
-
8
+
9
9
+ #if (NGX_UPSTREAM_CHECK_MODULE)
10
10
+ #include "ngx_http_upstream_check_handler.h"
11
11
+ #endif
12
12
+
13
-
13
+
14
14
typedef struct {
15
15
/* the round robin data must be first */
16
16
@@ -182,6 +186,12 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
17
-
17
+
18
18
if (!peer->down) {
19
-
19
+
20
20
+ #if (NGX_UPSTREAM_CHECK_MODULE)
21
21
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
22
22
+ "get ip_hash peer, check_index: %ui",
@@ -34,7 +34,7 @@ index fd9ecbe..d3849b6 100644
34
34
+ }
35
35
+ #endif
36
36
}
37
-
37
+
38
38
iphp->rrp.tried[n] |= m;
39
39
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
40
40
index afc9b2e..1c0344e 100644
@@ -43,11 +43,11 @@ index afc9b2e..1c0344e 100644
43
43
@@ -9,6 +9,9 @@
44
44
#include <ngx_core.h>
45
45
#include <ngx_http.h>
46
-
46
+
47
47
+ #if (NGX_UPSTREAM_CHECK_MODULE)
48
48
+ #include "ngx_http_upstream_check_handler.h"
49
49
+ #endif
50
-
50
+
51
51
static ngx_int_t ngx_http_upstream_cmp_servers(const void *one,
52
52
const void *two);
53
53
@@ -75,6 +78,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
@@ -57,7 +57,7 @@ index afc9b2e..1c0344e 100644
57
57
+
58
58
+ #if (NGX_UPSTREAM_CHECK_MODULE)
59
59
+ if (!server[i].down) {
60
- + peers->peer[n].check_index =
60
+ + peers->peer[n].check_index =
61
61
+ ngx_http_check_add_peer(cf, us, &server[i].addrs[j]);
62
62
+ }
63
63
+ else {
@@ -75,7 +75,7 @@ index afc9b2e..1c0344e 100644
75
75
+
76
76
+ #if (NGX_UPSTREAM_CHECK_MODULE)
77
77
+ if (!server[i].down) {
78
- + backup->peer[n].check_index =
78
+ + backup->peer[n].check_index =
79
79
+ ngx_http_check_add_peer(cf, us, &server[i].addrs[j]);
80
80
+ }
81
81
+ else {
@@ -94,7 +94,7 @@ index afc9b2e..1c0344e 100644
94
94
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
95
95
+ #endif
96
96
}
97
-
97
+
98
98
us->peer.data = peers;
99
99
@@ -302,6 +330,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
100
100
peers->peer[0].current_weight = 1;
@@ -103,9 +103,9 @@ index afc9b2e..1c0344e 100644
103
103
+ #if (NGX_UPSTREAM_CHECK_MODULE)
104
104
+ peers->peer[0].check_index = (ngx_uint_t) NGX_ERROR;
105
105
+ #endif
106
-
106
+
107
107
} else {
108
-
108
+
109
109
@@ -334,6 +365,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
110
110
peers->peer[i].current_weight = 1;
111
111
peers->peer[i].max_fails = 1;
@@ -115,9 +115,9 @@ index afc9b2e..1c0344e 100644
115
115
+ #endif
116
116
}
117
117
}
118
-
118
+
119
119
@@ -411,7 +445,11 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
120
-
120
+
121
121
if (rrp->peers->single) {
122
122
peer = &rrp->peers->peer[0];
123
123
-
@@ -127,15 +127,15 @@ index afc9b2e..1c0344e 100644
127
127
+ }
128
128
+ #endif
129
129
} else {
130
-
130
+
131
131
/* there are several peers */
132
132
@@ -438,6 +476,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
133
-
133
+
134
134
if (!peer->down) {
135
-
135
+
136
136
+ #if (NGX_UPSTREAM_CHECK_MODULE)
137
137
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
138
- + "get rr peer, check_index: %ui",
138
+ + "get rr peer, check_index: %ui",
139
139
+ peer->check_index);
140
140
+ if (!ngx_http_check_peer_down(peer->check_index)) {
141
141
+ #endif
@@ -149,13 +149,13 @@ index afc9b2e..1c0344e 100644
149
149
+ #if (NGX_UPSTREAM_CHECK_MODULE)
150
150
+ }
151
151
+ #endif
152
-
152
+
153
153
peer->current_weight = 0;
154
-
154
+
155
155
@@ -486,6 +533,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
156
-
156
+
157
157
if (!peer->down) {
158
-
158
+
159
159
+ #if (NGX_UPSTREAM_CHECK_MODULE)
160
160
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
161
161
+ "get rr peer2, check_index: %ui",
@@ -172,21 +172,21 @@ index afc9b2e..1c0344e 100644
172
172
+ #if (NGX_UPSTREAM_CHECK_MODULE)
173
173
+ }
174
174
+ #endif
175
-
175
+
176
176
peer->current_weight = 0;
177
-
177
+
178
178
diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h
179
179
index 6d285ab..354cca2 100644
180
180
--- a/src/http/ngx_http_upstream_round_robin.h
181
181
+++ b/src/http/ngx_http_upstream_round_robin.h
182
182
@@ -28,6 +28,10 @@ typedef struct {
183
183
ngx_uint_t max_fails;
184
184
time_t fail_timeout;
185
-
185
+
186
186
+ #if (NGX_UPSTREAM_CHECK_MODULE)
187
187
+ ngx_uint_t check_index;
188
188
+ #endif
189
189
+
190
190
ngx_uint_t down; /* unsigned down:1; */
191
-
191
+
192
192
#if (NGX_HTTP_SSL)
0 commit comments