From 5b96378eae5ea5fdc41ac24a474b4eb65381b460 Mon Sep 17 00:00:00 2001 From: Kirill A. Korinskiy Date: Sat, 16 May 2009 00:14:34 +0400 Subject: [PATCH] Add $mstimestamp Cc: catap@catap.ru --- src/http/ngx_http_variables.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 97ae784c270ad3a98544c991ebb0a0d075df2b67..0ede0ee72de0a99fad53ff0df4d98d4a41e0f7b7 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -99,6 +99,8 @@ 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_timestamp(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_mstimestamp(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); /* * TODO: @@ -264,6 +266,9 @@ static ngx_http_variable_t ngx_http_core_variables[] = { { ngx_string("timestamp"), NULL, ngx_http_variable_timestamp, 0, 0, 0 }, + { ngx_string("mstimestamp"), NULL, ngx_http_variable_mstimestamp, + 0, 0, 0 }, + { ngx_null_string, NULL, NULL, 0, 0, 0 } }; @@ -1816,6 +1821,27 @@ ngx_http_variable_timestamp(ngx_http_request_t *r, } +static ngx_int_t +ngx_http_variable_mstimestamp(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + u_char *p; + + p = ngx_pnalloc(r->pool, NGX_INT64_LEN + sizeof("123") - 1); + if (p == NULL) { + return NGX_ERROR; + } + + v->len = ngx_sprintf(p, "%T%03M", ngx_time(), (ngx_timeofday())->msec) - p; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = p; + + return NGX_OK; +} + + ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf) { -- 1.6.2