mirror of
https://github.com/nginx/nginx.git
synced 2026-10-24 04:52:25 +00:00
make limit_req to conform to the leaky bucket algorithm
This commit is contained in:
parent
a2951910d3
commit
5d4b802370
1 changed files with 5 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue