Mercurial > hg > nginx-quic
annotate src/http/ngx_http_upstream_round_robin.c @ 5788:cbb146b12029 release-1.7.4
nginx-1.7.4-RELEASE
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 05 Aug 2014 15:13:04 +0400 |
parents | 5b7276408565 |
children | 575175ebf4b4 |
rev | line source |
---|---|
884 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
884 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_http.h> | |
11 | |
12 | |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
13 static ngx_http_upstream_rr_peer_t *ngx_http_upstream_get_peer( |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
14 ngx_http_upstream_rr_peer_data_t *rrp); |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
15 |
3964
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
16 #if (NGX_HTTP_SSL) |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
17 |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
18 static ngx_int_t ngx_http_upstream_empty_set_session(ngx_peer_connection_t *pc, |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
19 void *data); |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
20 static void ngx_http_upstream_empty_save_session(ngx_peer_connection_t *pc, |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
21 void *data); |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
22 |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
23 #endif |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
24 |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
25 |
884 | 26 ngx_int_t |
27 ngx_http_upstream_init_round_robin(ngx_conf_t *cf, | |
28 ngx_http_upstream_srv_conf_t *us) | |
29 { | |
30 ngx_url_t u; | |
4655
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
31 ngx_uint_t i, j, n, w; |
884 | 32 ngx_http_upstream_server_t *server; |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
33 ngx_http_upstream_rr_peer_t *peer; |
1378 | 34 ngx_http_upstream_rr_peers_t *peers, *backup; |
884 | 35 |
36 us->peer.init = ngx_http_upstream_init_round_robin_peer; | |
37 | |
38 if (us->servers) { | |
39 server = us->servers->elts; | |
40 | |
1378 | 41 n = 0; |
4655
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
42 w = 0; |
1378 | 43 |
884 | 44 for (i = 0; i < us->servers->nelts; i++) { |
1378 | 45 if (server[i].backup) { |
46 continue; | |
47 } | |
48 | |
884 | 49 n += server[i].naddrs; |
4655
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
50 w += server[i].naddrs * server[i].weight; |
884 | 51 } |
52 | |
4569
1db899642518
Upstream: reject upstreams without normal servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
53 if (n == 0) { |
1db899642518
Upstream: reject upstreams without normal servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
54 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
1db899642518
Upstream: reject upstreams without normal servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
55 "no servers in upstream \"%V\" in %s:%ui", |
1db899642518
Upstream: reject upstreams without normal servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
56 &us->host, us->file_name, us->line); |
1db899642518
Upstream: reject upstreams without normal servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
57 return NGX_ERROR; |
1db899642518
Upstream: reject upstreams without normal servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
58 } |
1db899642518
Upstream: reject upstreams without normal servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
59 |
884 | 60 peers = ngx_pcalloc(cf->pool, sizeof(ngx_http_upstream_rr_peers_t) |
61 + sizeof(ngx_http_upstream_rr_peer_t) * (n - 1)); | |
62 if (peers == NULL) { | |
63 return NGX_ERROR; | |
64 } | |
65 | |
1378 | 66 peers->single = (n == 1); |
884 | 67 peers->number = n; |
4655
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
68 peers->weighted = (w != n); |
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
69 peers->total_weight = w; |
884 | 70 peers->name = &us->host; |
71 | |
72 n = 0; | |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
73 peer = peers->peer; |
884 | 74 |
75 for (i = 0; i < us->servers->nelts; i++) { | |
5429
e6a1623f87bc
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
Xiaochen Wang <wangxiaochen0@gmail.com>
parents:
5220
diff
changeset
|
76 if (server[i].backup) { |
e6a1623f87bc
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
Xiaochen Wang <wangxiaochen0@gmail.com>
parents:
5220
diff
changeset
|
77 continue; |
e6a1623f87bc
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
Xiaochen Wang <wangxiaochen0@gmail.com>
parents:
5220
diff
changeset
|
78 } |
e6a1623f87bc
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
Xiaochen Wang <wangxiaochen0@gmail.com>
parents:
5220
diff
changeset
|
79 |
884 | 80 for (j = 0; j < server[i].naddrs; j++) { |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
81 peer[n].sockaddr = server[i].addrs[j].sockaddr; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
82 peer[n].socklen = server[i].addrs[j].socklen; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
83 peer[n].name = server[i].addrs[j].name; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
84 peer[n].weight = server[i].weight; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
85 peer[n].effective_weight = server[i].weight; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
86 peer[n].current_weight = 0; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
87 peer[n].max_fails = server[i].max_fails; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
88 peer[n].fail_timeout = server[i].fail_timeout; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
89 peer[n].down = server[i].down; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
90 peer[n].server = server[i].name; |
884 | 91 n++; |
92 } | |
93 } | |
94 | |
95 us->peer.data = peers; | |
96 | |
1378 | 97 /* backup servers */ |
98 | |
99 n = 0; | |
4655
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
100 w = 0; |
1378 | 101 |
102 for (i = 0; i < us->servers->nelts; i++) { | |
103 if (!server[i].backup) { | |
104 continue; | |
105 } | |
106 | |
107 n += server[i].naddrs; | |
4655
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
108 w += server[i].naddrs * server[i].weight; |
1378 | 109 } |
110 | |
111 if (n == 0) { | |
112 return NGX_OK; | |
113 } | |
114 | |
115 backup = ngx_pcalloc(cf->pool, sizeof(ngx_http_upstream_rr_peers_t) | |
116 + sizeof(ngx_http_upstream_rr_peer_t) * (n - 1)); | |
117 if (backup == NULL) { | |
118 return NGX_ERROR; | |
119 } | |
120 | |
121 peers->single = 0; | |
122 backup->single = 0; | |
123 backup->number = n; | |
4655
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
124 backup->weighted = (w != n); |
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
125 backup->total_weight = w; |
1378 | 126 backup->name = &us->host; |
127 | |
128 n = 0; | |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
129 peer = backup->peer; |
1378 | 130 |
131 for (i = 0; i < us->servers->nelts; i++) { | |
5429
e6a1623f87bc
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
Xiaochen Wang <wangxiaochen0@gmail.com>
parents:
5220
diff
changeset
|
132 if (!server[i].backup) { |
e6a1623f87bc
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
Xiaochen Wang <wangxiaochen0@gmail.com>
parents:
5220
diff
changeset
|
133 continue; |
e6a1623f87bc
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
Xiaochen Wang <wangxiaochen0@gmail.com>
parents:
5220
diff
changeset
|
134 } |
e6a1623f87bc
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
Xiaochen Wang <wangxiaochen0@gmail.com>
parents:
5220
diff
changeset
|
135 |
1378 | 136 for (j = 0; j < server[i].naddrs; j++) { |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
137 peer[n].sockaddr = server[i].addrs[j].sockaddr; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
138 peer[n].socklen = server[i].addrs[j].socklen; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
139 peer[n].name = server[i].addrs[j].name; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
140 peer[n].weight = server[i].weight; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
141 peer[n].effective_weight = server[i].weight; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
142 peer[n].current_weight = 0; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
143 peer[n].max_fails = server[i].max_fails; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
144 peer[n].fail_timeout = server[i].fail_timeout; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
145 peer[n].down = server[i].down; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
146 peer[n].server = server[i].name; |
1378 | 147 n++; |
148 } | |
149 } | |
150 | |
151 peers->next = backup; | |
152 | |
884 | 153 return NGX_OK; |
154 } | |
155 | |
156 | |
157 /* an upstream implicitly defined by proxy_pass, etc. */ | |
158 | |
5005
c9059bd5445b
Fixed "proxy_pass" with IP address and no port (ticket #276).
Ruslan Ermilov <ru@nginx.com>
parents:
4991
diff
changeset
|
159 if (us->port == 0) { |
906 | 160 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
161 "no port in upstream \"%V\" in %s:%ui", | |
1489
56f1ea5baabb
u_char* is enough to keep file name
Igor Sysoev <igor@sysoev.ru>
parents:
1465
diff
changeset
|
162 &us->host, us->file_name, us->line); |
906 | 163 return NGX_ERROR; |
164 } | |
165 | |
884 | 166 ngx_memzero(&u, sizeof(ngx_url_t)); |
167 | |
168 u.host = us->host; | |
5005
c9059bd5445b
Fixed "proxy_pass" with IP address and no port (ticket #276).
Ruslan Ermilov <ru@nginx.com>
parents:
4991
diff
changeset
|
169 u.port = us->port; |
884 | 170 |
1559
fe11e2a3946d
use pool instead of ngx_conf_t
Igor Sysoev <igor@sysoev.ru>
parents:
1556
diff
changeset
|
171 if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) { |
884 | 172 if (u.err) { |
173 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | |
896
f247db60fc85
fix fastcgi and memcached upstreams
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
174 "%s in upstream \"%V\" in %s:%ui", |
1489
56f1ea5baabb
u_char* is enough to keep file name
Igor Sysoev <igor@sysoev.ru>
parents:
1465
diff
changeset
|
175 u.err, &us->host, us->file_name, us->line); |
884 | 176 } |
177 | |
178 return NGX_ERROR; | |
179 } | |
180 | |
181 n = u.naddrs; | |
182 | |
183 peers = ngx_pcalloc(cf->pool, sizeof(ngx_http_upstream_rr_peers_t) | |
184 + sizeof(ngx_http_upstream_rr_peer_t) * (n - 1)); | |
185 if (peers == NULL) { | |
186 return NGX_ERROR; | |
187 } | |
188 | |
1378 | 189 peers->single = (n == 1); |
884 | 190 peers->number = n; |
4655
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
191 peers->weighted = 0; |
382c523d253a
Upstream: weights support in ip_hash balancer.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4622
diff
changeset
|
192 peers->total_weight = n; |
884 | 193 peers->name = &us->host; |
194 | |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
195 peer = peers->peer; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
196 |
884 | 197 for (i = 0; i < u.naddrs; i++) { |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
198 peer[i].sockaddr = u.addrs[i].sockaddr; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
199 peer[i].socklen = u.addrs[i].socklen; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
200 peer[i].name = u.addrs[i].name; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
201 peer[i].weight = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
202 peer[i].effective_weight = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
203 peer[i].current_weight = 0; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
204 peer[i].max_fails = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
205 peer[i].fail_timeout = 10; |
884 | 206 } |
207 | |
208 us->peer.data = peers; | |
209 | |
1378 | 210 /* implicitly defined upstream has no backup servers */ |
211 | |
884 | 212 return NGX_OK; |
213 } | |
214 | |
215 | |
216 ngx_int_t | |
217 ngx_http_upstream_init_round_robin_peer(ngx_http_request_t *r, | |
218 ngx_http_upstream_srv_conf_t *us) | |
219 { | |
220 ngx_uint_t n; | |
221 ngx_http_upstream_rr_peer_data_t *rrp; | |
222 | |
223 rrp = r->upstream->peer.data; | |
224 | |
225 if (rrp == NULL) { | |
226 rrp = ngx_palloc(r->pool, sizeof(ngx_http_upstream_rr_peer_data_t)); | |
227 if (rrp == NULL) { | |
228 return NGX_ERROR; | |
229 } | |
230 | |
231 r->upstream->peer.data = rrp; | |
232 } | |
233 | |
234 rrp->peers = us->peer.data; | |
235 rrp->current = 0; | |
236 | |
4011
9d4cbb09ae8b
Upstream: properly allocate memory for tried flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4010
diff
changeset
|
237 n = rrp->peers->number; |
9d4cbb09ae8b
Upstream: properly allocate memory for tried flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4010
diff
changeset
|
238 |
9d4cbb09ae8b
Upstream: properly allocate memory for tried flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4010
diff
changeset
|
239 if (rrp->peers->next && rrp->peers->next->number > n) { |
9d4cbb09ae8b
Upstream: properly allocate memory for tried flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4010
diff
changeset
|
240 n = rrp->peers->next->number; |
9d4cbb09ae8b
Upstream: properly allocate memory for tried flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4010
diff
changeset
|
241 } |
9d4cbb09ae8b
Upstream: properly allocate memory for tried flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4010
diff
changeset
|
242 |
9d4cbb09ae8b
Upstream: properly allocate memory for tried flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4010
diff
changeset
|
243 if (n <= 8 * sizeof(uintptr_t)) { |
884 | 244 rrp->tried = &rrp->data; |
245 rrp->data = 0; | |
246 | |
247 } else { | |
4011
9d4cbb09ae8b
Upstream: properly allocate memory for tried flags.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4010
diff
changeset
|
248 n = (n + (8 * sizeof(uintptr_t) - 1)) / (8 * sizeof(uintptr_t)); |
884 | 249 |
250 rrp->tried = ngx_pcalloc(r->pool, n * sizeof(uintptr_t)); | |
251 if (rrp->tried == NULL) { | |
252 return NGX_ERROR; | |
253 } | |
254 } | |
255 | |
256 r->upstream->peer.get = ngx_http_upstream_get_round_robin_peer; | |
257 r->upstream->peer.free = ngx_http_upstream_free_round_robin_peer; | |
258 r->upstream->peer.tries = rrp->peers->number; | |
259 #if (NGX_HTTP_SSL) | |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
260 r->upstream->peer.set_session = |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
261 ngx_http_upstream_set_round_robin_peer_session; |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
262 r->upstream->peer.save_session = |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
263 ngx_http_upstream_save_round_robin_peer_session; |
884 | 264 #endif |
265 | |
266 return NGX_OK; | |
267 } | |
268 | |
269 | |
270 ngx_int_t | |
1658 | 271 ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r, |
272 ngx_http_upstream_resolved_t *ur) | |
273 { | |
274 u_char *p; | |
275 size_t len; | |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
276 socklen_t socklen; |
1658 | 277 ngx_uint_t i, n; |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
278 struct sockaddr *sockaddr; |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
279 ngx_http_upstream_rr_peer_t *peer; |
1658 | 280 ngx_http_upstream_rr_peers_t *peers; |
281 ngx_http_upstream_rr_peer_data_t *rrp; | |
282 | |
283 rrp = r->upstream->peer.data; | |
284 | |
285 if (rrp == NULL) { | |
286 rrp = ngx_palloc(r->pool, sizeof(ngx_http_upstream_rr_peer_data_t)); | |
287 if (rrp == NULL) { | |
288 return NGX_ERROR; | |
289 } | |
290 | |
291 r->upstream->peer.data = rrp; | |
292 } | |
293 | |
294 peers = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_rr_peers_t) | |
295 + sizeof(ngx_http_upstream_rr_peer_t) * (ur->naddrs - 1)); | |
296 if (peers == NULL) { | |
297 return NGX_ERROR; | |
298 } | |
299 | |
300 peers->single = (ur->naddrs == 1); | |
301 peers->number = ur->naddrs; | |
302 peers->name = &ur->host; | |
303 | |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
304 peer = peers->peer; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
305 |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
306 if (ur->sockaddr) { |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
307 peer[0].sockaddr = ur->sockaddr; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
308 peer[0].socklen = ur->socklen; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
309 peer[0].name = ur->host; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
310 peer[0].weight = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
311 peer[0].effective_weight = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
312 peer[0].current_weight = 0; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
313 peer[0].max_fails = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
314 peer[0].fail_timeout = 10; |
1658 | 315 |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
316 } else { |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
317 |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
318 for (i = 0; i < ur->naddrs; i++) { |
1658 | 319 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
320 socklen = ur->addrs[i].socklen; |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
321 |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
322 sockaddr = ngx_palloc(r->pool, socklen); |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
323 if (sockaddr == NULL) { |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
324 return NGX_ERROR; |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
325 } |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
326 |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
327 ngx_memcpy(sockaddr, ur->addrs[i].sockaddr, socklen); |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
328 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
329 switch (sockaddr->sa_family) { |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
330 #if (NGX_HAVE_INET6) |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
331 case AF_INET6: |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
332 ((struct sockaddr_in6 *) sockaddr)->sin6_port = htons(ur->port); |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
333 break; |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
334 #endif |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
335 default: /* AF_INET */ |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
336 ((struct sockaddr_in *) sockaddr)->sin_port = htons(ur->port); |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
337 } |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
338 |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
339 p = ngx_pnalloc(r->pool, NGX_SOCKADDR_STRLEN); |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
340 if (p == NULL) { |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
341 return NGX_ERROR; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
342 } |
1658 | 343 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5454
diff
changeset
|
344 len = ngx_sock_ntop(sockaddr, socklen, p, NGX_SOCKADDR_STRLEN, 1); |
1658 | 345 |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
346 peer[i].sockaddr = sockaddr; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
347 peer[i].socklen = socklen; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
348 peer[i].name.len = len; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
349 peer[i].name.data = p; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
350 peer[i].weight = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
351 peer[i].effective_weight = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
352 peer[i].current_weight = 0; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
353 peer[i].max_fails = 1; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
354 peer[i].fail_timeout = 10; |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2204
diff
changeset
|
355 } |
1658 | 356 } |
357 | |
358 rrp->peers = peers; | |
359 rrp->current = 0; | |
360 | |
361 if (rrp->peers->number <= 8 * sizeof(uintptr_t)) { | |
362 rrp->tried = &rrp->data; | |
363 rrp->data = 0; | |
364 | |
365 } else { | |
366 n = (rrp->peers->number + (8 * sizeof(uintptr_t) - 1)) | |
367 / (8 * sizeof(uintptr_t)); | |
368 | |
369 rrp->tried = ngx_pcalloc(r->pool, n * sizeof(uintptr_t)); | |
370 if (rrp->tried == NULL) { | |
371 return NGX_ERROR; | |
372 } | |
373 } | |
374 | |
375 r->upstream->peer.get = ngx_http_upstream_get_round_robin_peer; | |
376 r->upstream->peer.free = ngx_http_upstream_free_round_robin_peer; | |
377 r->upstream->peer.tries = rrp->peers->number; | |
378 #if (NGX_HTTP_SSL) | |
3964
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
379 r->upstream->peer.set_session = ngx_http_upstream_empty_set_session; |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
380 r->upstream->peer.save_session = ngx_http_upstream_empty_save_session; |
1658 | 381 #endif |
382 | |
383 return NGX_OK; | |
384 } | |
385 | |
386 | |
387 ngx_int_t | |
884 | 388 ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data) |
389 { | |
390 ngx_http_upstream_rr_peer_data_t *rrp = data; | |
391 | |
1378 | 392 ngx_int_t rc; |
393 ngx_uint_t i, n; | |
394 ngx_http_upstream_rr_peer_t *peer; | |
395 ngx_http_upstream_rr_peers_t *peers; | |
884 | 396 |
397 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, | |
398 "get rr peer, try: %ui", pc->tries); | |
399 | |
400 pc->cached = 0; | |
401 pc->connection = NULL; | |
402 | |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
403 peers = rrp->peers; |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
404 |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
405 /* ngx_lock_mutex(peers->mutex); */ |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
406 |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
407 if (peers->single) { |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
408 peer = &peers->peer[0]; |
884 | 409 |
4914
dcb853acae97
Upstream: honor the "down" flag for a single server.
Ruslan Ermilov <ru@nginx.com>
parents:
4655
diff
changeset
|
410 if (peer->down) { |
dcb853acae97
Upstream: honor the "down" flag for a single server.
Ruslan Ermilov <ru@nginx.com>
parents:
4655
diff
changeset
|
411 goto failed; |
dcb853acae97
Upstream: honor the "down" flag for a single server.
Ruslan Ermilov <ru@nginx.com>
parents:
4655
diff
changeset
|
412 } |
dcb853acae97
Upstream: honor the "down" flag for a single server.
Ruslan Ermilov <ru@nginx.com>
parents:
4655
diff
changeset
|
413 |
884 | 414 } else { |
415 | |
416 /* there are several peers */ | |
417 | |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
418 peer = ngx_http_upstream_get_peer(rrp); |
884 | 419 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
420 if (peer == NULL) { |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
421 goto failed; |
884 | 422 } |
423 | |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
424 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
425 "get rr peer, current: %ui %i", |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
426 rrp->current, peer->current_weight); |
884 | 427 } |
428 | |
429 pc->sockaddr = peer->sockaddr; | |
430 pc->socklen = peer->socklen; | |
431 pc->name = &peer->name; | |
432 | |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
433 /* ngx_unlock_mutex(peers->mutex); */ |
884 | 434 |
5720
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
435 if (pc->tries == 1 && peers->next) { |
ab540dd44528
Upstream: simplified some code that accesses peers.
Ruslan Ermilov <ru@nginx.com>
parents:
5717
diff
changeset
|
436 pc->tries += peers->next->number; |
1378 | 437 } |
438 | |
884 | 439 return NGX_OK; |
440 | |
441 failed: | |
442 | |
1378 | 443 if (peers->next) { |
444 | |
445 /* ngx_unlock_mutex(peers->mutex); */ | |
446 | |
447 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, "backup servers"); | |
448 | |
449 rrp->peers = peers->next; | |
450 pc->tries = rrp->peers->number; | |
451 | |
4991
a384c60d55f3
Upstream: fixed state resetting when switching to backup servers.
Valentin Bartenev <vbart@nginx.com>
parents:
4914
diff
changeset
|
452 n = (rrp->peers->number + (8 * sizeof(uintptr_t) - 1)) |
a384c60d55f3
Upstream: fixed state resetting when switching to backup servers.
Valentin Bartenev <vbart@nginx.com>
parents:
4914
diff
changeset
|
453 / (8 * sizeof(uintptr_t)); |
a384c60d55f3
Upstream: fixed state resetting when switching to backup servers.
Valentin Bartenev <vbart@nginx.com>
parents:
4914
diff
changeset
|
454 |
1389 | 455 for (i = 0; i < n; i++) { |
1378 | 456 rrp->tried[i] = 0; |
457 } | |
458 | |
459 rc = ngx_http_upstream_get_round_robin_peer(pc, rrp); | |
460 | |
461 if (rc != NGX_BUSY) { | |
462 return rc; | |
463 } | |
464 | |
465 /* ngx_lock_mutex(peers->mutex); */ | |
466 } | |
467 | |
884 | 468 /* all peers failed, mark them as live for quick recovery */ |
469 | |
1378 | 470 for (i = 0; i < peers->number; i++) { |
471 peers->peer[i].fails = 0; | |
884 | 472 } |
473 | |
1378 | 474 /* ngx_unlock_mutex(peers->mutex); */ |
884 | 475 |
1378 | 476 pc->name = peers->name; |
884 | 477 |
478 return NGX_BUSY; | |
479 } | |
480 | |
481 | |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
482 static ngx_http_upstream_rr_peer_t * |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
483 ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp) |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
484 { |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
485 time_t now; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
486 uintptr_t m; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
487 ngx_int_t total; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
488 ngx_uint_t i, n; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
489 ngx_http_upstream_rr_peer_t *peer, *best; |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
490 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
491 now = ngx_time(); |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
492 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
493 best = NULL; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
494 total = 0; |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
495 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
496 for (i = 0; i < rrp->peers->number; i++) { |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
497 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
498 n = i / (8 * sizeof(uintptr_t)); |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
499 m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t)); |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
500 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
501 if (rrp->tried[n] & m) { |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
502 continue; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
503 } |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
504 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
505 peer = &rrp->peers->peer[i]; |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
506 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
507 if (peer->down) { |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
508 continue; |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
509 } |
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
510 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
511 if (peer->max_fails |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
512 && peer->fails >= peer->max_fails |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
513 && now - peer->checked <= peer->fail_timeout) |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
514 { |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
515 continue; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
516 } |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
517 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
518 peer->current_weight += peer->effective_weight; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
519 total += peer->effective_weight; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
520 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
521 if (peer->effective_weight < peer->weight) { |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
522 peer->effective_weight++; |
4010
74a93d3fdd85
Fixing cpu hog with all upstream servers marked "down".
Maxim Dounin <mdounin@mdounin.ru>
parents:
3964
diff
changeset
|
523 } |
74a93d3fdd85
Fixing cpu hog with all upstream servers marked "down".
Maxim Dounin <mdounin@mdounin.ru>
parents:
3964
diff
changeset
|
524 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
525 if (best == NULL || peer->current_weight > best->current_weight) { |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
526 best = peer; |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
527 } |
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
528 } |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
529 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
530 if (best == NULL) { |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
531 return NULL; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
532 } |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
533 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
534 i = best - &rrp->peers->peer[0]; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
535 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
536 rrp->current = i; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
537 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
538 n = i / (8 * sizeof(uintptr_t)); |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
539 m = (uintptr_t) 1 << i % (8 * sizeof(uintptr_t)); |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
540 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
541 rrp->tried[n] |= m; |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
542 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
543 best->current_weight -= total; |
5220
1d68b502088c
Upstream: fixed fail_timeout and max_fails > 1.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5136
diff
changeset
|
544 |
1d68b502088c
Upstream: fixed fail_timeout and max_fails > 1.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5136
diff
changeset
|
545 if (now - best->checked > best->fail_timeout) { |
1d68b502088c
Upstream: fixed fail_timeout and max_fails > 1.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5136
diff
changeset
|
546 best->checked = now; |
1d68b502088c
Upstream: fixed fail_timeout and max_fails > 1.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5136
diff
changeset
|
547 } |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
548 |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
549 return best; |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
550 } |
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
551 |
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
552 |
884 | 553 void |
554 ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data, | |
555 ngx_uint_t state) | |
556 { | |
557 ngx_http_upstream_rr_peer_data_t *rrp = data; | |
558 | |
559 time_t now; | |
560 ngx_http_upstream_rr_peer_t *peer; | |
561 | |
562 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, | |
563 "free rr peer %ui %ui", pc->tries, state); | |
564 | |
565 /* TODO: NGX_PEER_KEEPALIVE */ | |
566 | |
1378 | 567 if (rrp->peers->single) { |
884 | 568 pc->tries = 0; |
569 return; | |
570 } | |
571 | |
4207
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
572 peer = &rrp->peers->peer[rrp->current]; |
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
573 |
884 | 574 if (state & NGX_PEER_FAILED) { |
575 now = ngx_time(); | |
576 | |
577 /* ngx_lock_mutex(rrp->peers->mutex); */ | |
578 | |
579 peer->fails++; | |
580 peer->accessed = now; | |
4207
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
581 peer->checked = now; |
884 | 582 |
2204
70a2bcc7e307
fix divide by zero if max_fails=0
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
583 if (peer->max_fails) { |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
584 peer->effective_weight -= peer->weight / peer->max_fails; |
2204
70a2bcc7e307
fix divide by zero if max_fails=0
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
585 } |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
586 |
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
587 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
588 "free rr peer failed: %ui %i", |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
589 rrp->current, peer->effective_weight); |
1344
8f5b5641966c
fair upstream weight balancer
Igor Sysoev <igor@sysoev.ru>
parents:
1284
diff
changeset
|
590 |
4621
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
591 if (peer->effective_weight < 0) { |
c90801720a0c
Upstream: smooth weighted round-robin balancing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4569
diff
changeset
|
592 peer->effective_weight = 0; |
884 | 593 } |
594 | |
595 /* ngx_unlock_mutex(rrp->peers->mutex); */ | |
4207
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
596 |
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
597 } else { |
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
598 |
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
599 /* mark peer live if check passed */ |
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
600 |
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
601 if (peer->accessed < peer->checked) { |
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
602 peer->fails = 0; |
4fc91bae6f83
Better recheck of dead upstream servers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4011
diff
changeset
|
603 } |
884 | 604 } |
605 | |
606 if (pc->tries) { | |
607 pc->tries--; | |
608 } | |
609 | |
610 /* ngx_unlock_mutex(rrp->peers->mutex); */ | |
611 } | |
612 | |
613 | |
614 #if (NGX_HTTP_SSL) | |
615 | |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
616 ngx_int_t |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
617 ngx_http_upstream_set_round_robin_peer_session(ngx_peer_connection_t *pc, |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
618 void *data) |
884 | 619 { |
620 ngx_http_upstream_rr_peer_data_t *rrp = data; | |
621 | |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
622 ngx_int_t rc; |
884 | 623 ngx_ssl_session_t *ssl_session; |
624 ngx_http_upstream_rr_peer_t *peer; | |
625 | |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
626 peer = &rrp->peers->peer[rrp->current]; |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
627 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
628 /* TODO: threads only mutex */ |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
629 /* ngx_lock_mutex(rrp->peers->mutex); */ |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
630 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
631 ssl_session = peer->ssl_session; |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
632 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
633 rc = ngx_ssl_set_session(pc->connection, ssl_session); |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
634 |
5756
5b7276408565
SSL: stop accessing SSL_SESSION's fields directly.
Piotr Sikora <piotr@cloudflare.com>
parents:
5720
diff
changeset
|
635 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
5b7276408565
SSL: stop accessing SSL_SESSION's fields directly.
Piotr Sikora <piotr@cloudflare.com>
parents:
5720
diff
changeset
|
636 "set session: %p", ssl_session); |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
637 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
638 /* ngx_unlock_mutex(rrp->peers->mutex); */ |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
639 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
640 return rc; |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
641 } |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
642 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
643 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
644 void |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
645 ngx_http_upstream_save_round_robin_peer_session(ngx_peer_connection_t *pc, |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
646 void *data) |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
647 { |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
648 ngx_http_upstream_rr_peer_data_t *rrp = data; |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
649 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
650 ngx_ssl_session_t *old_ssl_session, *ssl_session; |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
651 ngx_http_upstream_rr_peer_t *peer; |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
652 |
884 | 653 ssl_session = ngx_ssl_get_session(pc->connection); |
654 | |
655 if (ssl_session == NULL) { | |
656 return; | |
657 } | |
658 | |
5756
5b7276408565
SSL: stop accessing SSL_SESSION's fields directly.
Piotr Sikora <piotr@cloudflare.com>
parents:
5720
diff
changeset
|
659 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
5b7276408565
SSL: stop accessing SSL_SESSION's fields directly.
Piotr Sikora <piotr@cloudflare.com>
parents:
5720
diff
changeset
|
660 "save session: %p", ssl_session); |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
661 |
884 | 662 peer = &rrp->peers->peer[rrp->current]; |
663 | |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
664 /* TODO: threads only mutex */ |
884 | 665 /* ngx_lock_mutex(rrp->peers->mutex); */ |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
666 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
667 old_ssl_session = peer->ssl_session; |
884 | 668 peer->ssl_session = ssl_session; |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
669 |
884 | 670 /* ngx_unlock_mutex(rrp->peers->mutex); */ |
671 | |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
672 if (old_ssl_session) { |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
673 |
5756
5b7276408565
SSL: stop accessing SSL_SESSION's fields directly.
Piotr Sikora <piotr@cloudflare.com>
parents:
5720
diff
changeset
|
674 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
5b7276408565
SSL: stop accessing SSL_SESSION's fields directly.
Piotr Sikora <piotr@cloudflare.com>
parents:
5720
diff
changeset
|
675 "old session: %p", old_ssl_session); |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
676 |
884 | 677 /* TODO: may block */ |
1284
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
678 |
be2b895d31e0
fix segfault when session was freed twice
Igor Sysoev <igor@sysoev.ru>
parents:
1206
diff
changeset
|
679 ngx_ssl_free_session(old_ssl_session); |
884 | 680 } |
681 } | |
682 | |
3964
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
683 |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
684 static ngx_int_t |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
685 ngx_http_upstream_empty_set_session(ngx_peer_connection_t *pc, void *data) |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
686 { |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
687 return NGX_OK; |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
688 } |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
689 |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
690 |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
691 static void |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
692 ngx_http_upstream_empty_save_session(ngx_peer_connection_t *pc, void *data) |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
693 { |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
694 return; |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
695 } |
ff127ba3b091
do not try to reuse and save a SSL session for a peer created on the fly
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
696 |
884 | 697 #endif |