]> git.kaiwu.me - nginx.git/commitdiff
Geo: fixed warnings when removing nonexistent ranges.
authorRuslan Ermilov <ru@nginx.com>
Tue, 23 Aug 2016 12:59:42 +0000 (15:59 +0300)
committerRuslan Ermilov <ru@nginx.com>
Tue, 23 Aug 2016 12:59:42 +0000 (15:59 +0300)
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
}

src/http/modules/ngx_http_geo_module.c
src/stream/ngx_stream_geo_module.c

index 2794548edbad6252bde0525237309883a4ff0220..21b4b334f28684497f2f2fde8d47faf26076f5c7 100644 (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];
 
-        if (a == NULL) {
+        if (a == NULL || a->nelts == 0) {
             warn = 1;
             goto next;
         }
@@ -1009,13 +1009,9 @@ ngx_http_geo_delete_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
                 break;
             }
 
-            if (s != (ngx_uint_t) range[i].start
-                && e != (ngx_uint_t) range[i].end)
-            {
-                continue;
+            if (i == a->nelts - 1) {
+                warn = 1;
             }
-
-            warn = 1;
         }
 
     next:
index 5e91c46fbcb8556fd5654ff77903789605e03f8e..220454631aed4a0e24822328d540228b856f33eb 100644 (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];
 
-        if (a == NULL) {
+        if (a == NULL || a->nelts == 0) {
             warn = 1;
             goto next;
         }
@@ -959,13 +959,9 @@ ngx_stream_geo_delete_range(ngx_conf_t *cf, ngx_stream_geo_conf_ctx_t *ctx,
                 break;
             }
 
-            if (s != (ngx_uint_t) range[i].start
-                && e != (ngx_uint_t) range[i].end)
-            {
-                continue;
+            if (i == a->nelts - 1) {
+                warn = 1;
             }
-
-            warn = 1;
         }
 
     next: