summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-01-16 16:29:23 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-01-16 16:29:23 +0000
commitc1a2b978de2831883cbaa791cf0a7483c270bf66 (patch)
treef71dc7d3d527fd5d382c96e423253259618d0f3b
parent53554ae54d4f32ba4e05d815692e0a8b8c202d9e (diff)
downloadnginx-c1a2b978de2831883cbaa791cf0a7483c270bf66.tar.gz
nginx-c1a2b978de2831883cbaa791cf0a7483c270bf66.tar.bz2
allow insertion range if its start or end is the same as existent one
-rw-r--r--src/http/modules/ngx_http_geo_module.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c
index 003f02c6b..5535eb299 100644
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -615,12 +615,60 @@ ngx_http_geo_add_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
range[i + 2].end = range[i].end;
range[i + 2].value = range[i].value;
+ range[i + 1].start = (u_short) s;
+ range[i + 1].end = (u_short) e;
+ range[i + 1].value = ctx->value;
+
range[i].end = (u_short) (s - 1);
+ goto next;
+ }
+
+ if (s == (ngx_uint_t) range[i].start
+ && e < (ngx_uint_t) range[i].end)
+ {
+ /* shift the range start and insert the new range */
+
+ range = ngx_array_push(a);
+ if (range == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ range = a->elts;
+
+ ngx_memcpy(&range[i + 2], &range[i + 1],
+ (a->nelts - 2 - i) * sizeof(ngx_http_geo_range_t));
+
+ range[i + 1].start = (u_short) (e + 1);
+
+ range[i].start = (u_short) s;
+ range[i].end = (u_short) e;
+ range[i].value = ctx->value;
+
+ goto next;
+ }
+
+ if (s > (ngx_uint_t) range[i].start
+ && e == (ngx_uint_t) range[i].end)
+ {
+ /* shift the range end and insert the new range */
+
+ range = ngx_array_push(a);
+ if (range == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ range = a->elts;
+
+ ngx_memcpy(&range[i + 2], &range[i + 1],
+ (a->nelts - 2 - i) * sizeof(ngx_http_geo_range_t));
+
range[i + 1].start = (u_short) s;
range[i + 1].end = (u_short) e;
range[i + 1].value = ctx->value;
+ range[i].end = (u_short) (s - 1);
+
goto next;
}