diff options
| author | Ruslan Ermilov <ru@nginx.com> | 2016-08-08 17:11:29 +0300 |
|---|---|---|
| committer | Ruslan Ermilov <ru@nginx.com> | 2016-08-08 17:11:29 +0300 |
| commit | 47e72bf7e0e14a7c62022e7c428e506ccb7ed43f (patch) | |
| tree | fada724ecbfe1c58ad3061375074315b91fd8af5 /src/http/modules/ngx_http_limit_req_module.c | |
| parent | af9e72533a69de3b8b7ed59be7be9b37203b5c82 (diff) | |
| download | nginx-47e72bf7e0e14a7c62022e7c428e506ccb7ed43f.tar.gz nginx-47e72bf7e0e14a7c62022e7c428e506ccb7ed43f.tar.bz2 | |
Simplified extraction of current time.
Diffstat (limited to 'src/http/modules/ngx_http_limit_req_module.c')
| -rw-r--r-- | src/http/modules/ngx_http_limit_req_module.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/http/modules/ngx_http_limit_req_module.c b/src/http/modules/ngx_http_limit_req_module.c index 9059ac376..2f695f212 100644 --- a/src/http/modules/ngx_http_limit_req_module.c +++ b/src/http/modules/ngx_http_limit_req_module.c @@ -362,15 +362,13 @@ ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limit, ngx_uint_t hash, { size_t size; ngx_int_t rc, excess; - ngx_time_t *tp; ngx_msec_t now; ngx_msec_int_t ms; ngx_rbtree_node_t *node, *sentinel; ngx_http_limit_req_ctx_t *ctx; ngx_http_limit_req_node_t *lr; - tp = ngx_timeofday(); - now = (ngx_msec_t) (tp->sec * 1000 + tp->msec); + now = ngx_current_msec; ctx = limit->shm_zone->data; @@ -483,7 +481,6 @@ ngx_http_limit_req_account(ngx_http_limit_req_limit_t *limits, ngx_uint_t n, ngx_uint_t *ep, ngx_http_limit_req_limit_t **limit) { ngx_int_t excess; - ngx_time_t *tp; ngx_msec_t now, delay, max_delay; ngx_msec_int_t ms; ngx_http_limit_req_ctx_t *ctx; @@ -509,9 +506,7 @@ ngx_http_limit_req_account(ngx_http_limit_req_limit_t *limits, ngx_uint_t n, ngx_shmtx_lock(&ctx->shpool->mutex); - tp = ngx_timeofday(); - - now = (ngx_msec_t) (tp->sec * 1000 + tp->msec); + now = ngx_current_msec; ms = (ngx_msec_int_t) (now - lr->last); excess = lr->excess - ctx->rate * ngx_abs(ms) / 1000 + 1000; @@ -549,16 +544,13 @@ static void ngx_http_limit_req_expire(ngx_http_limit_req_ctx_t *ctx, ngx_uint_t n) { ngx_int_t excess; - ngx_time_t *tp; ngx_msec_t now; ngx_queue_t *q; ngx_msec_int_t ms; ngx_rbtree_node_t *node; ngx_http_limit_req_node_t *lr; - tp = ngx_timeofday(); - - now = (ngx_msec_t) (tp->sec * 1000 + tp->msec); + now = ngx_current_msec; /* * n == 1 deletes one or two zero rate entries |
