diff options
author | Ruslan Ermilov <ru@nginx.com> | 2012-12-14 19:56:03 +0000 |
---|---|---|
committer | Ruslan Ermilov <ru@nginx.com> | 2012-12-14 19:56:03 +0000 |
commit | 18a7e1b359597aaed8e302bc7c55d3146ee632ef (patch) | |
tree | 54d3fd953f4bdb863a69833ef14e85bda070e826 /src | |
parent | cd04ca3546f64deeabcbd477c5eb627f1af71685 (diff) | |
download | nginx-18a7e1b359597aaed8e302bc7c55d3146ee632ef.tar.gz nginx-18a7e1b359597aaed8e302bc7c55d3146ee632ef.zip |
Geo: fixed the "ranges" without ranges case.
The following configuration returned an empty value for $geo:
geo $geo {
ranges;
default default;
}
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_geo_module.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c index 8d2679db5..0e0aa0edc 100644 --- a/src/http/modules/ngx_http_geo_module.c +++ b/src/http/modules/ngx_http_geo_module.c @@ -189,19 +189,22 @@ ngx_http_geo_range_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, *v = *ctx->u.high.default_value; - addr = ngx_http_geo_addr(r, ctx); - - range = ctx->u.high.low[addr >> 16]; - - if (range) { - n = addr & 0xffff; - do { - if (n >= (ngx_uint_t) range->start && n <= (ngx_uint_t) range->end) - { - *v = *range->value; - break; - } - } while ((++range)->value); + if (ctx->u.high.low) { + addr = ngx_http_geo_addr(r, ctx); + + range = ctx->u.high.low[addr >> 16]; + + if (range) { + n = addr & 0xffff; + do { + if (n >= (ngx_uint_t) range->start + && n <= (ngx_uint_t) range->end) + { + *v = *range->value; + break; + } + } while ((++range)->value); + } } ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, @@ -384,9 +387,9 @@ ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) geo->proxies = ctx.proxies; geo->proxy_recursive = ctx.proxy_recursive; - if (ctx.high.low) { + if (ctx.ranges) { - if (!ctx.binary_include) { + if (ctx.high.low && !ctx.binary_include) { for (i = 0; i < 0x10000; i++) { a = (ngx_array_t *) ctx.high.low[i]; |