|
| 1 | +diff -burN nginx-1.12.1_orig/src/http/modules/ngx_http_upstream_hash_module.c nginx-1.12.1/src/http/modules/ngx_http_upstream_hash_module.c |
| 2 | +--- nginx-1.12.1_orig/src/http/modules/ngx_http_upstream_hash_module.c 2017-07-11 13:24:08.000000000 +0000 |
| 3 | ++++ nginx-1.12.1/src/http/modules/ngx_http_upstream_hash_module.c 2017-07-13 17:58:44.687213233 +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 | +@@ -538,6 +549,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.12.1_orig/src/http/modules/ngx_http_upstream_ip_hash_module.c nginx-1.12.1/src/http/modules/ngx_http_upstream_ip_hash_module.c |
| 46 | +--- nginx-1.12.1_orig/src/http/modules/ngx_http_upstream_ip_hash_module.c 2017-07-11 13:24:08.000000000 +0000 |
| 47 | ++++ nginx-1.12.1/src/http/modules/ngx_http_upstream_ip_hash_module.c 2017-07-13 17:59:48.205692500 +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.12.1_orig/src/http/modules/ngx_http_upstream_least_conn_module.c nginx-1.12.1/src/http/modules/ngx_http_upstream_least_conn_module.c |
| 75 | +--- nginx-1.12.1_orig/src/http/modules/ngx_http_upstream_least_conn_module.c 2017-07-11 13:24:08.000000000 +0000 |
| 76 | ++++ nginx-1.12.1/src/http/modules/ngx_http_upstream_least_conn_module.c 2017-07-13 18:05:34.417398156 +0000 |
| 77 | +@@ -9,6 +9,10 @@ |
| 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 | + |
| 86 | + static ngx_int_t ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r, |
| 87 | + ngx_http_upstream_srv_conf_t *us); |
| 88 | +@@ -147,6 +151,16 @@ |
| 89 | + continue; |
| 90 | + } |
| 91 | + |
| 92 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 93 | ++ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
| 94 | ++ "get least_conn peer, check_index: %ui", |
| 95 | ++ peer->check_index); |
| 96 | ++ |
| 97 | ++ if (ngx_http_upstream_check_peer_down(peer->check_index)) { |
| 98 | ++ continue; |
| 99 | ++ } |
| 100 | ++#endif |
| 101 | ++ |
| 102 | + if (peer->max_fails |
| 103 | + && peer->fails >= peer->max_fails |
| 104 | + && now - peer->checked <= peer->fail_timeout) |
| 105 | +@@ -202,6 +216,16 @@ |
| 106 | + continue; |
| 107 | + } |
| 108 | + |
| 109 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 110 | ++ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
| 111 | ++ "get least_conn peer, check_index: %ui", |
| 112 | ++ peer->check_index); |
| 113 | ++ |
| 114 | ++ if (ngx_http_upstream_check_peer_down(peer->check_index)) { |
| 115 | ++ continue; |
| 116 | ++ } |
| 117 | ++#endif |
| 118 | ++ |
| 119 | + if (peer->conns * best->weight != best->conns * peer->weight) { |
| 120 | + continue; |
| 121 | + } |
| 122 | +diff -burN nginx-1.12.1_orig/src/http/ngx_http_upstream_round_robin.c nginx-1.12.1/src/http/ngx_http_upstream_round_robin.c |
| 123 | +--- nginx-1.12.1_orig/src/http/ngx_http_upstream_round_robin.c 2017-07-11 13:24:09.000000000 +0000 |
| 124 | ++++ nginx-1.12.1/src/http/ngx_http_upstream_round_robin.c 2017-07-13 18:13:00.510764315 +0000 |
| 125 | +@@ -9,6 +9,10 @@ |
| 126 | + #include <ngx_core.h> |
| 127 | + #include <ngx_http.h> |
| 128 | + |
| 129 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 130 | ++#include "ngx_http_upstream_check_module.h" |
| 131 | ++#endif |
| 132 | ++ |
| 133 | + |
| 134 | + #define ngx_http_upstream_tries(p) ((p)->number \ |
| 135 | + + ((p)->next ? (p)->next->number : 0)) |
| 136 | +@@ -98,6 +102,15 @@ |
| 137 | + peer[n].down = server[i].down; |
| 138 | + peer[n].server = server[i].name; |
| 139 | + |
| 140 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 141 | ++ if (!server[i].down) { |
| 142 | ++ peer[n].check_index = |
| 143 | ++ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]); |
| 144 | ++ } else { |
| 145 | ++ peer[n].check_index = (ngx_uint_t) NGX_ERROR; |
| 146 | ++ } |
| 147 | ++#endif |
| 148 | ++ |
| 149 | + *peerp = &peer[n]; |
| 150 | + peerp = &peer[n].next; |
| 151 | + n++; |
| 152 | +@@ -162,6 +175,16 @@ |
| 153 | + peer[n].down = server[i].down; |
| 154 | + peer[n].server = server[i].name; |
| 155 | + |
| 156 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 157 | ++ if (!server[i].down) { |
| 158 | ++ peer[n].check_index = |
| 159 | ++ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]); |
| 160 | ++ } |
| 161 | ++ else { |
| 162 | ++ peer[n].check_index = (ngx_uint_t) NGX_ERROR; |
| 163 | ++ } |
| 164 | ++#endif |
| 165 | ++ |
| 166 | + *peerp = &peer[n]; |
| 167 | + peerp = &peer[n].next; |
| 168 | + n++; |
| 169 | +@@ -228,6 +251,9 @@ |
| 170 | + peer[i].max_conns = 0; |
| 171 | + peer[i].max_fails = 1; |
| 172 | + peer[i].fail_timeout = 10; |
| 173 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 174 | ++ peer[i].check_index = (ngx_uint_t) NGX_ERROR; |
| 175 | ++#endif |
| 176 | + *peerp = &peer[i]; |
| 177 | + peerp = &peer[i].next; |
| 178 | + } |
| 179 | +@@ -344,6 +370,9 @@ |
| 180 | + peer[0].max_conns = 0; |
| 181 | + peer[0].max_fails = 1; |
| 182 | + peer[0].fail_timeout = 10; |
| 183 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 184 | ++ peer[0].check_index = (ngx_uint_t) NGX_ERROR; |
| 185 | ++#endif |
| 186 | + peers->peer = peer; |
| 187 | + |
| 188 | + } else { |
| 189 | +@@ -378,6 +407,9 @@ |
| 190 | + peer[i].max_conns = 0; |
| 191 | + peer[i].max_fails = 1; |
| 192 | + peer[i].fail_timeout = 10; |
| 193 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 194 | ++ peer[i].check_index = (ngx_uint_t) NGX_ERROR; |
| 195 | ++#endif |
| 196 | + *peerp = &peer[i]; |
| 197 | + peerp = &peer[i].next; |
| 198 | + } |
| 199 | +@@ -443,6 +475,12 @@ |
| 200 | + goto failed; |
| 201 | + } |
| 202 | + |
| 203 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 204 | ++ if (ngx_http_upstream_check_peer_down(peer->check_index)) { |
| 205 | ++ goto failed; |
| 206 | ++ } |
| 207 | ++#endif |
| 208 | ++ |
| 209 | + rrp->current = peer; |
| 210 | + |
| 211 | + } else { |
| 212 | +@@ -537,6 +575,12 @@ |
| 213 | + continue; |
| 214 | + } |
| 215 | + |
| 216 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 217 | ++ if (ngx_http_upstream_check_peer_down(peer->check_index)) { |
| 218 | ++ continue; |
| 219 | ++ } |
| 220 | ++#endif |
| 221 | ++ |
| 222 | + if (peer->max_fails |
| 223 | + && peer->fails >= peer->max_fails |
| 224 | + && now - peer->checked <= peer->fail_timeout) |
| 225 | +diff -burN nginx-1.12.1_orig/src/http/ngx_http_upstream_round_robin.h nginx-1.12.1/src/http/ngx_http_upstream_round_robin.h |
| 226 | +--- nginx-1.12.1_orig/src/http/ngx_http_upstream_round_robin.h 2017-07-11 13:24:09.000000000 +0000 |
| 227 | ++++ nginx-1.12.1/src/http/ngx_http_upstream_round_robin.h 2017-07-13 18:13:30.254055435 +0000 |
| 228 | +@@ -38,6 +38,10 @@ |
| 229 | + ngx_msec_t slow_start; |
| 230 | + ngx_msec_t start_time; |
| 231 | + |
| 232 | ++#if (NGX_HTTP_UPSTREAM_CHECK) |
| 233 | ++ ngx_uint_t check_index; |
| 234 | ++#endif |
| 235 | ++ |
| 236 | + ngx_uint_t down; |
| 237 | + |
| 238 | + #if (NGX_HTTP_SSL || NGX_COMPAT) |
0 commit comments