Mercurial > hg > nginx-vendor-1-0
diff src/http/modules/ngx_http_log_module.c @ 412:b246022ef454 NGINX_0_7_18
nginx 0.7.18
*) Change: the "underscores_in_headers" directive; now nginx does not
allows underscores in a client request header line names.
*) Feature: the ngx_http_secure_link_module.
*) Feature: the "real_ip_header" directive supports any header.
*) Feature: the "log_subrequest" directive.
*) Feature: the $realpath_root variable.
*) Feature: the "http_502" and "http_504" parameters of the
"proxy_next_upstream" directive.
*) Bugfix: the "http_503" parameter of the "proxy_next_upstream" or
"fastcgi_next_upstream" directives did not work.
*) Bugfix: nginx might send a "Transfer-Encoding: chunked" heaer line
for HEAD requests.
*) Bugfix: now accept threshold depends on worker_connections.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 13 Oct 2008 00:00:00 +0400 |
parents | a8e3f1441eec |
children | b4f69f2ef02c |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_log_module.c +++ b/src/http/modules/ngx_http_log_module.c @@ -28,6 +28,7 @@ struct ngx_http_log_op_s { typedef struct { ngx_str_t name; + ngx_array_t *flushes; ngx_array_t *ops; /* array of ngx_http_log_op_t */ } ngx_http_log_fmt_t; @@ -49,7 +50,7 @@ typedef struct { ngx_http_log_script_t *script; time_t disk_full_time; time_t error_log_time; - ngx_array_t *ops; /* array of ngx_http_log_op_t */ + ngx_http_log_fmt_t *format; } ngx_http_log_t; @@ -113,7 +114,7 @@ static char *ngx_http_log_set_log(ngx_co static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_log_compile_format(ngx_conf_t *cf, - ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s); + ngx_array_t *flushes, ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s); static char *ngx_http_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static ngx_int_t ngx_http_log_init(ngx_conf_t *cf); @@ -242,9 +243,11 @@ ngx_http_log_handler(ngx_http_request_t continue; } + ngx_http_script_flush_no_cacheable_variables(r, log[l].format->flushes); + len = 0; - op = log[l].ops->elts; - for (i = 0; i < log[l].ops->nelts; i++) { + op = log[l].format->ops->elts; + for (i = 0; i < log[l].format->ops->nelts; i++) { if (op[i].len == 0) { len += op[i].getlen(r, op[i].data); @@ -271,7 +274,7 @@ ngx_http_log_handler(ngx_http_request_t p = file->pos; - for (i = 0; i < log[l].ops->nelts; i++) { + for (i = 0; i < log[l].format->ops->nelts; i++) { p = op[i].run(r, p, &op[i]); } @@ -290,7 +293,7 @@ ngx_http_log_handler(ngx_http_request_t p = line; - for (i = 0; i < log[l].ops->nelts; i++) { + for (i = 0; i < log[l].format->ops->nelts; i++) { p = op[i].run(r, p, &op[i]); } @@ -726,6 +729,8 @@ ngx_http_log_create_main_conf(ngx_conf_t fmt->name.len = sizeof("combined") - 1; fmt->name.data = (u_char *) "combined"; + fmt->flushes = NULL; + fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); if (fmt->ops == NULL) { return NGX_CONF_ERROR; @@ -806,7 +811,7 @@ ngx_http_log_merge_loc_conf(ngx_conf_t * fmt = lmcf->formats.elts; /* the default "combined" format */ - log->ops = fmt[0].ops; + log->format = &fmt[0]; lmcf->combined_used = 1; return NGX_CONF_OK; @@ -900,7 +905,7 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx if (fmt[i].name.len == name.len && ngx_strcasecmp(fmt[i].name.data, name.data) == 0) { - log->ops = fmt[i].ops; + log->format = &fmt[i]; goto buffer; } } @@ -985,22 +990,28 @@ ngx_http_log_set_format(ngx_conf_t *cf, fmt->name = value[1]; + fmt->flushes = ngx_array_create(cf->pool, 4, sizeof(ngx_int_t)); + if (fmt->flushes == NULL) { + return NGX_CONF_ERROR; + } + fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); if (fmt->ops == NULL) { return NGX_CONF_ERROR; } - return ngx_http_log_compile_format(cf, fmt->ops, cf->args, 2); + return ngx_http_log_compile_format(cf, fmt->flushes, fmt->ops, cf->args, 2); } static char * -ngx_http_log_compile_format(ngx_conf_t *cf, ngx_array_t *ops, - ngx_array_t *args, ngx_uint_t s) +ngx_http_log_compile_format(ngx_conf_t *cf, ngx_array_t *flushes, + ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s) { u_char *data, *p, ch; size_t i, len; ngx_str_t *value, var; + ngx_int_t *flush; ngx_uint_t bracket; ngx_http_log_op_t *op; ngx_http_log_var_t *v; @@ -1114,6 +1125,16 @@ ngx_http_log_compile_format(ngx_conf_t * return NGX_CONF_ERROR; } + if (flushes) { + + flush = ngx_array_push(flushes); + if (flush == NULL) { + return NGX_CONF_ERROR; + } + + *flush = op->data; /* variable index */ + } + found: continue; @@ -1299,7 +1320,7 @@ ngx_http_log_init(ngx_conf_t *cf) *value = ngx_http_combined_fmt; fmt = lmcf->formats.elts; - if (ngx_http_log_compile_format(cf, fmt->ops, &a, 0) + if (ngx_http_log_compile_format(cf, NULL, fmt->ops, &a, 0) != NGX_CONF_OK) { return NGX_ERROR;