mirror of
https://github.com/nginx/nginx.git
synced 2025-06-16 16:51:05 +08:00
Variables $connection and $connection_requests.
Log module counterparts are removed as they aren't used often and there is no need to preserve them for efficiency.
This commit is contained in:
parent
7b3731862b
commit
1e12e7fa1d
@ -78,10 +78,6 @@ static void ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log,
|
|||||||
static ssize_t ngx_http_log_script_write(ngx_http_request_t *r,
|
static ssize_t ngx_http_log_script_write(ngx_http_request_t *r,
|
||||||
ngx_http_log_script_t *script, u_char **name, u_char *buf, size_t len);
|
ngx_http_log_script_t *script, u_char **name, u_char *buf, size_t len);
|
||||||
|
|
||||||
static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
|
|
||||||
ngx_http_log_op_t *op);
|
|
||||||
static u_char *ngx_http_log_connection_requests(ngx_http_request_t *r,
|
|
||||||
u_char *buf, ngx_http_log_op_t *op);
|
|
||||||
static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf,
|
static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf,
|
||||||
ngx_http_log_op_t *op);
|
ngx_http_log_op_t *op);
|
||||||
static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf,
|
static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf,
|
||||||
@ -194,9 +190,6 @@ static ngx_str_t ngx_http_combined_fmt =
|
|||||||
|
|
||||||
|
|
||||||
static ngx_http_log_var_t ngx_http_log_vars[] = {
|
static ngx_http_log_var_t ngx_http_log_vars[] = {
|
||||||
{ ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection },
|
|
||||||
{ ngx_string("connection_requests"), NGX_INT_T_LEN,
|
|
||||||
ngx_http_log_connection_requests },
|
|
||||||
{ ngx_string("pipe"), 1, ngx_http_log_pipe },
|
{ ngx_string("pipe"), 1, ngx_http_log_pipe },
|
||||||
{ ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
|
{ ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
|
||||||
ngx_http_log_time },
|
ngx_http_log_time },
|
||||||
@ -499,22 +492,6 @@ ngx_http_log_copy_long(ngx_http_request_t *r, u_char *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static u_char *
|
|
||||||
ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
|
|
||||||
ngx_http_log_op_t *op)
|
|
||||||
{
|
|
||||||
return ngx_sprintf(buf, "%uA", r->connection->number);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static u_char *
|
|
||||||
ngx_http_log_connection_requests(ngx_http_request_t *r, u_char *buf,
|
|
||||||
ngx_http_log_op_t *op)
|
|
||||||
{
|
|
||||||
return ngx_sprintf(buf, "%ui", r->connection->requests);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static u_char *
|
static u_char *
|
||||||
ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,11 @@ static ngx_int_t ngx_http_variable_sent_keep_alive(ngx_http_request_t *r,
|
|||||||
static ngx_int_t ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r,
|
static ngx_int_t ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r,
|
||||||
ngx_http_variable_value_t *v, uintptr_t data);
|
ngx_http_variable_value_t *v, uintptr_t data);
|
||||||
|
|
||||||
|
static ngx_int_t ngx_http_variable_connection(ngx_http_request_t *r,
|
||||||
|
ngx_http_variable_value_t *v, uintptr_t data);
|
||||||
|
static ngx_int_t ngx_http_variable_connection_requests(ngx_http_request_t *r,
|
||||||
|
ngx_http_variable_value_t *v, uintptr_t data);
|
||||||
|
|
||||||
static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r,
|
static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r,
|
||||||
ngx_http_variable_value_t *v, uintptr_t data);
|
ngx_http_variable_value_t *v, uintptr_t data);
|
||||||
static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r,
|
static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r,
|
||||||
@ -265,6 +270,12 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
|
|||||||
offsetof(ngx_http_request_t, limit_rate),
|
offsetof(ngx_http_request_t, limit_rate),
|
||||||
NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
|
NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
|
||||||
|
|
||||||
|
{ ngx_string("connection"), NULL,
|
||||||
|
ngx_http_variable_connection, 0, 0, 0 },
|
||||||
|
|
||||||
|
{ ngx_string("connection_requests"), NULL,
|
||||||
|
ngx_http_variable_connection_requests, 0, 0, 0 },
|
||||||
|
|
||||||
{ ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version,
|
{ ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version,
|
||||||
0, 0, 0 },
|
0, 0, 0 },
|
||||||
|
|
||||||
@ -1813,6 +1824,48 @@ ngx_http_variable_request_body_file(ngx_http_request_t *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_int_t
|
||||||
|
ngx_http_variable_connection(ngx_http_request_t *r,
|
||||||
|
ngx_http_variable_value_t *v, uintptr_t data)
|
||||||
|
{
|
||||||
|
u_char *p;
|
||||||
|
|
||||||
|
p = ngx_pnalloc(r->pool, NGX_ATOMIC_T_LEN);
|
||||||
|
if (p == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
v->len = ngx_sprintf(p, "%uA", r->connection->number) - 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_connection_requests(ngx_http_request_t *r,
|
||||||
|
ngx_http_variable_value_t *v, uintptr_t data)
|
||||||
|
{
|
||||||
|
u_char *p;
|
||||||
|
|
||||||
|
p = ngx_pnalloc(r->pool, NGX_INT_T_LEN);
|
||||||
|
if (p == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
v->len = ngx_sprintf(p, "%ui", r->connection->requests) - p;
|
||||||
|
v->valid = 1;
|
||||||
|
v->no_cacheable = 0;
|
||||||
|
v->not_found = 0;
|
||||||
|
v->data = p;
|
||||||
|
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_variable_nginx_version(ngx_http_request_t *r,
|
ngx_http_variable_nginx_version(ngx_http_request_t *r,
|
||||||
ngx_http_variable_value_t *v, uintptr_t data)
|
ngx_http_variable_value_t *v, uintptr_t data)
|
||||||
|
Loading…
Reference in New Issue
Block a user