Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 6705:29bf0dbc0a77
Upstream: max_conns.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 22 Sep 2016 19:32:47 +0300 |
parents | edcd9303a4d3 |
children | 7e5199f172fb |
comparison
equal
deleted
inserted
replaced
6704:a44ba757851d | 6705:29bf0dbc0a77 |
---|---|
5442 u.no_resolve = 1; | 5442 u.no_resolve = 1; |
5443 u.no_port = 1; | 5443 u.no_port = 1; |
5444 | 5444 |
5445 uscf = ngx_http_upstream_add(cf, &u, NGX_HTTP_UPSTREAM_CREATE | 5445 uscf = ngx_http_upstream_add(cf, &u, NGX_HTTP_UPSTREAM_CREATE |
5446 |NGX_HTTP_UPSTREAM_WEIGHT | 5446 |NGX_HTTP_UPSTREAM_WEIGHT |
5447 |NGX_HTTP_UPSTREAM_MAX_CONNS | |
5447 |NGX_HTTP_UPSTREAM_MAX_FAILS | 5448 |NGX_HTTP_UPSTREAM_MAX_FAILS |
5448 |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT | 5449 |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT |
5449 |NGX_HTTP_UPSTREAM_DOWN | 5450 |NGX_HTTP_UPSTREAM_DOWN |
5450 |NGX_HTTP_UPSTREAM_BACKUP); | 5451 |NGX_HTTP_UPSTREAM_BACKUP); |
5451 if (uscf == NULL) { | 5452 if (uscf == NULL) { |
5543 ngx_http_upstream_srv_conf_t *uscf = conf; | 5544 ngx_http_upstream_srv_conf_t *uscf = conf; |
5544 | 5545 |
5545 time_t fail_timeout; | 5546 time_t fail_timeout; |
5546 ngx_str_t *value, s; | 5547 ngx_str_t *value, s; |
5547 ngx_url_t u; | 5548 ngx_url_t u; |
5548 ngx_int_t weight, max_fails; | 5549 ngx_int_t weight, max_conns, max_fails; |
5549 ngx_uint_t i; | 5550 ngx_uint_t i; |
5550 ngx_http_upstream_server_t *us; | 5551 ngx_http_upstream_server_t *us; |
5551 | 5552 |
5552 us = ngx_array_push(uscf->servers); | 5553 us = ngx_array_push(uscf->servers); |
5553 if (us == NULL) { | 5554 if (us == NULL) { |
5557 ngx_memzero(us, sizeof(ngx_http_upstream_server_t)); | 5558 ngx_memzero(us, sizeof(ngx_http_upstream_server_t)); |
5558 | 5559 |
5559 value = cf->args->elts; | 5560 value = cf->args->elts; |
5560 | 5561 |
5561 weight = 1; | 5562 weight = 1; |
5563 max_conns = 0; | |
5562 max_fails = 1; | 5564 max_fails = 1; |
5563 fail_timeout = 10; | 5565 fail_timeout = 10; |
5564 | 5566 |
5565 for (i = 2; i < cf->args->nelts; i++) { | 5567 for (i = 2; i < cf->args->nelts; i++) { |
5566 | 5568 |
5571 } | 5573 } |
5572 | 5574 |
5573 weight = ngx_atoi(&value[i].data[7], value[i].len - 7); | 5575 weight = ngx_atoi(&value[i].data[7], value[i].len - 7); |
5574 | 5576 |
5575 if (weight == NGX_ERROR || weight == 0) { | 5577 if (weight == NGX_ERROR || weight == 0) { |
5578 goto invalid; | |
5579 } | |
5580 | |
5581 continue; | |
5582 } | |
5583 | |
5584 if (ngx_strncmp(value[i].data, "max_conns=", 10) == 0) { | |
5585 | |
5586 if (!(uscf->flags & NGX_HTTP_UPSTREAM_MAX_CONNS)) { | |
5587 goto not_supported; | |
5588 } | |
5589 | |
5590 max_conns = ngx_atoi(&value[i].data[10], value[i].len - 10); | |
5591 | |
5592 if (max_conns == NGX_ERROR) { | |
5576 goto invalid; | 5593 goto invalid; |
5577 } | 5594 } |
5578 | 5595 |
5579 continue; | 5596 continue; |
5580 } | 5597 } |
5653 | 5670 |
5654 us->name = u.url; | 5671 us->name = u.url; |
5655 us->addrs = u.addrs; | 5672 us->addrs = u.addrs; |
5656 us->naddrs = u.naddrs; | 5673 us->naddrs = u.naddrs; |
5657 us->weight = weight; | 5674 us->weight = weight; |
5675 us->max_conns = max_conns; | |
5658 us->max_fails = max_fails; | 5676 us->max_fails = max_fails; |
5659 us->fail_timeout = fail_timeout; | 5677 us->fail_timeout = fail_timeout; |
5660 | 5678 |
5661 return NGX_CONF_OK; | 5679 return NGX_CONF_OK; |
5662 | 5680 |