Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Development #19

Open
wants to merge 92 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
307234e
tidy the source
yaoweibin Aug 16, 2010
d034448
first compile succ
yaoweibin Aug 16, 2010
b5fdafe
first test succ
yaoweibin Aug 16, 2010
e01614a
add module.h
yaoweibin Aug 17, 2010
823e615
modify the peers_conf -> peers, peer_conf -> peer
yaoweibin Aug 17, 2010
3a275bc
create the upstream_check init main structure
yaoweibin Aug 17, 2010
6c1da12
reduce the patch, move the main configration and server configration
yaoweibin Aug 17, 2010
72db4c0
use the ngx_http_conf_upstream_srv_conf to get the server configration
yaoweibin Aug 18, 2010
8f96f78
add the check type of ajp
yaoweibin Aug 18, 2010
bbcae78
add the README
yaoweibin Aug 18, 2010
6939f7a
fix a bug of default type. Add test scripts
yaoweibin Aug 18, 2010
d0c5cfe
fix the problem with ngx_log_debug
yaoweibin Aug 18, 2010
1c7e306
add the option of default_down
yaoweibin Aug 19, 2010
400493c
update README
yaoweibin Aug 30, 2010
77b960f
fix docs
yaoweibin Aug 30, 2010
2e063ba
make nginx-0.8.22+ happy
yaoweibin Aug 31, 2010
ec445bf
add a MACRO wrapping the patch
yaoweibin Aug 31, 2010
1eeb172
fix docs
yaoweibin Aug 31, 2010
8cadf68
fix the #issue/1,2,3,4 Thanks to Matthieu Tourne
yaoweibin Oct 20, 2010
35b89ae
fix the wrong ssl_hello packet
yaoweibin Oct 20, 2010
5ba4b5f
add more test scripts, fix a bug with implicitly defined upstream
yaoweibin Oct 20, 2010
226f7c7
fix a possible bug
yaoweibin Oct 21, 2010
3bdbe35
fix a bug with kqueue, change the test scripts to public domain
yaoweibin Oct 21, 2010
be48121
add the name of Matthieu to README
yaoweibin Oct 22, 2010
7054293
add the Matthieu to copyright
yaoweibin Oct 22, 2010
4bd5f76
fix a bug of segment fault after reload
yaoweibin Dec 17, 2010
7b0f364
mv wiki to doc
yaoweibin Jan 6, 2011
2700a95
fix a bug of segment fault when reloading
yaoweibin Apr 29, 2011
dcbbe1d
fix a bug with the option of backup
yaoweibin Jun 2, 2011
af8eb8b
Merge branch 'master' of github.com:yaoweibin/nginx_upstream_check_mo…
yaoweibin Jun 2, 2011
d7b9d5a
add upstream name and remove busyness, access_count in the status page
yaoweibin Jul 8, 2011
d8533fd
no touch the shared memory after reloading
yaoweibin Jul 8, 2011
ef863c9
fix the problem of "-Werror=unused-but-set-variable"
yaoweibin Jul 15, 2011
4f58910
fix the above when without --with-debug
yaoweibin Jul 15, 2011
40229fa
add the patch for upstream ip_hash and fair module. add test scripts and
yaoweibin Aug 3, 2011
1fa2aa8
make it comtiable with c99
yaoweibin Oct 24, 2011
5adb654
update docs
yaoweibin Feb 3, 2012
63ca24b
fix an bug when using variable in proxy_pass
yaoweibin Feb 22, 2012
b2f5a61
Merge branch 'master' of github.com:yaoweibin/nginx_upstream_check_mo…
yaoweibin Feb 22, 2012
cdcf50c
remove the smtp check feature
yaoweibin Feb 23, 2012
36d4bf6
fix the coding style
yaoweibin Feb 23, 2012
7a4fd30
fix the coding style in the patch
yaoweibin Feb 23, 2012
e2f31f3
chomp the space in the end of line
yaoweibin Feb 23, 2012
0ee0616
add chomp script
yaoweibin Feb 23, 2012
6d5fd78
test the zero configure parameter
yaoweibin Mar 5, 2012
e61c289
inherit the shared memory when you reload nginx
yaoweibin Mar 6, 2012
2475dca
update test scripts version
yaoweibin Mar 6, 2012
c094896
remove the dependence with Ragel
yaoweibin Apr 6, 2012
367f783
fix the coding style
yaoweibin Apr 6, 2012
dfc6ae7
fix a bug of untriggered clean event
yaoweibin Apr 6, 2012
2e93f1e
fix a bug of wrong peer number
yaoweibin Apr 9, 2012
554ebe2
change the get_shm_name function to static string
yaoweibin Apr 9, 2012
3a52be9
fix the mysql check
yaoweibin Apr 9, 2012
7b93365
remove the imap and pop3 check method
yaoweibin Apr 9, 2012
43052ea
remove the docs for imap and pop3
yaoweibin Apr 10, 2012
84f9b39
change the test scripts
yaoweibin Apr 10, 2012
c07f6b7
chomp the space in the end of line
yaoweibin Apr 10, 2012
660183a
inherit the peer state from the old shared memory when reload
yaoweibin Apr 13, 2012
a33a0fa
change to srand to srandom
yaoweibin May 11, 2012
a447f11
remove the status section in the docs
yaoweibin May 28, 2012
dfee401
add a new patch for nginx-1.2.1+
yaoweibin Jun 6, 2012
dd32cd0
remove the useless code
yaoweibin Jul 13, 2012
27b8736
added the patch for nginx-sticky-module
yaoweibin Jul 22, 2012
fc8473b
add the docs for nginx-sticky-module
yaoweibin Jul 22, 2012
55fd9bc
added the least-conn patch for nginx-1.2.2+
yaoweibin Jul 22, 2012
e270908
add the docs for 1.2.2+.patch
yaoweibin Jul 22, 2012
be97c70
added the test cases for least_conn
yaoweibin Jul 22, 2012
b605a9c
added skip section with least_conn test cases for nginx-1.2.1-
yaoweibin Jul 23, 2012
5bf858f
fix the error type of DEBUG log formats, coding style
yaoweibin Jul 23, 2012
7fce4f5
added static keyword for some static global variables
yaoweibin Aug 9, 2012
36bf0f8
fixed a memory overflow bug with check_status directive with thousand…
yaoweibin Aug 22, 2012
7950f04
merged with tengine's upstream check module
yaoweibin Aug 22, 2012
fab7953
fixed an compile warning in CentOS 5.7 i386
yaoweibin Aug 23, 2012
2c5a2c8
fixed an bug with wrong array index
yaoweibin Aug 23, 2012
3c355a5
fixed an bug with wrong array index
yaoweibin Aug 23, 2012
660055f
fixed a wrong log format bug
yaoweibin Sep 6, 2012
8ec8024
fixed docs
yaoweibin Sep 17, 2012
c9e62ba
fixed docs
yaoweibin Sep 17, 2012
13f5e20
added the patch for jvm_route module
yaoweibin Oct 18, 2012
c85b35f
fixed a segment fault bug with upstream check module when check time…
yaoweibin Nov 27, 2012
99524ef
fixed typo
yaoweibin Nov 27, 2012
c837849
fixed a segment fault bug with upstream check module when check timeo…
yaoweibin Nov 27, 2012
fd8383b
updated the docs
yaoweibin Dec 21, 2012
327249c
added the patch for nginx-1.2.6+ and nginx-1.3.9+
yaoweibin Dec 23, 2012
196a6b1
Merge branch 'master' into development
yaoweibin Jan 3, 2013
7ea5d36
sync with tengine's check module version
yaoweibin Oct 2, 2014
2c5b81b
ip/port and upstream_name inherit
yaoweibin Oct 2, 2014
2f0c8e7
added the patch for 1.5.12+
yaoweibin Oct 2, 2014
a31f215
added the new test scripts
yaoweibin Oct 2, 2014
572c738
added the test cases for fastcgi check
yaoweibin Oct 2, 2014
f1a8429
updated the new docs
yaoweibin Oct 2, 2014
7d73c60
added the patch for 1.7.2
yaoweibin Oct 2, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added CHANGES
Empty file.
428 changes: 340 additions & 88 deletions README

Large diffs are not rendered by default.

192 changes: 192 additions & 0 deletions check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
index fd9ecbe..d3849b6 100644
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
@@ -9,6 +9,10 @@
#include <ngx_core.h>
#include <ngx_http.h>

+#if (NGX_HTTP_UPSTREAM_CHECK)
+#include "ngx_http_upstream_check_module.h"
+#endif
+

typedef struct {
/* the round robin data must be first */
@@ -182,6 +186,12 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)

if (!peer->down) {

+#if (NGX_HTTP_UPSTREAM_CHECK)
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
+ "get ip_hash peer, check_index: %ui",
+ peer->check_index);
+ if (!ngx_http_upstream_check_peer_down(peer->check_index)) {
+#endif
if (peer->max_fails == 0 || peer->fails < peer->max_fails) {
break;
}
@@ -190,6 +200,9 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
peer->fails = 0;
break;
}
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ }
+#endif
}

iphp->rrp.tried[n] |= m;
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index afc9b2e..1c0344e 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -9,6 +9,9 @@
#include <ngx_core.h>
#include <ngx_http.h>

+#if (NGX_HTTP_UPSTREAM_CHECK)
+#include "ngx_http_upstream_check_module.h"
+#endif

static ngx_int_t ngx_http_upstream_cmp_servers(const void *one,
const void *two);
@@ -75,6 +78,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
peers->peer[n].down = server[i].down;
peers->peer[n].weight = server[i].down ? 0 : server[i].weight;
peers->peer[n].current_weight = peers->peer[n].weight;
+
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ if (!server[i].down) {
+ peers->peer[n].check_index =
+ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
+ }
+ else {
+ peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
+ }
+#endif
+
n++;
}
}
@@ -128,6 +142,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
backup->peer[n].max_fails = server[i].max_fails;
backup->peer[n].fail_timeout = server[i].fail_timeout;
backup->peer[n].down = server[i].down;
+
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ if (!server[i].down) {
+ backup->peer[n].check_index =
+ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
+ }
+ else {
+ backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
+ }
+#endif
+
n++;
}
}
@@ -186,6 +211,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
peers->peer[i].current_weight = 1;
peers->peer[i].max_fails = 1;
peers->peer[i].fail_timeout = 10;
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
+#endif
}

us->peer.data = peers;
@@ -302,6 +330,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
peers->peer[0].current_weight = 1;
peers->peer[0].max_fails = 1;
peers->peer[0].fail_timeout = 10;
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ peers->peer[0].check_index = (ngx_uint_t) NGX_ERROR;
+#endif

} else {

@@ -334,6 +365,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
peers->peer[i].current_weight = 1;
peers->peer[i].max_fails = 1;
peers->peer[i].fail_timeout = 10;
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
+#endif
}
}

@@ -411,7 +445,11 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)

if (rrp->peers->single) {
peer = &rrp->peers->peer[0];
-
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
+ return NGX_BUSY;
+ }
+#endif
} else {

/* there are several peers */
@@ -438,6 +476,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)

if (!peer->down) {

+#if (NGX_HTTP_UPSTREAM_CHECK)
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
+ "get rr peer, check_index: %ui",
+ peer->check_index);
+ if (!ngx_http_upstream_check_peer_down(peer->check_index)) {
+#endif
if (peer->max_fails == 0
|| peer->fails < peer->max_fails)
{
@@ -448,6 +492,9 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
peer->fails = 0;
break;
}
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ }
+#endif

peer->current_weight = 0;

@@ -486,6 +533,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)

if (!peer->down) {

+#if (NGX_HTTP_UPSTREAM_CHECK)
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
+ "get rr peer2, check_index: %ui",
+ peer->check_index);
+ if (!ngx_http_upstream_check_peer_down(peer->check_index)) {
+#endif
if (peer->max_fails == 0
|| peer->fails < peer->max_fails)
{
@@ -496,6 +549,9 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
peer->fails = 0;
break;
}
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ }
+#endif

peer->current_weight = 0;

diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h
index 6d285ab..354cca2 100644
--- a/src/http/ngx_http_upstream_round_robin.h
+++ b/src/http/ngx_http_upstream_round_robin.h
@@ -28,6 +28,10 @@ typedef struct {
ngx_uint_t max_fails;
time_t fail_timeout;

+#if (NGX_HTTP_UPSTREAM_CHECK)
+ ngx_uint_t check_index;
+#endif
+
ngx_uint_t down; /* unsigned down:1; */

#if (NGX_HTTP_SSL)
160 changes: 160 additions & 0 deletions check_1.2.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
index 100ea34..642b01b 100644
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
@@ -9,6 +9,10 @@
#include <ngx_core.h>
#include <ngx_http.h>

+#if (NGX_HTTP_UPSTREAM_CHECK)
+#include "ngx_http_upstream_check_module.h"
+#endif
+

typedef struct {
/* the round robin data must be first */
@@ -182,6 +186,12 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)

if (!peer->down) {

+#if (NGX_HTTP_UPSTREAM_CHECK)
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
+ "get ip_hash peer, check_index: %ui",
+ peer->check_index);
+ if (!ngx_http_upstream_check_peer_down(peer->check_index)) {
+#endif
if (peer->max_fails == 0 || peer->fails < peer->max_fails) {
break;
}
@@ -190,6 +200,9 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
peer->checked = now;
break;
}
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ }
+#endif
}

iphp->rrp.tried[n] |= m;
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index 214de7b..309725b 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -9,6 +9,9 @@
#include <ngx_core.h>
#include <ngx_http.h>

+#if (NGX_HTTP_UPSTREAM_CHECK)
+#include "ngx_http_upstream_check_module.h"
+#endif

static ngx_int_t ngx_http_upstream_cmp_servers(const void *one,
const void *two);
@@ -83,7 +86,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
peers->peer[n].weight = server[i].weight;
peers->peer[n].effective_weight = server[i].weight;
peers->peer[n].current_weight = 0;
- n++;
+
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ if (!server[i].down) {
+ peers->peer[n].check_index =
+ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
+ }
+ else {
+ peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
+ }
+#endif
+ n++;
}
}

@@ -137,6 +150,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
backup->peer[n].max_fails = server[i].max_fails;
backup->peer[n].fail_timeout = server[i].fail_timeout;
backup->peer[n].down = server[i].down;
+
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ if (!server[i].down) {
+ backup->peer[n].check_index =
+ ngx_http_upstream_check_add_peer(cf, us, &server[i].addrs[j]);
+ }
+ else {
+ backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
+ }
+#endif
+
n++;
}
}
@@ -196,6 +220,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
peers->peer[i].current_weight = 0;
peers->peer[i].max_fails = 1;
peers->peer[i].fail_timeout = 10;
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
+#endif
}

us->peer.data = peers;
@@ -313,6 +340,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
peers->peer[0].current_weight = 0;
peers->peer[0].max_fails = 1;
peers->peer[0].fail_timeout = 10;
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ peers->peer[0].check_index = (ngx_uint_t) NGX_ERROR;
+#endif

} else {

@@ -346,6 +376,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
peers->peer[i].current_weight = 0;
peers->peer[i].max_fails = 1;
peers->peer[i].fail_timeout = 10;
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
+#endif
}
}

@@ -419,7 +452,11 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)

if (rrp->peers->single) {
peer = &rrp->peers->peer[0];
-
+#if (NGX_HTTP_UPSTREAM_CHECK)
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
+ return NGX_BUSY;
+ }
+#endif
} else {

/* there are several peers */
@@ -517,6 +554,12 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp)
continue;
}

+#if (NGX_HTTP_UPSTREAM_CHECK)
+ if (ngx_http_upstream_check_peer_down(peer->check_index)) {
+ continue;
+ }
+#endif
+
if (peer->max_fails
&& peer->fails >= peer->max_fails
&& now - peer->checked <= peer->fail_timeout)
diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h
index 4de3cae..164867b 100644
--- a/src/http/ngx_http_upstream_round_robin.h
+++ b/src/http/ngx_http_upstream_round_robin.h
@@ -30,6 +30,10 @@ typedef struct {
ngx_uint_t max_fails;
time_t fail_timeout;

+#if (NGX_HTTP_UPSTREAM_CHECK)
+ ngx_uint_t check_index;
+#endif
+
ngx_uint_t down; /* unsigned down:1; */

#if (NGX_HTTP_SSL)
Loading