aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-10-06 09:37:18 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-10-06 09:37:18 +0000
commit5d4b802370e0e3f1bacb68908a6eb7e8c1bdcfd8 (patch)
tree571de073cc7242f5fcc8a9f055ee1981abb69755 /src
parenta2951910d3b63f005777fc74051eddab6437de93 (diff)
downloadnginx-5d4b802370e0e3f1bacb68908a6eb7e8c1bdcfd8.tar.gz
nginx-5d4b802370e0e3f1bacb68908a6eb7e8c1bdcfd8.zip
make limit_req to conform to the leaky bucket algorithm
Diffstat (limited to 'src')
-rw-r--r--src/http/modules/ngx_http_limit_req_module.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/http/modules/ngx_http_limit_req_module.c b/src/http/modules/ngx_http_limit_req_module.c
index 84e70b4f4..b203d96e3 100644
--- a/src/http/modules/ngx_http_limit_req_module.c
+++ b/src/http/modules/ngx_http_limit_req_module.c
@@ -379,6 +379,11 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash,
excess = lr->excess - ctx->rate * ngx_abs(ms) / 1000 + 1000;
+ if ((ngx_uint_t) excess > lrcf->burst) {
+ *lrp = lr;
+ return NGX_BUSY;
+ }
+
if (excess < 0) {
excess = 0;
}
@@ -388,10 +393,6 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash,
*lrp = lr;
- if ((ngx_uint_t) excess > lrcf->burst) {
- return NGX_BUSY;
- }
-
if (excess) {
return NGX_AGAIN;
}