Skip to content

Commit 9208875

Browse files
committed
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 }
1 parent 20de5f1 commit 9208875

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

src/http/modules/ngx_http_geo_module.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ ngx_http_geo_delete_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
990990

991991
a = (ngx_array_t *) ctx->high.low[h];
992992

993-
if (a == NULL) {
993+
if (a == NULL || a->nelts == 0) {
994994
warn = 1;
995995
goto next;
996996
}
@@ -1009,13 +1009,9 @@ ngx_http_geo_delete_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
10091009
break;
10101010
}
10111011

1012-
if (s != (ngx_uint_t) range[i].start
1013-
&& e != (ngx_uint_t) range[i].end)
1014-
{
1015-
continue;
1012+
if (i == a->nelts - 1) {
1013+
warn = 1;
10161014
}
1017-
1018-
warn = 1;
10191015
}
10201016

10211017
next:

src/stream/ngx_stream_geo_module.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ ngx_stream_geo_delete_range(ngx_conf_t *cf, ngx_stream_geo_conf_ctx_t *ctx,
940940

941941
a = (ngx_array_t *) ctx->high.low[h];
942942

943-
if (a == NULL) {
943+
if (a == NULL || a->nelts == 0) {
944944
warn = 1;
945945
goto next;
946946
}
@@ -959,13 +959,9 @@ ngx_stream_geo_delete_range(ngx_conf_t *cf, ngx_stream_geo_conf_ctx_t *ctx,
959959
break;
960960
}
961961

962-
if (s != (ngx_uint_t) range[i].start
963-
&& e != (ngx_uint_t) range[i].end)
964-
{
965-
continue;
962+
if (i == a->nelts - 1) {
963+
warn = 1;
966964
}
967-
968-
warn = 1;
969965
}
970966

971967
next:

0 commit comments

Comments
 (0)