Mercurial > hg > nginx
comparison src/http/modules/ngx_http_geo_module.c @ 4968:90d8c3400769
Geo: fixed the "ranges" without ranges case.
The following configuration returned an empty value for $geo:
geo $geo {
ranges;
default default;
}
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Fri, 14 Dec 2012 19:56:03 +0000 |
parents | a9d60fafaa85 |
children | 8b635cf36ccc |
comparison
equal
deleted
inserted
replaced
4967:a9d60fafaa85 | 4968:90d8c3400769 |
---|---|
187 ngx_uint_t n; | 187 ngx_uint_t n; |
188 ngx_http_geo_range_t *range; | 188 ngx_http_geo_range_t *range; |
189 | 189 |
190 *v = *ctx->u.high.default_value; | 190 *v = *ctx->u.high.default_value; |
191 | 191 |
192 addr = ngx_http_geo_addr(r, ctx); | 192 if (ctx->u.high.low) { |
193 | 193 addr = ngx_http_geo_addr(r, ctx); |
194 range = ctx->u.high.low[addr >> 16]; | 194 |
195 | 195 range = ctx->u.high.low[addr >> 16]; |
196 if (range) { | 196 |
197 n = addr & 0xffff; | 197 if (range) { |
198 do { | 198 n = addr & 0xffff; |
199 if (n >= (ngx_uint_t) range->start && n <= (ngx_uint_t) range->end) | 199 do { |
200 { | 200 if (n >= (ngx_uint_t) range->start |
201 *v = *range->value; | 201 && n <= (ngx_uint_t) range->end) |
202 break; | 202 { |
203 } | 203 *v = *range->value; |
204 } while ((++range)->value); | 204 break; |
205 } | |
206 } while ((++range)->value); | |
207 } | |
205 } | 208 } |
206 | 209 |
207 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 210 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
208 "http geo: %v", v); | 211 "http geo: %v", v); |
209 | 212 |
382 *cf = save; | 385 *cf = save; |
383 | 386 |
384 geo->proxies = ctx.proxies; | 387 geo->proxies = ctx.proxies; |
385 geo->proxy_recursive = ctx.proxy_recursive; | 388 geo->proxy_recursive = ctx.proxy_recursive; |
386 | 389 |
387 if (ctx.high.low) { | 390 if (ctx.ranges) { |
388 | 391 |
389 if (!ctx.binary_include) { | 392 if (ctx.high.low && !ctx.binary_include) { |
390 for (i = 0; i < 0x10000; i++) { | 393 for (i = 0; i < 0x10000; i++) { |
391 a = (ngx_array_t *) ctx.high.low[i]; | 394 a = (ngx_array_t *) ctx.high.low[i]; |
392 | 395 |
393 if (a == NULL || a->nelts == 0) { | 396 if (a == NULL || a->nelts == 0) { |
394 continue; | 397 continue; |