]> git.kaiwu.me - nginx.git/commitdiff
stop rbtree search early if equal hash was found
authorIgor Sysoev <igor@sysoev.ru>
Thu, 11 Jan 2007 16:57:30 +0000 (16:57 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Thu, 11 Jan 2007 16:57:30 +0000 (16:57 +0000)
src/http/modules/ngx_http_limit_zone_module.c

index abab4ad11bdcf6508549e99b0be7dc2bb1f99ee5..ca7910e39f88c615e2eb38084bc9e3758d47cb7c 100644 (file)
@@ -173,7 +173,9 @@ ngx_http_limit_zone_handler(ngx_http_request_t *r)
             continue;
         }
 
-        if (hash == node->key ){
+        /* hash == node->key */
+
+        do {
             lz = (ngx_http_limit_zone_node_t *) &node->color;
 
             if (len == (size_t) lz->len
@@ -188,7 +190,12 @@ ngx_http_limit_zone_handler(ngx_http_request_t *r)
 
                 return NGX_HTTP_SERVICE_UNAVAILABLE;
             }
-        }
+
+            node = node->right;
+
+        } while (node != sentinel && hash == node->key);
+
+        break;
     }
 
     n = offsetof(ngx_rbtree_node_t, color)