Latest update - 7281
This commit is contained in:
@@ -399,7 +399,14 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit, ngx_uint_t hash,
|
||||
|
||||
ms = (ngx_msec_int_t) (now - lr->last);
|
||||
|
||||
excess = lr->excess - ctx->rate * ngx_abs(ms) / 1000 + 1000;
|
||||
if (ms < -60000) {
|
||||
ms = 1;
|
||||
|
||||
} else if (ms < 0) {
|
||||
ms = 0;
|
||||
}
|
||||
|
||||
excess = lr->excess - ctx->rate * ms / 1000 + 1000;
|
||||
|
||||
if (excess < 0) {
|
||||
excess = 0;
|
||||
@@ -413,7 +420,11 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit, ngx_uint_t hash,
|
||||
|
||||
if (account) {
|
||||
lr->excess = excess;
|
||||
lr->last = now;
|
||||
|
||||
if (ms) {
|
||||
lr->last = now;
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
@@ -509,13 +520,23 @@ ngx_http_limit_req_account(ngx_http_limit_req_limit_t *limits, ngx_uint_t n,
|
||||
now = ngx_current_msec;
|
||||
ms = (ngx_msec_int_t) (now - lr->last);
|
||||
|
||||
excess = lr->excess - ctx->rate * ngx_abs(ms) / 1000 + 1000;
|
||||
if (ms < -60000) {
|
||||
ms = 1;
|
||||
|
||||
} else if (ms < 0) {
|
||||
ms = 0;
|
||||
}
|
||||
|
||||
excess = lr->excess - ctx->rate * ms / 1000 + 1000;
|
||||
|
||||
if (excess < 0) {
|
||||
excess = 0;
|
||||
}
|
||||
|
||||
lr->last = now;
|
||||
if (ms) {
|
||||
lr->last = now;
|
||||
}
|
||||
|
||||
lr->excess = excess;
|
||||
lr->count--;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user