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
index 84e70b4..b203d96 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 @@
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 @@
*lrp = lr;
- if ((ngx_uint_t) excess > lrcf->burst) {
- return NGX_BUSY;
- }
-
if (excess) {
return NGX_AGAIN;
}