# HG changeset patch # User Igor Sysoev # Date 1168192037 0 # Node ID dd128232e6bafcad94ceb5b49b49ea678f46ced6 # Parent 7a8ca436d61141edab3b38e2ddf1e09850d900ba count connection once per request diff --git a/src/http/modules/ngx_http_limit_zone_module.c b/src/http/modules/ngx_http_limit_zone_module.c --- a/src/http/modules/ngx_http_limit_zone_module.c +++ b/src/http/modules/ngx_http_limit_zone_module.c @@ -107,6 +107,10 @@ ngx_http_limit_zone_handler(ngx_http_req 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_req return NGX_DECLINED; } + r->limit_zone_set = 1; + len = vv->len; hash = ngx_crc32_short(vv->data, len); diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -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