Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-04-21 11:50:19 +0400
committerIgor Sysoev <igor@sysoev.ru>2007-04-21 11:50:19 +0400
commitb4ccb9f5bd1ae7ea59e2f78c31ec713bb10af0ff (patch)
tree73172325b181d406d61fb6880b2535c172663cef
parent60472812081386c0f2fda3139aef07a10f095173 (diff)
$request_time has millisecond precision
-rw-r--r--src/http/modules/ngx_http_log_module.c13
-rw-r--r--src/http/ngx_http_core_module.c2
-rw-r--r--src/http/ngx_http_request.c5
-rw-r--r--src/http/ngx_http_request.h3
-rw-r--r--src/http/ngx_http_write_filter_module.c2
5 files changed, 16 insertions, 9 deletions
diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
index e4b861bf0..d3ebca4f1 100644
--- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c
@@ -170,7 +170,8 @@ static ngx_http_log_var_t ngx_http_log_vars[] = {
{ ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
ngx_http_log_time },
{ ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec },
- { ngx_string("request_time"), NGX_TIME_T_LEN, ngx_http_log_request_time },
+ { ngx_string("request_time"), NGX_TIME_T_LEN + 4,
+ ngx_http_log_request_time },
{ ngx_string("status"), 3, ngx_http_log_status },
{ ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent },
{ ngx_string("body_bytes_sent"), NGX_OFF_T_LEN,
@@ -394,11 +395,15 @@ static u_char *
ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
ngx_http_log_op_t *op)
{
- time_t elapsed;
+ ngx_time_t *tp;
+ ngx_msec_int_t ms;
- elapsed = ngx_time() - r->start_time;
+ tp = ngx_timeofday();
+
+ ms = (tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec);
+ ms = (ms >= 0) ? ms : 0;
- return ngx_sprintf(buf, "%T", elapsed);
+ return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000);
}
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 7fa0ba347..76f5e9831 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1353,8 +1353,6 @@ ngx_http_subrequest(ngx_http_request_t *r,
sr->headers_in = r->headers_in;
- sr->start_time = ngx_time();
-
ngx_http_clear_content_length(sr);
ngx_http_clear_accept_ranges(sr);
ngx_http_clear_last_modified(sr);
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 1a2e1bc27..9b5d02f94 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -212,6 +212,7 @@ ngx_http_init_connection(ngx_connection_t *c)
static void
ngx_http_init_request(ngx_event_t *rev)
{
+ ngx_time_t *tp;
socklen_t len;
ngx_uint_t i;
struct sockaddr_in sin;
@@ -421,7 +422,9 @@ ngx_http_init_request(ngx_event_t *rev)
r->main = r;
- r->start_time = ngx_time();
+ tp = ngx_timeofday();
+ r->start_sec = tp->sec;
+ r->start_msec = tp->msec;
r->method = NGX_HTTP_UNKNOWN;
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 414efd7a2..a380ac0f0 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -342,7 +342,8 @@ struct ngx_http_request_s {
ngx_http_request_body_t *request_body;
time_t lingering_time;
- time_t start_time;
+ time_t start_sec;
+ ngx_msec_t start_msec;
ngx_uint_t method;
ngx_uint_t http_version;
diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c
index b25d07e81..2015c43ba 100644
--- a/src/http/ngx_http_write_filter_module.c
+++ b/src/http/ngx_http_write_filter_module.c
@@ -210,7 +210,7 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
if (r->limit_rate) {
- to_send = r->limit_rate * (ngx_time() - r->start_time + 1) - c->sent;
+ to_send = r->limit_rate * (ngx_time() - r->start_sec + 1) - c->sent;
if (to_send <= 0) {
c->write->delayed = 1;