[nginx] Upstream: reduced diffs to the plus version of nginx.
Ruslan Ermilov
ru at nginx.com
Fri Jun 20 12:27:17 UTC 2014
details: http://hg.nginx.org/nginx/rev/63d7d69d0fe4
branches:
changeset: 5728:63d7d69d0fe4
user: Ruslan Ermilov <ru at 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;
More information about the nginx-devel
mailing list