|
| 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 2016-05-31 15:43:51.000000000 +0200 |
| 3 | ++++ src/http/modules/ngx_http_upstream_hash_module.c 2016-06-22 17:20:19.553955295 +0200 |
| 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 @@ |
| 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 | +@@ -535,6 +548,15 @@ |
| 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 2016-05-31 15:43:51.000000000 +0200 |
| 49 | ++++ src/http/modules/ngx_http_upstream_ip_hash_module.c 2016-06-22 17:21:38.465741397 +0200 |
| 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 @@ |
| 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 2016-05-31 15:43:51.000000000 +0200 |
| 78 | ++++ src/http/modules/ngx_http_upstream_least_conn_module.c 2016-06-22 17:23:04.165509237 +0200 |
| 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 | +@@ -148,6 +152,16 @@ |
| 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 | +@@ -199,6 +213,16 @@ |
| 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 | + |
| 125 | +diff --git src/http/ngx_http_upstream_round_robin.c src/http/ngx_http_upstream_round_robin.c |
| 126 | +--- src/http/ngx_http_upstream_round_robin.c 2016-05-31 15:43:51.000000000 +0200 |
| 127 | ++++ src/http/ngx_http_upstream_round_robin.c 2016-06-22 17:27:03.200862423 +0200 |
| 128 | +@@ -9,6 +9,9 @@ |
| 129 | + #include <ngx_core.h> |
| 130 | + #include <ngx_http.h> |
| 131 | + |
| 132 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 133 | ++#include "ngx_http_upstream_check_module.h" |
| 134 | ++#endif |
| 135 | + |
| 136 | + #define ngx_http_upstream_tries(p) ((p)->number \ |
| 137 | + + ((p)->next ? (p)->next->number : 0)) |
| 138 | +@@ -96,7 +99,14 @@ |
| 139 | + peer[n].fail_timeout = server[i].fail_timeout; |
| 140 | + peer[n].down = server[i].down; |
| 141 | + peer[n].server = server[i].name; |
| 142 | +- |
| 143 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 144 | ++ if (!server[i].down) { |
| 145 | ++ peer[n].check_index = |
| 146 | ++ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]); |
| 147 | ++ } else { |
| 148 | ++ peer[n].check_index = (ngx_uint_t) NGX_ERROR; |
| 149 | ++ } |
| 150 | ++#endif |
| 151 | + *peerp = &peer[n]; |
| 152 | + peerp = &peer[n].next; |
| 153 | + n++; |
| 154 | +@@ -159,7 +169,15 @@ |
| 155 | + peer[n].fail_timeout = server[i].fail_timeout; |
| 156 | + peer[n].down = server[i].down; |
| 157 | + peer[n].server = server[i].name; |
| 158 | +- |
| 159 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 160 | ++ if (!server[i].down) { |
| 161 | ++ peer[n].check_index = |
| 162 | ++ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]); |
| 163 | ++ } |
| 164 | ++ else { |
| 165 | ++ peer[n].check_index = (ngx_uint_t) NGX_ERROR; |
| 166 | ++ } |
| 167 | ++#endif |
| 168 | + *peerp = &peer[n]; |
| 169 | + peerp = &peer[n].next; |
| 170 | + n++; |
| 171 | +@@ -225,6 +243,9 @@ |
| 172 | + peer[i].current_weight = 0; |
| 173 | + peer[i].max_fails = 1; |
| 174 | + peer[i].fail_timeout = 10; |
| 175 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 176 | ++ peer[i].check_index = (ngx_uint_t) NGX_ERROR; |
| 177 | ++#endif |
| 178 | + *peerp = &peer[i]; |
| 179 | + peerp = &peer[i].next; |
| 180 | + } |
| 181 | +@@ -339,6 +360,9 @@ |
| 182 | + peer[0].current_weight = 0; |
| 183 | + peer[0].max_fails = 1; |
| 184 | + peer[0].fail_timeout = 10; |
| 185 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 186 | ++ peer[0].check_index = (ngx_uint_t) NGX_ERROR; |
| 187 | ++#endif |
| 188 | + peers->peer = peer; |
| 189 | + |
| 190 | + } else { |
| 191 | +@@ -381,6 +405,9 @@ |
| 192 | + peer[i].current_weight = 0; |
| 193 | + peer[i].max_fails = 1; |
| 194 | + peer[i].fail_timeout = 10; |
| 195 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 196 | ++ peer[i].check_index = (ngx_uint_t) NGX_ERROR; |
| 197 | ++#endif |
| 198 | + *peerp = &peer[i]; |
| 199 | + peerp = &peer[i].next; |
| 200 | + } |
| 201 | +@@ -441,6 +468,12 @@ |
| 202 | + goto failed; |
| 203 | + } |
| 204 | + |
| 205 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 206 | ++ if (ngx_http_upstream_check_peer_down(peer->check_index)) { |
| 207 | ++ goto failed; |
| 208 | ++ } |
| 209 | ++#endif |
| 210 | ++ |
| 211 | + rrp->current = peer; |
| 212 | + |
| 213 | + } else { |
| 214 | +@@ -542,6 +575,12 @@ |
| 215 | + continue; |
| 216 | + } |
| 217 | + |
| 218 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 219 | ++ if (ngx_http_upstream_check_peer_down(peer->check_index)) { |
| 220 | ++ continue; |
| 221 | ++ } |
| 222 | ++#endif |
| 223 | ++ |
| 224 | + if (peer->max_fails |
| 225 | + && peer->fails >= peer->max_fails |
| 226 | + && now - peer->checked <= peer->fail_timeout) |
| 227 | +diff --git src/http/ngx_http_upstream_round_robin.h src/http/ngx_http_upstream_round_robin.h |
| 228 | +--- src/http/ngx_http_upstream_round_robin.h 2016-05-31 15:43:51.000000000 +0200 |
| 229 | ++++ src/http/ngx_http_upstream_round_robin.h 2016-06-22 17:27:47.316743162 +0200 |
| 230 | +@@ -35,6 +35,10 @@ |
| 231 | + ngx_uint_t max_fails; |
| 232 | + time_t fail_timeout; |
| 233 | + |
| 234 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 235 | ++ ngx_uint_t check_index; |
| 236 | ++#endif |
| 237 | ++ |
| 238 | + ngx_uint_t down; /* unsigned down:1; */ |
| 239 | + |
| 240 | + #if (NGX_HTTP_SSL) |
| 241 | + |
0 commit comments