-
Notifications
You must be signed in to change notification settings - Fork 0
/
tengine-hc-keepalive.patch
94 lines (87 loc) · 2.74 KB
/
tengine-hc-keepalive.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
--- src/http/ngx_http_upstream_check_module.c 2014-01-21 14:23:30.000000000 +0800
+++ /home/rangeng.llb/ngx_http_upstream_check_module.c 2014-01-21 14:23:08.000000000 +0800
@@ -264,6 +264,7 @@
static void ngx_http_upstream_check_send_handler(ngx_event_t *event);
static void ngx_http_upstream_check_recv_handler(ngx_event_t *event);
+static void ngx_http_upstream_check_discard_handler(ngx_event_t *event);
static void ngx_http_upstream_check_dummy_handler(ngx_event_t *event);
static ngx_int_t ngx_http_upstream_check_http_init(
@@ -540,7 +541,7 @@
{ NGX_HTTP_CHECK_HTTP,
ngx_string("http"),
- ngx_string("GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n"),
+ ngx_string("GET / HTTP/1.0\r\n\r\n"),
NGX_CONF_BITMASK_SET | NGX_CHECK_HTTP_2XX | NGX_CHECK_HTTP_3XX,
ngx_http_upstream_check_send_handler,
ngx_http_upstream_check_recv_handler,
@@ -1076,6 +1077,56 @@
static void
+ngx_http_upstream_check_discard_handler(ngx_event_t *event)
+{
+ u_char buf[4096];
+ ssize_t size;
+ ngx_connection_t *c;
+ ngx_http_upstream_check_peer_t *peer;
+
+ c = event->data;
+
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "upstream check discard handler");
+
+ if (ngx_http_upstream_check_need_exit()) {
+ return;
+ }
+
+ peer = c->data;
+
+ while (1) {
+ size = c->recv(c, buf, 4096);
+
+ if (size > 0) {
+ continue;
+
+ } else if (size == NGX_AGAIN) {
+ break;
+
+ } else {
+ if (size == 0) {
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "peer closed its half side of the connection");
+ }
+
+ goto check_discard_fail;
+ }
+ }
+
+ if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
+ goto check_discard_fail;
+ }
+
+ return;
+
+ check_discard_fail:
+ c->error = 1;
+ ngx_http_upstream_check_clean_event(peer);
+}
+
+
+static void
ngx_http_upstream_check_dummy_handler(ngx_event_t *event)
{
return;
@@ -1856,7 +1907,7 @@
(c->requests < ucscf->check_keepalive_requests))
{
c->write->handler = ngx_http_upstream_check_dummy_handler;
- c->read->handler = ngx_http_upstream_check_dummy_handler;
+ c->read->handler = ngx_http_upstream_check_discard_handler;
} else {
ngx_close_connection(c);
peer->pc.connection = NULL;
@@ -2802,7 +2853,7 @@
}
if (ucscf->check_keepalive_requests == NGX_CONF_UNSET_UINT) {
- ucscf->check_keepalive_requests = 100;
+ ucscf->check_keepalive_requests = 1;
}
if (ucscf->check_type_conf == NGX_CONF_UNSET_PTR) {