-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathnginx-1.10.1.patch
98 lines (85 loc) · 3.48 KB
/
nginx-1.10.1.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
95
96
97
98
--- src/http/ngx_http_upstream.h.1.10.1 2016-06-01 11:55:08.722172761 +0800
+++ src/http/ngx_http_upstream.h 2016-06-01 11:55:37.870172018 +0800
@@ -373,6 +373,7 @@
unsigned request_sent:1;
unsigned request_body_sent:1;
unsigned header_sent:1;
+ unsigned blocked:1;
};
@@ -405,6 +406,8 @@
ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,
ngx_str_t *default_hide_headers, ngx_hash_init_t *hash);
+void ngx_http_upstream_connect(ngx_http_request_t *r,
+ ngx_http_upstream_t *u);
#define ngx_http_conf_upstream_srv_conf(uscf, module) \
--- src/http/ngx_http_upstream.c.1.10.1 2016-06-01 11:55:08.726172761 +0800
+++ src/http/ngx_http_upstream.c 2016-06-01 11:56:49.238170197 +0800
@@ -31,8 +31,6 @@
static void ngx_http_upstream_wr_check_broken_connection(ngx_http_request_t *r);
static void ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
ngx_event_t *ev);
-static void ngx_http_upstream_connect(ngx_http_request_t *r,
- ngx_http_upstream_t *u);
static ngx_int_t ngx_http_upstream_reinit(ngx_http_request_t *r,
ngx_http_upstream_t *u);
static void ngx_http_upstream_send_request(ngx_http_request_t *r,
@@ -1325,35 +1323,39 @@
}
-static void
+void
ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
{
ngx_int_t rc;
ngx_connection_t *c;
+ if (!u->blocked) {
+ r->connection->log->action = "connecting to upstream";
- r->connection->log->action = "connecting to upstream";
-
- if (u->state && u->state->response_time) {
- u->state->response_time = ngx_current_msec - u->state->response_time;
- }
-
- u->state = ngx_array_push(r->upstream_states);
- if (u->state == NULL) {
- ngx_http_upstream_finalize_request(r, u,
- NGX_HTTP_INTERNAL_SERVER_ERROR);
- return;
- }
+ if (u->state && u->state->response_time) {
+ u->state->response_time = ngx_current_msec
+ - u->state->response_time;
+ }
- ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
+ u->state = ngx_array_push(r->upstream_states);
+ if (u->state == NULL) {
+ ngx_http_upstream_finalize_request(r, u,
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
- u->state->response_time = ngx_current_msec;
- u->state->connect_time = (ngx_msec_t) -1;
- u->state->header_time = (ngx_msec_t) -1;
+ ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
+ u->state->response_time = ngx_current_msec;
+ u->state->connect_time = (ngx_msec_t) -1;
+ u->state->header_time = (ngx_msec_t) -1;
+ }
rc = ngx_event_connect_peer(&u->peer);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http upstream connect: %i", rc);
+ if (rc == NGX_BLOCK) {
+ return;
+ }
if (rc == NGX_ERROR) {
ngx_http_upstream_finalize_request(r, u,
--- src/core/ngx_core.h.1.10.1 2016-06-01 11:55:08.726172761 +0800
+++ src/core/ngx_core.h 2016-06-01 11:55:13.514172639 +0800
@@ -40,7 +40,7 @@
#define NGX_DONE -4
#define NGX_DECLINED -5
#define NGX_ABORT -6
-
+#define NGX_BLOCK -7
#include <ngx_errno.h>
#include <ngx_atomic.h>