comparison src/http/modules/ngx_http_upstream_keepalive_module.c @ 678:981b4c44593b NGINX_1_3_2

nginx 1.3.2 *) Change: the "single" parameter of the "keepalive" directive is now ignored. *) Change: SSL compression is now disabled when using all versions of OpenSSL, including ones prior to 1.0.0. *) Feature: it is now possible to use the "ip_hash" directive to balance IPv6 clients. *) Feature: the $status variable can now be used not only in the "log_format" directive. *) Bugfix: a segmentation fault might occur in a worker process on shutdown if the "resolver" directive was used. *) Bugfix: a segmentation fault might occur in a worker process if the ngx_http_mp4_module was used. *) Bugfix: in the ngx_http_mp4_module. *) Bugfix: a segmentation fault might occur in a worker process if conflicting wildcard server names were used. *) Bugfix: nginx might be terminated abnormally on a SIGBUS signal on ARM platform. *) Bugfix: an alert "sendmsg() failed (9: Bad file number)" on HP-UX while reconfiguration.
author Igor Sysoev <http://sysoev.ru>
date Tue, 26 Jun 2012 00:00:00 +0400
parents d0f7a625f27c
children
comparison
equal deleted inserted replaced
677:47f0934d8824 678:981b4c44593b
10 #include <ngx_http.h> 10 #include <ngx_http.h>
11 11
12 12
13 typedef struct { 13 typedef struct {
14 ngx_uint_t max_cached; 14 ngx_uint_t max_cached;
15 ngx_uint_t single; /* unsigned:1 */
16 15
17 ngx_queue_t cache; 16 ngx_queue_t cache;
18 ngx_queue_t free; 17 ngx_queue_t free;
19 18
20 ngx_http_upstream_init_pt original_init_upstream; 19 ngx_http_upstream_init_pt original_init_upstream;
221 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, 220 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0,
222 "get keepalive peer"); 221 "get keepalive peer");
223 222
224 kp->failed = 0; 223 kp->failed = 0;
225 224
226 /* single pool of cached connections */ 225 /* ask balancer */
227
228 if (kp->conf->single && !ngx_queue_empty(&kp->conf->cache)) {
229
230 q = ngx_queue_head(&kp->conf->cache);
231
232 item = ngx_queue_data(q, ngx_http_upstream_keepalive_cache_t, queue);
233 c = item->connection;
234
235 ngx_queue_remove(q);
236 ngx_queue_insert_head(&kp->conf->free, q);
237
238 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
239 "get keepalive peer: using connection %p", c);
240
241 c->idle = 0;
242 c->log = pc->log;
243 c->read->log = pc->log;
244 c->write->log = pc->log;
245 c->pool->log = pc->log;
246
247 pc->connection = c;
248 pc->cached = 1;
249
250 return NGX_DONE;
251 }
252 226
253 rc = kp->original_get_peer(pc, kp->data); 227 rc = kp->original_get_peer(pc, kp->data);
254 228
255 if (kp->conf->single || rc != NGX_OK) { 229 if (rc != NGX_OK) {
256 return rc; 230 return rc;
257 } 231 }
258 232
259 /* search cache for suitable connection */ 233 /* search cache for suitable connection */
260 234
550 kcf->max_cached = n; 524 kcf->max_cached = n;
551 525
552 for (i = 2; i < cf->args->nelts; i++) { 526 for (i = 2; i < cf->args->nelts; i++) {
553 527
554 if (ngx_strcmp(value[i].data, "single") == 0) { 528 if (ngx_strcmp(value[i].data, "single") == 0) {
555 kcf->single = 1; 529 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
530 "the \"single\" parameter is deprecated");
556 continue; 531 continue;
557 } 532 }
558 533
559 goto invalid; 534 goto invalid;
560 } 535 }