Skip to content

Commit fb4d208

Browse files
committed
Added support for upstream hash module
1 parent d0e92fa commit fb4d208

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

check_1.7.2+.patch

+44
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
diff --git a/src/http/modules/ngx_http_upstream_hash_module.c b/src/http/modules/ngx_http_upstream_hash_module.c
2+
index 777e180..e302f52 100644
3+
--- a/src/http/modules/ngx_http_upstream_hash_module.c
4+
+++ b/src/http/modules/ngx_http_upstream_hash_module.c
5+
@@ -9,6 +9,9 @@
6+
#include <ngx_core.h>
7+
#include <ngx_http.h>
8+
9+
+#if (NGX_HTTP_UPSTREAM_CHECK)
10+
+#include "ngx_http_upstream_check_module.h"
11+
+#endif
12+
13+
typedef struct {
14+
uint32_t hash;
15+
@@ -240,6 +243,14 @@ ngx_http_upstream_get_hash_peer(ngx_peer_connection_t *pc, void *data)
16+
goto next;
17+
}
18+
19+
+#if (NGX_HTTP_UPSTREAM_CHECK)
20+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
21+
+ "get hash peer, check_index: %ui",
22+
+ peer->check_index);
23+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
24+
+ goto next;
25+
+ }
26+
+#endif
27+
if (peer->max_fails
28+
&& peer->fails >= peer->max_fails
29+
&& now - peer->checked <= peer->fail_timeout)
30+
@@ -506,6 +517,14 @@ ngx_http_upstream_get_chash_peer(ngx_peer_connection_t *pc, void *data)
31+
continue;
32+
}
33+
34+
+#if (NGX_HTTP_UPSTREAM_CHECK)
35+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
36+
+ "get consistent_hash peer, check_index: %ui",
37+
+ peer->check_index);
38+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
39+
+ continue;
40+
+ }
41+
+#endif
42+
if (peer->server.len != server->len
43+
|| ngx_strncmp(peer->server.data, server->data, server->len)
44+
!= 0)
145
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
246
index 148d73a..913e395 100644
347
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c

check_1.7.5+.patch

+46
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,49 @@
1+
diff --git a/src/http/modules/ngx_http_upstream_hash_module.c b/src/http/modules/ngx_http_upstream_hash_module.c
2+
index 777e180..b6b7830 100644
3+
--- a/src/http/modules/ngx_http_upstream_hash_module.c
4+
+++ b/src/http/modules/ngx_http_upstream_hash_module.c
5+
@@ -9,6 +9,9 @@
6+
#include <ngx_core.h>
7+
#include <ngx_http.h>
8+
9+
+#if (NGX_HTTP_UPSTREAM_CHECK)
10+
+#include "ngx_http_upstream_check_module.h"
11+
+#endif
12+
13+
typedef struct {
14+
uint32_t hash;
15+
@@ -240,6 +243,15 @@ ngx_http_upstream_get_hash_peer(ngx_peer_connection_t *pc, void *data)
16+
goto next;
17+
}
18+
19+
+#if (NGX_HTTP_UPSTREAM_CHECK)
20+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
21+
+ "get hash peer, check_index: %ui",
22+
+ peer->check_index);
23+
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
24+
+ goto next;
25+
+ }
26+
+#endif
27+
+
28+
if (peer->max_fails
29+
&& peer->fails >= peer->max_fails
30+
&& now - peer->checked <= peer->fail_timeout)
31+
@@ -506,6 +518,15 @@ ngx_http_upstream_get_chash_peer(ngx_peer_connection_t *pc, void *data)
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)
147
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
248
index 148d73a..913e395 100644
349
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c

0 commit comments

Comments
 (0)