Geo: fixed warnings when removing nonexistent ranges.

geo $geo {
    ranges;

    10.0.0.0-10.0.0.255 test;

    delete 10.0.1.0-10.0.1.255;     # should warn

    delete 10.0.0.0-10.0.0.255;
    delete 10.0.0.0-10.0.0.255;     # should warn
}
This commit is contained in:
Ruslan Ermilov 2016-08-23 15:59:42 +03:00
parent 20de5f14e5
commit 9208875db1
2 changed files with 6 additions and 14 deletions

View File

@ -990,7 +990,7 @@ ngx_http_geo_delete_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
a = (ngx_array_t *) ctx->high.low[h]; a = (ngx_array_t *) ctx->high.low[h];
if (a == NULL) { if (a == NULL || a->nelts == 0) {
warn = 1; warn = 1;
goto next; goto next;
} }
@ -1009,13 +1009,9 @@ ngx_http_geo_delete_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
break; break;
} }
if (s != (ngx_uint_t) range[i].start if (i == a->nelts - 1) {
&& e != (ngx_uint_t) range[i].end) warn = 1;
{
continue;
} }
warn = 1;
} }
next: next:

View File

@ -940,7 +940,7 @@ ngx_stream_geo_delete_range(ngx_conf_t *cf, ngx_stream_geo_conf_ctx_t *ctx,
a = (ngx_array_t *) ctx->high.low[h]; a = (ngx_array_t *) ctx->high.low[h];
if (a == NULL) { if (a == NULL || a->nelts == 0) {
warn = 1; warn = 1;
goto next; goto next;
} }
@ -959,13 +959,9 @@ ngx_stream_geo_delete_range(ngx_conf_t *cf, ngx_stream_geo_conf_ctx_t *ctx,
break; break;
} }
if (s != (ngx_uint_t) range[i].start if (i == a->nelts - 1) {
&& e != (ngx_uint_t) range[i].end) warn = 1;
{
continue;
} }
warn = 1;
} }
next: next: