[nginx] Geo: fixed warnings when removing nonexistent ranges.

Ruslan Ermilov ru at nginx.com
Tue Aug 23 14:00:31 UTC 2016


details:   http://hg.nginx.org/nginx/rev/0ee6f023ef92
branches:  
changeset: 6664:0ee6f023ef92
user:      Ruslan Ermilov <ru at nginx.com>
date:      Tue Aug 23 15:59:42 2016 +0300
description:
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
}

diffstat:

 src/http/modules/ngx_http_geo_module.c |  10 +++-------
 src/stream/ngx_stream_geo_module.c     |  10 +++-------
 2 files changed, 6 insertions(+), 14 deletions(-)

diffs (56 lines):

diff -r 53198d9bf84f -r 0ee6f023ef92 src/http/modules/ngx_http_geo_module.c
--- a/src/http/modules/ngx_http_geo_module.c	Tue Aug 23 15:59:14 2016 +0300
+++ b/src/http/modules/ngx_http_geo_module.c	Tue Aug 23 15:59:42 2016 +0300
@@ -990,7 +990,7 @@ ngx_http_geo_delete_range(ngx_conf_t *cf
 
         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
                 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:
diff -r 53198d9bf84f -r 0ee6f023ef92 src/stream/ngx_stream_geo_module.c
--- a/src/stream/ngx_stream_geo_module.c	Tue Aug 23 15:59:14 2016 +0300
+++ b/src/stream/ngx_stream_geo_module.c	Tue Aug 23 15:59:42 2016 +0300
@@ -940,7 +940,7 @@ ngx_stream_geo_delete_range(ngx_conf_t *
 
         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 *
                 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:



More information about the nginx-devel mailing list