diff src/http/modules/ngx_http_limit_req_module.c @ 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 70c8b2d28d1d
children 30570a5b9bb0
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;
                 }