Mercurial > hg > nginx
changeset 2442:6978f3827a5c
*) fix duplicate geo ranges
*) split existent range and insert a new one
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 16 Jan 2009 13:17:12 +0000 |
parents | 0c117a89f399 |
children | a8697cc12b3a |
files | src/http/modules/ngx_http_geo_module.c |
diffstat | 1 files changed, 44 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_geo_module.c Thu Jan 15 13:10:45 2009 +0000 +++ b/src/http/modules/ngx_http_geo_module.c Fri Jan 16 13:17:12 2009 +0000 @@ -567,7 +567,9 @@ ngx_memcpy(&range[i + 2], &range[i + 1], (a->nelts - 2 - i) * sizeof(ngx_http_geo_range_t)); - range = &range[i + 1]; + range[i + 1].start = (u_short) s; + range[i + 1].end = (u_short) e; + range[i + 1].value = ctx->value; goto next; } @@ -578,7 +580,43 @@ ngx_conf_log_error(NGX_LOG_WARN, cf, 0, "duplicate range \"%V\", value: \"%v\", old value: \"%v\"", ctx->net, ctx->value, range[i].value); - continue; + + range[i].value = ctx->value; + + goto next; + } + + if (s > (ngx_uint_t) range[i].start + && e < (ngx_uint_t) range[i].end) + { + /* split the range and insert the new one */ + + range = ngx_array_push(a); + if (range == NULL) { + return NGX_CONF_ERROR; + } + + range = ngx_array_push(a); + if (range == NULL) { + return NGX_CONF_ERROR; + } + + range = a->elts; + + ngx_memcpy(&range[i + 3], &range[i + 1], + (a->nelts - 3 - i) * sizeof(ngx_http_geo_range_t)); + + range[i + 2].start = (u_short) (e + 1); + range[i + 2].end = range[i].end; + range[i + 2].value = range[i].value; + + range[i].end = (u_short) (s - 1); + + range[i + 1].start = (u_short) s; + range[i + 1].end = (u_short) e; + range[i + 1].value = ctx->value; + + goto next; } ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, @@ -594,11 +632,13 @@ return NGX_CONF_ERROR; } - next: - range->start = (u_short) s; range->end = (u_short) e; range->value = ctx->value; + + next: + + continue; } return NGX_CONF_OK;