diff options
author | Valentin Bartenev <vbart@nginx.com> | 2012-01-30 10:01:39 +0000 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2012-01-30 10:01:39 +0000 |
commit | 73d0b6a72134552cbcd54f2ee5887d438080b587 (patch) | |
tree | a7c1de2b2f80cc93c13b6ce206606c978268228a /src | |
parent | 8dab3b5a39493fb2803e0391a8ec4d1ee999f966 (diff) | |
download | nginx-73d0b6a72134552cbcd54f2ee5887d438080b587.tar.gz nginx-73d0b6a72134552cbcd54f2ee5887d438080b587.zip |
Limit req: number of cleanup calls reduced.
Doing a cleanup before every lookup seems to be too aggressive. It can lead to
premature removal of the nodes still usable, which increases the amount of work
under a mutex lock and therefore decreases performance.
In order to improve cleanup behavior, cleanup function call has been moved right
before the allocation of a new node.
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_limit_req_module.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_limit_req_module.c b/src/http/modules/ngx_http_limit_req_module.c index 8778a160a..63fd9d0da 100644 --- a/src/http/modules/ngx_http_limit_req_module.c +++ b/src/http/modules/ngx_http_limit_req_module.c @@ -182,8 +182,6 @@ ngx_http_limit_req_handler(ngx_http_request_t *r) ngx_shmtx_lock(&ctx->shpool->mutex); - ngx_http_limit_req_expire(ctx, 1); - rc = ngx_http_limit_req_lookup(lrcf, hash, vv->data, len, &excess); ngx_shmtx_unlock(&ctx->shpool->mutex); @@ -385,6 +383,8 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash, + offsetof(ngx_http_limit_req_node_t, data) + len; + ngx_http_limit_req_expire(ctx, 1); + node = ngx_slab_alloc_locked(ctx->shpool, size); if (node == NULL) { |