Mercurial > hg > nginx-vendor-1-0
diff src/http/ngx_http_variables.c @ 410:a8e3f1441eec NGINX_0_7_17
nginx 0.7.17
*) Feature: now the "directio" directive works on Linux.
*) Feature: the $pid variable.
*) Bugfix: the "directio" optimization that had appeared in 0.7.15 did
not work with open_file_cache.
*) Bugfix: the "access_log" with variables did not work on Linux; the
bug had appeared in 0.7.7.
*) Bugfix: the ngx_http_charset_module did not understand quoted
charset name received from backend.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 15 Sep 2008 00:00:00 +0400 |
parents | 79c5df00501e |
children | b246022ef454 |
line wrap: on
line diff
--- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -78,6 +78,8 @@ static ngx_int_t ngx_http_variable_nginx ngx_http_variable_value_t *v, uintptr_t data); 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); /* * TODO: @@ -227,6 +229,9 @@ static ngx_http_variable_t ngx_http_cor { ngx_string("hostname"), NULL, ngx_http_variable_hostname, 0, 0, 0 }, + { ngx_string("pid"), NULL, ngx_http_variable_pid, + 0, 0, 0 }, + { ngx_null_string, NULL, NULL, 0, 0, 0 } }; @@ -1353,6 +1358,27 @@ ngx_http_variable_hostname(ngx_http_requ } +static ngx_int_t +ngx_http_variable_pid(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); + if (p == NULL) { + return NGX_ERROR; + } + + v->len = ngx_sprintf(p, "%P", ngx_pid) - 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) {