changeset 3183:b87542338ac3

make limit_req to conform to the leaky bucket algorithm
author Igor Sysoev <igor@sysoev.ru>
date Tue, 06 Oct 2009 09:37:18 +0000
parents 6ddaac3e0bf7
children 88f972ffe96e
files src/http/modules/ngx_http_limit_req_module.c
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
 
                 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
 
                 *lrp = lr;
 
-                if ((ngx_uint_t) excess > lrcf->burst) {
-                    return NGX_BUSY;
-                }
-
                 if (excess) {
                     return NGX_AGAIN;
                 }