]> git.kaiwu.me - nginx.git/commitdiff
count connection once per request
authorIgor Sysoev <igor@sysoev.ru>
Sun, 7 Jan 2007 17:47:17 +0000 (17:47 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Sun, 7 Jan 2007 17:47:17 +0000 (17:47 +0000)
src/http/modules/ngx_http_limit_zone_module.c
src/http/ngx_http_request.h

index 218c0de7f12d0b5a68d2cacf05fc9452a8c0e3e0..e262a8176d87295716357fb3e712308dde5efd86 100644 (file)
@@ -107,6 +107,10 @@ ngx_http_limit_zone_handler(ngx_http_request_t *r)
     ngx_http_limit_zone_conf_t     *lzcf;
     ngx_http_limit_zone_cleanup_t  *lzcln;
 
+    if (r->limit_zone_set) {
+        return NGX_DECLINED;
+    }
+
     lzcf = ngx_http_get_module_loc_conf(r, ngx_http_limit_zone_module);
 
     if (lzcf->shm_zone == NULL) {
@@ -119,6 +123,8 @@ ngx_http_limit_zone_handler(ngx_http_request_t *r)
         return NGX_DECLINED;
     }
 
+    r->limit_zone_set = 1;
+
     len = vv->len;
 
     hash = ngx_crc32_short(vv->data, len);
index 25f07b109f68a83a642d5d2d66cbabdc46b00680..5cdcb94989ec47ce30948faaa47cff651e4fdd2a 100644 (file)
@@ -430,6 +430,12 @@ struct ngx_http_request_s {
 
 #endif
 
+    /*
+     * instead of using the request context data in ngx_http_limit_zone_module
+     * we use the single bit in the request structure
+     */
+    unsigned                          limit_zone_set:1;
+
 #if 0
     unsigned                          cachable:1;
 #endif