nginx-0.3.37-RELEASE import

    *) Feature: the "limit_except" directive.

    *) Feature: the "if" directive supports the "!~", "!~*", "-f", and
       "!-f" operators.

    *) Feature: the ngx_http_perl_module supports the $r->request_body
       method.

    *) Bugfix: in the ngx_http_addition_filter_module.
diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c
index 2876318..0ee5e77 100644
--- a/src/core/ngx_hash.c
+++ b/src/core/ngx_hash.c
@@ -164,10 +164,14 @@
         return NGX_ERROR;
     }
 
-    start = nelts / (ngx_cacheline_size / (2 * sizeof(void *)) - 1);
+    bucket_size = hinit->bucket_size - sizeof(void *);
+
+    start = nelts / (bucket_size / (2 * sizeof(void *)) - 1);
     start = start ? start : 1;
 
-    bucket_size = hinit->bucket_size - sizeof(void *);
+    if (hinit->max_size > 10000 && hinit->max_size / nelts < 100) {
+        start = hinit->max_size - 1000;
+    }
 
     for (size = start; size < hinit->max_size; size++) {