Mercurial > hg > nginx-quic
diff src/http/modules/ngx_http_geo_module.c @ 553:45033d85b30e release-0.2.5
nginx-0.2.5-RELEASE import
*) Change: the duplicate value of the ngx_http_geo_module variable now
causes the warning and changes old value.
*) Feature: the ngx_http_ssi_module supports the "set" command.
*) Feature: the ngx_http_ssi_module supports the "file" parameter in
the "include" command.
*) Feature: the ngx_http_ssi_module supports the variable value
substitutions in expressions of the "if" command.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 04 Oct 2005 10:38:53 +0000 |
parents | 818fbd4750b9 |
children | 9c2f3ed7a247 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_geo_module.c +++ b/src/http/modules/ngx_http_geo_module.c @@ -182,11 +182,11 @@ static char * ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) { ngx_int_t rc, n; + ngx_str_t *value, file; ngx_uint_t i; - ngx_str_t *value, file; ngx_inet_cidr_t cidrin; ngx_http_geo_conf_t *geo; - ngx_http_variable_value_t *var, **v; + ngx_http_variable_value_t *var, *old, **v; geo = cf->ctx; @@ -274,17 +274,33 @@ ngx_http_geo(ngx_conf_t *cf, ngx_command *v = var; } - rc = ngx_radix32tree_insert(geo->tree, cidrin.addr, cidrin.mask, - (uintptr_t) var); - if (rc == NGX_ERROR) { - return NGX_CONF_ERROR; + for (i = 2; i; i--) { + rc = ngx_radix32tree_insert(geo->tree, cidrin.addr, cidrin.mask, + (uintptr_t) var); + if (rc == NGX_OK) { + return NGX_CONF_OK; + } + + if (rc == NGX_ERROR) { + return NGX_CONF_ERROR; + } + + /* rc == NGX_BUSY */ + + old = (ngx_http_variable_value_t *) + ngx_radix32tree_find(geo->tree, cidrin.addr & cidrin.mask); + + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "duplicate parameter \"%V\", value: \"%V\", " + "old value: \"%V\"", + &value[0], &var->text, &old->text); + + rc = ngx_radix32tree_delete(geo->tree, cidrin.addr, cidrin.mask); + + if (rc == NGX_ERROR) { + return NGX_CONF_ERROR; + } } - if (rc == NGX_BUSY) { - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "duplicate parameter \"%V\"", - &value[0]); - return NGX_CONF_ERROR; - } - - return NGX_CONF_OK; + return NGX_CONF_ERROR; }