forked from Hakase/nginx-build
Latest update - 7281
This commit is contained in:
@@ -43,8 +43,8 @@ extern volatile ngx_str_t ngx_cached_http_log_iso8601;
|
|||||||
extern volatile ngx_str_t ngx_cached_syslog_time;
|
extern volatile ngx_str_t ngx_cached_syslog_time;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* milliseconds elapsed since epoch and truncated to ngx_msec_t,
|
* milliseconds elapsed since some unspecified point in the past
|
||||||
* used in event timers
|
* and truncated to ngx_msec_t, used in event timers
|
||||||
*/
|
*/
|
||||||
extern volatile ngx_msec_t ngx_current_msec;
|
extern volatile ngx_msec_t ngx_current_msec;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
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) {
|
if (excess < 0) {
|
||||||
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) {
|
if (account) {
|
||||||
lr->excess = excess;
|
lr->excess = excess;
|
||||||
lr->last = now;
|
|
||||||
|
if (ms) {
|
||||||
|
lr->last = now;
|
||||||
|
}
|
||||||
|
|
||||||
return NGX_OK;
|
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;
|
now = ngx_current_msec;
|
||||||
ms = (ngx_msec_int_t) (now - lr->last);
|
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) {
|
if (excess < 0) {
|
||||||
excess = 0;
|
excess = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lr->last = now;
|
if (ms) {
|
||||||
|
lr->last = now;
|
||||||
|
}
|
||||||
|
|
||||||
lr->excess = excess;
|
lr->excess = excess;
|
||||||
lr->count--;
|
lr->count--;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user