# HG changeset patch # User Igor Sysoev # Date 1254821838 0 # Node ID b87542338ac31317cb6833265fcb69f374de4183 # Parent 6ddaac3e0bf76f7a072a799d0f283f94a06d13ea make limit_req to conform to the leaky bucket algorithm diff --git a/src/http/modules/ngx_http_limit_req_module.c b/src/http/modules/ngx_http_limit_req_module.c --- 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; }