Created
December 8, 2012 05:08
-
-
Save lawrencepit/4238738 to your computer and use it in GitHub Desktop.
nginx variable $start_msec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From c008c94e9c1018b1caa8e8f17db3087fd24d70df Mon Sep 17 00:00:00 2001 | |
From: Lawrence Pit <[email protected]> | |
Date: Sat, 8 Dec 2012 15:32:17 +1100 | |
Subject: [PATCH] Variable $start_msec. | |
--- | |
src/http/ngx_http_variables.c | 26 ++++++++++++++++++++++++++ | |
1 file changed, 26 insertions(+) | |
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c | |
index db41964..c8fc09a 100644 | |
--- a/src/http/ngx_http_variables.c | |
+++ b/src/http/ngx_http_variables.c | |
@@ -112,6 +112,8 @@ static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r, | |
ngx_http_variable_value_t *v, uintptr_t data); | |
static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r, | |
ngx_http_variable_value_t *v, uintptr_t data); | |
+static ngx_int_t ngx_http_variable_start_msec(ngx_http_request_t *r, | |
+ ngx_http_variable_value_t *v, uintptr_t data); | |
static ngx_int_t ngx_http_variable_msec(ngx_http_request_t *r, | |
ngx_http_variable_value_t *v, uintptr_t data); | |
@@ -294,6 +296,9 @@ static ngx_http_variable_t ngx_http_core_variables[] = { | |
{ ngx_string("pid"), NULL, ngx_http_variable_pid, | |
0, 0, 0 }, | |
+ { ngx_string("start_msec"), NULL, ngx_http_variable_start_msec, | |
+ 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, | |
+ | |
{ ngx_string("msec"), NULL, ngx_http_variable_msec, | |
0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, | |
@@ -1998,6 +2003,27 @@ ngx_http_variable_pid(ngx_http_request_t *r, | |
static ngx_int_t | |
+ngx_http_variable_start_msec(ngx_http_request_t *r, | |
+ ngx_http_variable_value_t *v, uintptr_t data) | |
+{ | |
+ u_char *p; | |
+ | |
+ p = ngx_pnalloc(r->pool, NGX_TIME_T_LEN + 4); | |
+ if (p == NULL) { | |
+ return NGX_ERROR; | |
+ } | |
+ | |
+ v->len = ngx_sprintf(p, "%T.%03M", r->start_sec, r->start_msec) - p; | |
+ v->valid = 1; | |
+ v->no_cacheable = 0; | |
+ v->not_found = 0; | |
+ v->data = p; | |
+ | |
+ return NGX_OK; | |
+} | |
+ | |
+ | |
+static ngx_int_t | |
ngx_http_variable_msec(ngx_http_request_t *r, | |
ngx_http_variable_value_t *v, uintptr_t data) | |
{ | |
-- | |
1.7.11.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment