mirror of
https://github.com/nginx/nginx.git
synced 2024-11-27 23:49:00 +08:00
Stream: log module.
This commit is contained in:
parent
443b52db59
commit
68a7b9b5a3
@ -971,6 +971,7 @@ if [ $STREAM != NO ]; then
|
||||
|
||||
ngx_module_name="ngx_stream_module \
|
||||
ngx_stream_core_module \
|
||||
ngx_stream_log_module \
|
||||
ngx_stream_proxy_module \
|
||||
ngx_stream_upstream_module"
|
||||
ngx_module_incs="src/stream"
|
||||
@ -984,6 +985,7 @@ if [ $STREAM != NO ]; then
|
||||
src/stream/ngx_stream_script.c \
|
||||
src/stream/ngx_stream_handler.c \
|
||||
src/stream/ngx_stream_core_module.c \
|
||||
src/stream/ngx_stream_log_module.c \
|
||||
src/stream/ngx_stream_proxy_module.c \
|
||||
src/stream/ngx_stream_upstream.c \
|
||||
src/stream/ngx_stream_upstream_round_robin.c"
|
||||
|
@ -121,6 +121,7 @@ typedef struct {
|
||||
|
||||
ngx_stream_access_pt limit_conn_handler;
|
||||
ngx_stream_access_pt access_handler;
|
||||
ngx_stream_access_pt access_log_handler;
|
||||
|
||||
ngx_hash_t variables_hash;
|
||||
|
||||
|
@ -311,11 +311,19 @@ ngx_stream_ssl_handshake_handler(ngx_connection_t *c)
|
||||
void
|
||||
ngx_stream_finalize_session(ngx_stream_session_t *s, ngx_uint_t rc)
|
||||
{
|
||||
ngx_stream_core_main_conf_t *cmcf;
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0,
|
||||
"finalize stream session: %i", rc);
|
||||
|
||||
s->status = rc;
|
||||
|
||||
cmcf = ngx_stream_get_module_main_conf(s, ngx_stream_core_module);
|
||||
|
||||
if (cmcf->access_log_handler) {
|
||||
(void) cmcf->access_log_handler(s);
|
||||
}
|
||||
|
||||
ngx_stream_close_connection(s->connection);
|
||||
}
|
||||
|
||||
|
1474
src/stream/ngx_stream_log_module.c
Normal file
1474
src/stream/ngx_stream_log_module.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -388,6 +388,73 @@ invalid_variable:
|
||||
}
|
||||
|
||||
|
||||
u_char *
|
||||
ngx_stream_script_run(ngx_stream_session_t *s, ngx_str_t *value,
|
||||
void *code_lengths, size_t len, void *code_values)
|
||||
{
|
||||
ngx_uint_t i;
|
||||
ngx_stream_script_code_pt code;
|
||||
ngx_stream_script_engine_t e;
|
||||
ngx_stream_core_main_conf_t *cmcf;
|
||||
ngx_stream_script_len_code_pt lcode;
|
||||
|
||||
cmcf = ngx_stream_get_module_main_conf(s, ngx_stream_core_module);
|
||||
|
||||
for (i = 0; i < cmcf->variables.nelts; i++) {
|
||||
if (s->variables[i].no_cacheable) {
|
||||
s->variables[i].valid = 0;
|
||||
s->variables[i].not_found = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ngx_memzero(&e, sizeof(ngx_stream_script_engine_t));
|
||||
|
||||
e.ip = code_lengths;
|
||||
e.session = s;
|
||||
e.flushed = 1;
|
||||
|
||||
while (*(uintptr_t *) e.ip) {
|
||||
lcode = *(ngx_stream_script_len_code_pt *) e.ip;
|
||||
len += lcode(&e);
|
||||
}
|
||||
|
||||
|
||||
value->len = len;
|
||||
value->data = ngx_pnalloc(s->connection->pool, len);
|
||||
if (value->data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
e.ip = code_values;
|
||||
e.pos = value->data;
|
||||
|
||||
while (*(uintptr_t *) e.ip) {
|
||||
code = *(ngx_stream_script_code_pt *) e.ip;
|
||||
code((ngx_stream_script_engine_t *) &e);
|
||||
}
|
||||
|
||||
return e.pos;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ngx_stream_script_flush_no_cacheable_variables(ngx_stream_session_t *s,
|
||||
ngx_array_t *indices)
|
||||
{
|
||||
ngx_uint_t n, *index;
|
||||
|
||||
if (indices) {
|
||||
index = indices->elts;
|
||||
for (n = 0; n < indices->nelts; n++) {
|
||||
if (s->variables[index[n]].no_cacheable) {
|
||||
s->variables[index[n]].valid = 0;
|
||||
s->variables[index[n]].not_found = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_stream_script_init_arrays(ngx_stream_script_compile_t *sc)
|
||||
{
|
||||
|
@ -110,6 +110,10 @@ char *ngx_stream_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
|
||||
ngx_uint_t ngx_stream_script_variables_count(ngx_str_t *value);
|
||||
ngx_int_t ngx_stream_script_compile(ngx_stream_script_compile_t *sc);
|
||||
u_char *ngx_stream_script_run(ngx_stream_session_t *s, ngx_str_t *value,
|
||||
void *code_lengths, size_t reserved, void *code_values);
|
||||
void ngx_stream_script_flush_no_cacheable_variables(ngx_stream_session_t *s,
|
||||
ngx_array_t *indices);
|
||||
|
||||
void *ngx_stream_script_add_code(ngx_array_t *codes, size_t size, void *code);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user