Mercurial > hg > nginx
comparison 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 |
comparison
equal
deleted
inserted
replaced
552:b6f3197058d3 | 553:45033d85b30e |
---|---|
180 | 180 |
181 static char * | 181 static char * |
182 ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) | 182 ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) |
183 { | 183 { |
184 ngx_int_t rc, n; | 184 ngx_int_t rc, n; |
185 ngx_str_t *value, file; | |
185 ngx_uint_t i; | 186 ngx_uint_t i; |
186 ngx_str_t *value, file; | |
187 ngx_inet_cidr_t cidrin; | 187 ngx_inet_cidr_t cidrin; |
188 ngx_http_geo_conf_t *geo; | 188 ngx_http_geo_conf_t *geo; |
189 ngx_http_variable_value_t *var, **v; | 189 ngx_http_variable_value_t *var, *old, **v; |
190 | 190 |
191 geo = cf->ctx; | 191 geo = cf->ctx; |
192 | 192 |
193 if (cf->args->nelts != 2) { | 193 if (cf->args->nelts != 2) { |
194 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 194 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
272 } | 272 } |
273 | 273 |
274 *v = var; | 274 *v = var; |
275 } | 275 } |
276 | 276 |
277 rc = ngx_radix32tree_insert(geo->tree, cidrin.addr, cidrin.mask, | 277 for (i = 2; i; i--) { |
278 (uintptr_t) var); | 278 rc = ngx_radix32tree_insert(geo->tree, cidrin.addr, cidrin.mask, |
279 if (rc == NGX_ERROR) { | 279 (uintptr_t) var); |
280 return NGX_CONF_ERROR; | 280 if (rc == NGX_OK) { |
281 } | 281 return NGX_CONF_OK; |
282 | 282 } |
283 if (rc == NGX_BUSY) { | 283 |
284 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "duplicate parameter \"%V\"", | 284 if (rc == NGX_ERROR) { |
285 &value[0]); | 285 return NGX_CONF_ERROR; |
286 return NGX_CONF_ERROR; | 286 } |
287 } | 287 |
288 | 288 /* rc == NGX_BUSY */ |
289 return NGX_CONF_OK; | 289 |
290 old = (ngx_http_variable_value_t *) | |
291 ngx_radix32tree_find(geo->tree, cidrin.addr & cidrin.mask); | |
292 | |
293 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
294 "duplicate parameter \"%V\", value: \"%V\", " | |
295 "old value: \"%V\"", | |
296 &value[0], &var->text, &old->text); | |
297 | |
298 rc = ngx_radix32tree_delete(geo->tree, cidrin.addr, cidrin.mask); | |
299 | |
300 if (rc == NGX_ERROR) { | |
301 return NGX_CONF_ERROR; | |
302 } | |
303 } | |
304 | |
305 return NGX_CONF_ERROR; | |
290 } | 306 } |