mirror of
https://github.com/nginx/nginx.git
synced 2024-12-04 13:59:00 +08:00
*) fix duplicate geo ranges
*) split existent range and insert a new one
This commit is contained in:
parent
f7204173f9
commit
73f9bb4d01
@ -567,7 +567,9 @@ ngx_http_geo_add_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
|
||||
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_http_geo_add_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
|
||||
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 @@ ngx_http_geo_add_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user