Welcome! Log In Create A New Profile

Advanced

[nginx] Upstream: reduced diffs to the plus version of nginx.

Ruslan Ermilov
June 20, 2014 08:28AM
details: http://hg.nginx.org/nginx/rev/63d7d69d0fe4
branches:
changeset: 5728:63d7d69d0fe4
user: Ruslan Ermilov <ru@nginx.com>
date: Fri Jun 20 12:55:41 2014 +0400
description:
Upstream: reduced diffs to the plus version of nginx.

No functional changes.

diffstat:

src/http/ngx_http_upstream.c | 174 +++++++++++++++++++++---------------------
1 files changed, 86 insertions(+), 88 deletions(-)

diffs (212 lines):

diff -r 675bda8dcfdb -r 63d7d69d0fe4 src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c Thu Jun 19 13:55:59 2014 +0400
+++ b/src/http/ngx_http_upstream.c Fri Jun 20 12:55:41 2014 +0400
@@ -4851,6 +4851,12 @@ ngx_http_upstream(ngx_conf_t *cf, ngx_co
}
}

+ uscf->servers = ngx_array_create(cf->pool, 4,
+ sizeof(ngx_http_upstream_server_t));
+ if (uscf->servers == NULL) {
+ return NGX_CONF_ERROR;
+ }
+

/* parse inside upstream{} */

@@ -4866,7 +4872,7 @@ ngx_http_upstream(ngx_conf_t *cf, ngx_co
return rv;
}

- if (uscf->servers == NULL) {
+ if (uscf->servers->nelts == 0) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"no servers are inside upstream");
return NGX_CONF_ERROR;
@@ -4888,14 +4894,6 @@ ngx_http_upstream_server(ngx_conf_t *cf,
ngx_uint_t i;
ngx_http_upstream_server_t *us;

- if (uscf->servers == NULL) {
- uscf->servers = ngx_array_create(cf->pool, 4,
- sizeof(ngx_http_upstream_server_t));
- if (uscf->servers == NULL) {
- return NGX_CONF_ERROR;
- }
- }
-
us = ngx_array_push(uscf->servers);
if (us == NULL) {
return NGX_CONF_ERROR;
@@ -4905,6 +4903,85 @@ ngx_http_upstream_server(ngx_conf_t *cf,

value = cf->args->elts;

+ weight = 1;
+ max_fails = 1;
+ fail_timeout = 10;
+
+ for (i = 2; i < cf->args->nelts; i++) {
+
+ if (ngx_strncmp(value[i].data, "weight=", 7) == 0) {
+
+ if (!(uscf->flags & NGX_HTTP_UPSTREAM_WEIGHT)) {
+ goto invalid;
+ }
+
+ weight = ngx_atoi(&value[i].data[7], value[i].len - 7);
+
+ if (weight == NGX_ERROR || weight == 0) {
+ goto invalid;
+ }
+
+ continue;
+ }
+
+ if (ngx_strncmp(value[i].data, "max_fails=", 10) == 0) {
+
+ if (!(uscf->flags & NGX_HTTP_UPSTREAM_MAX_FAILS)) {
+ goto invalid;
+ }
+
+ max_fails = ngx_atoi(&value[i].data[10], value[i].len - 10);
+
+ if (max_fails == NGX_ERROR) {
+ goto invalid;
+ }
+
+ continue;
+ }
+
+ if (ngx_strncmp(value[i].data, "fail_timeout=", 13) == 0) {
+
+ if (!(uscf->flags & NGX_HTTP_UPSTREAM_FAIL_TIMEOUT)) {
+ goto invalid;
+ }
+
+ s.len = value[i].len - 13;
+ s.data = &value[i].data[13];
+
+ fail_timeout = ngx_parse_time(&s, 1);
+
+ if (fail_timeout == (time_t) NGX_ERROR) {
+ goto invalid;
+ }
+
+ continue;
+ }
+
+ if (ngx_strcmp(value[i].data, "backup") == 0) {
+
+ if (!(uscf->flags & NGX_HTTP_UPSTREAM_BACKUP)) {
+ goto invalid;
+ }
+
+ us->backup = 1;
+
+ continue;
+ }
+
+ if (ngx_strcmp(value[i].data, "down") == 0) {
+
+ if (!(uscf->flags & NGX_HTTP_UPSTREAM_DOWN)) {
+ goto invalid;
+ }
+
+ us->down = 1;
+
+ continue;
+ }
+
+ goto invalid;
+ }
+
ngx_memzero(&u, sizeof(ngx_url_t));

u.url = value[1];
@@ -4919,85 +4996,6 @@ ngx_http_upstream_server(ngx_conf_t *cf,
return NGX_CONF_ERROR;
}

- weight = 1;
- max_fails = 1;
- fail_timeout = 10;
-
- for (i = 2; i < cf->args->nelts; i++) {
-
- if (ngx_strncmp(value[i].data, "weight=", 7) == 0) {
-
- if (!(uscf->flags & NGX_HTTP_UPSTREAM_WEIGHT)) {
- goto invalid;
- }
-
- weight = ngx_atoi(&value[i].data[7], value[i].len - 7);
-
- if (weight == NGX_ERROR || weight == 0) {
- goto invalid;
- }
-
- continue;
- }
-
- if (ngx_strncmp(value[i].data, "max_fails=", 10) == 0) {
-
- if (!(uscf->flags & NGX_HTTP_UPSTREAM_MAX_FAILS)) {
- goto invalid;
- }
-
- max_fails = ngx_atoi(&value[i].data[10], value[i].len - 10);
-
- if (max_fails == NGX_ERROR) {
- goto invalid;
- }
-
- continue;
- }
-
- if (ngx_strncmp(value[i].data, "fail_timeout=", 13) == 0) {
-
- if (!(uscf->flags & NGX_HTTP_UPSTREAM_FAIL_TIMEOUT)) {
- goto invalid;
- }
-
- s.len = value[i].len - 13;
- s.data = &value[i].data[13];
-
- fail_timeout = ngx_parse_time(&s, 1);
-
- if (fail_timeout == (time_t) NGX_ERROR) {
- goto invalid;
- }
-
- continue;
- }
-
- if (ngx_strcmp(value[i].data, "backup") == 0) {
-
- if (!(uscf->flags & NGX_HTTP_UPSTREAM_BACKUP)) {
- goto invalid;
- }
-
- us->backup = 1;
-
- continue;
- }
-
- if (ngx_strcmp(value[i].data, "down") == 0) {
-
- if (!(uscf->flags & NGX_HTTP_UPSTREAM_DOWN)) {
- goto invalid;
- }
-
- us->down = 1;
-
- continue;
- }
-
- goto invalid;
- }
-
us->name = u.url;
us->addrs = u.addrs;
us->naddrs = u.naddrs;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Upstream: reduced diffs to the plus version of nginx.

Ruslan Ermilov 714 June 20, 2014 08:28AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 301
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready