diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-10-04 10:38:53 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-10-04 10:38:53 +0000 |
commit | f6e1fe3f28ee43792a4543e8b9e8702713c5b74a (patch) | |
tree | 67cd150690123c53effef3aac42cca767ceafbbf /src/http/modules/ngx_http_geo_module.c | |
parent | 4dabff2624d4bae5e9cae37fb80d864501481432 (diff) | |
download | nginx-f6e1fe3f28ee43792a4543e8b9e8702713c5b74a.tar.gz nginx-f6e1fe3f28ee43792a4543e8b9e8702713c5b74a.zip |
nginx-0.2.5-RELEASE importrelease-0.2.5
*) 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.
Diffstat (limited to 'src/http/modules/ngx_http_geo_module.c')
-rw-r--r-- | src/http/modules/ngx_http_geo_module.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c index 2031a4c0b..eedc1f7b2 100644 --- 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_uint_t i; ngx_str_t *value, file; + ngx_uint_t i; 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_t *dummy, void *conf) *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_BUSY) { - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "duplicate parameter \"%V\"", - &value[0]); - return NGX_CONF_ERROR; + 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; + } } - return NGX_CONF_OK; + return NGX_CONF_ERROR; } |