comparison src/http/ngx_http_upstream.c @ 5818:fe8bafab5b49

Upstream: improved configuration parser diagnostics. Made it clear when the selected balancing method does not support certain parameters of the "server" directive.
author Ruslan Ermilov <ru@nginx.com>
date Mon, 01 Sep 2014 12:27:38 +0400
parents 9bf58a3da25b
children 54e9b83d00f0
comparison
equal deleted inserted replaced
5817:74ffe03555d0 5818:fe8bafab5b49
4971 for (i = 2; i < cf->args->nelts; i++) { 4971 for (i = 2; i < cf->args->nelts; i++) {
4972 4972
4973 if (ngx_strncmp(value[i].data, "weight=", 7) == 0) { 4973 if (ngx_strncmp(value[i].data, "weight=", 7) == 0) {
4974 4974
4975 if (!(uscf->flags & NGX_HTTP_UPSTREAM_WEIGHT)) { 4975 if (!(uscf->flags & NGX_HTTP_UPSTREAM_WEIGHT)) {
4976 goto invalid; 4976 goto not_supported;
4977 } 4977 }
4978 4978
4979 weight = ngx_atoi(&value[i].data[7], value[i].len - 7); 4979 weight = ngx_atoi(&value[i].data[7], value[i].len - 7);
4980 4980
4981 if (weight == NGX_ERROR || weight == 0) { 4981 if (weight == NGX_ERROR || weight == 0) {
4986 } 4986 }
4987 4987
4988 if (ngx_strncmp(value[i].data, "max_fails=", 10) == 0) { 4988 if (ngx_strncmp(value[i].data, "max_fails=", 10) == 0) {
4989 4989
4990 if (!(uscf->flags & NGX_HTTP_UPSTREAM_MAX_FAILS)) { 4990 if (!(uscf->flags & NGX_HTTP_UPSTREAM_MAX_FAILS)) {
4991 goto invalid; 4991 goto not_supported;
4992 } 4992 }
4993 4993
4994 max_fails = ngx_atoi(&value[i].data[10], value[i].len - 10); 4994 max_fails = ngx_atoi(&value[i].data[10], value[i].len - 10);
4995 4995
4996 if (max_fails == NGX_ERROR) { 4996 if (max_fails == NGX_ERROR) {
5001 } 5001 }
5002 5002
5003 if (ngx_strncmp(value[i].data, "fail_timeout=", 13) == 0) { 5003 if (ngx_strncmp(value[i].data, "fail_timeout=", 13) == 0) {
5004 5004
5005 if (!(uscf->flags & NGX_HTTP_UPSTREAM_FAIL_TIMEOUT)) { 5005 if (!(uscf->flags & NGX_HTTP_UPSTREAM_FAIL_TIMEOUT)) {
5006 goto invalid; 5006 goto not_supported;
5007 } 5007 }
5008 5008
5009 s.len = value[i].len - 13; 5009 s.len = value[i].len - 13;
5010 s.data = &value[i].data[13]; 5010 s.data = &value[i].data[13];
5011 5011
5019 } 5019 }
5020 5020
5021 if (ngx_strcmp(value[i].data, "backup") == 0) { 5021 if (ngx_strcmp(value[i].data, "backup") == 0) {
5022 5022
5023 if (!(uscf->flags & NGX_HTTP_UPSTREAM_BACKUP)) { 5023 if (!(uscf->flags & NGX_HTTP_UPSTREAM_BACKUP)) {
5024 goto invalid; 5024 goto not_supported;
5025 } 5025 }
5026 5026
5027 us->backup = 1; 5027 us->backup = 1;
5028 5028
5029 continue; 5029 continue;
5030 } 5030 }
5031 5031
5032 if (ngx_strcmp(value[i].data, "down") == 0) { 5032 if (ngx_strcmp(value[i].data, "down") == 0) {
5033 5033
5034 if (!(uscf->flags & NGX_HTTP_UPSTREAM_DOWN)) { 5034 if (!(uscf->flags & NGX_HTTP_UPSTREAM_DOWN)) {
5035 goto invalid; 5035 goto not_supported;
5036 } 5036 }
5037 5037
5038 us->down = 1; 5038 us->down = 1;
5039 5039
5040 continue; 5040 continue;
5068 5068
5069 invalid: 5069 invalid:
5070 5070
5071 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 5071 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
5072 "invalid parameter \"%V\"", &value[i]); 5072 "invalid parameter \"%V\"", &value[i]);
5073
5074 return NGX_CONF_ERROR;
5075
5076 not_supported:
5077
5078 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
5079 "balancing method does not support parameter \"%V\"",
5080 &value[i]);
5073 5081
5074 return NGX_CONF_ERROR; 5082 return NGX_CONF_ERROR;
5075 } 5083 }
5076 5084
5077 5085