Mercurial > hg > nginx-quic
annotate src/stream/ngx_stream_log_module.c @ 7832:ad3a6f069498 quic
Added proper handling of connection close phases.
There are following flags in quic connection:
closing - true, when a connection close is initiated, for whatever reason
draining - true, when a CC frame is received from peer
The following state machine is used for closing:
+------------------+
| I/HS/AD |
+------------------+
| | |
| | V
| | immediate close initiated:
| | reasons: close by top-level protocol, fatal error
| | + sends CC (probably with app-level message)
| | + starts close_timer: 3 * PTO (current probe timeout)
| | |
| | V
| | +---------+ - Reply to input with CC (rate-limited)
| | | CLOSING | - Close/Reset all streams
| | +---------+
| | | |
| V V |
| receives CC |
| | |
idle | |
timer | |
| V |
| +----------+ | - MUST NOT send anything (MAY send a single CC)
| | DRAINING | | - if not already started, starts close_timer: 3 * PTO
| +----------+ | - if not already done, close all streams
| | |
| | |
| close_timer fires
| |
V V
+------------------------+
| CLOSED | - clean up all the resources, drop connection
+------------------------+ state completely
The ngx_quic_close_connection() function gets an "rc" argument, that signals
reason of connection closing:
NGX_OK - initiated by application (i.e. http/3), follow state machine
NGX_DONE - timedout (while idle or draining)
NGX_ERROR - fatal error, destroy connection immediately
The PTO calculations are not yet implemented, hardcoded value of 5s is used.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Thu, 23 Apr 2020 13:41:08 +0300 |
parents | 1ab290cf5267 |
children |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
6 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
6678 | 10 #include <ngx_stream.h> |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
12 #if (NGX_ZLIB) |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
13 #include <zlib.h> |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
14 #endif |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
15 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 |
6678 | 17 typedef struct ngx_stream_log_op_s ngx_stream_log_op_t; |
880 | 18 |
6678 | 19 typedef u_char *(*ngx_stream_log_op_run_pt) (ngx_stream_session_t *s, |
20 u_char *buf, ngx_stream_log_op_t *op); | |
880 | 21 |
6678 | 22 typedef size_t (*ngx_stream_log_op_getlen_pt) (ngx_stream_session_t *s, |
880 | 23 uintptr_t data); |
24 | |
25 | |
6678 | 26 struct ngx_stream_log_op_s { |
27 size_t len; | |
28 ngx_stream_log_op_getlen_pt getlen; | |
29 ngx_stream_log_op_run_pt run; | |
30 uintptr_t data; | |
880 | 31 }; |
32 | |
573 | 33 |
34 typedef struct { | |
6678 | 35 ngx_str_t name; |
36 ngx_array_t *flushes; | |
37 ngx_array_t *ops; /* array of ngx_stream_log_op_t */ | |
38 } ngx_stream_log_fmt_t; | |
573 | 39 |
657 | 40 |
573 | 41 typedef struct { |
6678 | 42 ngx_array_t formats; /* array of ngx_stream_log_fmt_t */ |
43 } ngx_stream_log_main_conf_t; | |
573 | 44 |
657 | 45 |
573 | 46 typedef struct { |
6678 | 47 u_char *start; |
48 u_char *pos; | |
49 u_char *last; | |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
50 |
6678 | 51 ngx_event_t *event; |
52 ngx_msec_t flush; | |
53 ngx_int_t gzip; | |
54 } ngx_stream_log_buf_t; | |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
55 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
56 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
57 typedef struct { |
6678 | 58 ngx_array_t *lengths; |
59 ngx_array_t *values; | |
60 } ngx_stream_log_script_t; | |
2072 | 61 |
62 | |
63 typedef struct { | |
6678 | 64 ngx_open_file_t *file; |
65 ngx_stream_log_script_t *script; | |
66 time_t disk_full_time; | |
67 time_t error_log_time; | |
68 ngx_syslog_peer_t *syslog_peer; | |
69 ngx_stream_log_fmt_t *format; | |
70 ngx_stream_complex_value_t *filter; | |
71 } ngx_stream_log_t; | |
573 | 72 |
657 | 73 |
573 | 74 typedef struct { |
6678 | 75 ngx_array_t *logs; /* array of ngx_stream_log_t */ |
2072 | 76 |
6678 | 77 ngx_open_file_cache_t *open_file_cache; |
78 time_t open_file_cache_valid; | |
79 ngx_uint_t open_file_cache_min_uses; | |
2072 | 80 |
6678 | 81 ngx_uint_t off; /* unsigned off:1 */ |
82 } ngx_stream_log_srv_conf_t; | |
573 | 83 |
84 | |
85 typedef struct { | |
6678 | 86 ngx_str_t name; |
87 size_t len; | |
88 ngx_stream_log_op_run_pt run; | |
89 } ngx_stream_log_var_t; | |
573 | 90 |
91 | |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
92 #define NGX_STREAM_LOG_ESCAPE_DEFAULT 0 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
93 #define NGX_STREAM_LOG_ESCAPE_JSON 1 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
94 #define NGX_STREAM_LOG_ESCAPE_NONE 2 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
95 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
96 |
6678 | 97 static void ngx_stream_log_write(ngx_stream_session_t *s, ngx_stream_log_t *log, |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
98 u_char *buf, size_t len); |
6678 | 99 static ssize_t ngx_stream_log_script_write(ngx_stream_session_t *s, |
100 ngx_stream_log_script_t *script, u_char **name, u_char *buf, size_t len); | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
101 |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
102 #if (NGX_ZLIB) |
6678 | 103 static ssize_t ngx_stream_log_gzip(ngx_fd_t fd, u_char *buf, size_t len, |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
104 ngx_int_t level, ngx_log_t *log); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
105 |
6678 | 106 static void *ngx_stream_log_gzip_alloc(void *opaque, u_int items, u_int size); |
107 static void ngx_stream_log_gzip_free(void *opaque, void *address); | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
108 #endif |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
109 |
6678 | 110 static void ngx_stream_log_flush(ngx_open_file_t *file, ngx_log_t *log); |
111 static void ngx_stream_log_flush_handler(ngx_event_t *ev); | |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
112 |
6678 | 113 static ngx_int_t ngx_stream_log_variable_compile(ngx_conf_t *cf, |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
114 ngx_stream_log_op_t *op, ngx_str_t *value, ngx_uint_t escape); |
6678 | 115 static size_t ngx_stream_log_variable_getlen(ngx_stream_session_t *s, |
501 | 116 uintptr_t data); |
6678 | 117 static u_char *ngx_stream_log_variable(ngx_stream_session_t *s, u_char *buf, |
118 ngx_stream_log_op_t *op); | |
119 static uintptr_t ngx_stream_log_escape(u_char *dst, u_char *src, size_t size); | |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
120 static size_t ngx_stream_log_json_variable_getlen(ngx_stream_session_t *s, |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
121 uintptr_t data); |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
122 static u_char *ngx_stream_log_json_variable(ngx_stream_session_t *s, |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
123 u_char *buf, ngx_stream_log_op_t *op); |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
124 static size_t ngx_stream_log_unescaped_variable_getlen(ngx_stream_session_t *s, |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
125 uintptr_t data); |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
126 static u_char *ngx_stream_log_unescaped_variable(ngx_stream_session_t *s, |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
127 u_char *buf, ngx_stream_log_op_t *op); |
501 | 128 |
129 | |
6678 | 130 static void *ngx_stream_log_create_main_conf(ngx_conf_t *cf); |
131 static void *ngx_stream_log_create_srv_conf(ngx_conf_t *cf); | |
132 static char *ngx_stream_log_merge_srv_conf(ngx_conf_t *cf, void *parent, | |
497 | 133 void *child); |
6678 | 134 static char *ngx_stream_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, |
497 | 135 void *conf); |
6678 | 136 static char *ngx_stream_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, |
497 | 137 void *conf); |
6678 | 138 static char *ngx_stream_log_compile_format(ngx_conf_t *cf, |
2261 | 139 ngx_array_t *flushes, ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s); |
6678 | 140 static char *ngx_stream_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, |
2072 | 141 void *conf); |
6678 | 142 static ngx_int_t ngx_stream_log_init(ngx_conf_t *cf); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
143 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
144 |
6678 | 145 static ngx_command_t ngx_stream_log_commands[] = { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
146 |
497 | 147 { ngx_string("log_format"), |
6678 | 148 NGX_STREAM_MAIN_CONF|NGX_CONF_2MORE, |
149 ngx_stream_log_set_format, | |
150 NGX_STREAM_MAIN_CONF_OFFSET, | |
497 | 151 0, |
152 NULL }, | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
153 |
497 | 154 { ngx_string("access_log"), |
6678 | 155 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_1MORE, |
156 ngx_stream_log_set_log, | |
157 NGX_STREAM_SRV_CONF_OFFSET, | |
497 | 158 0, |
159 NULL }, | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
160 |
2072 | 161 { ngx_string("open_log_file_cache"), |
6678 | 162 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1234, |
163 ngx_stream_log_open_file_cache, | |
164 NGX_STREAM_SRV_CONF_OFFSET, | |
2072 | 165 0, |
166 NULL }, | |
167 | |
497 | 168 ngx_null_command |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
169 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
170 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
171 |
6678 | 172 static ngx_stream_module_t ngx_stream_log_module_ctx = { |
880 | 173 NULL, /* preconfiguration */ |
6678 | 174 ngx_stream_log_init, /* postconfiguration */ |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
175 |
6678 | 176 ngx_stream_log_create_main_conf, /* create main configuration */ |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
177 NULL, /* init main configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
178 |
6678 | 179 ngx_stream_log_create_srv_conf, /* create server configuration */ |
180 ngx_stream_log_merge_srv_conf /* merge server configuration */ | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
181 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
182 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
183 |
6678 | 184 ngx_module_t ngx_stream_log_module = { |
509 | 185 NGX_MODULE_V1, |
6678 | 186 &ngx_stream_log_module_ctx, /* module context */ |
187 ngx_stream_log_commands, /* module directives */ | |
188 NGX_STREAM_MODULE, /* module type */ | |
541 | 189 NULL, /* init master */ |
573 | 190 NULL, /* init module */ |
541 | 191 NULL, /* init process */ |
192 NULL, /* init thread */ | |
193 NULL, /* exit thread */ | |
194 NULL, /* exit process */ | |
195 NULL, /* exit master */ | |
196 NGX_MODULE_V1_PADDING | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
197 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
198 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 |
6678 | 200 static ngx_int_t |
201 ngx_stream_log_handler(ngx_stream_session_t *s) | |
202 { | |
203 u_char *line, *p; | |
204 size_t len, size; | |
205 ssize_t n; | |
206 ngx_str_t val; | |
207 ngx_uint_t i, l; | |
208 ngx_stream_log_t *log; | |
209 ngx_stream_log_op_t *op; | |
210 ngx_stream_log_buf_t *buffer; | |
211 ngx_stream_log_srv_conf_t *lscf; | |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
212 |
6678 | 213 ngx_log_debug0(NGX_LOG_DEBUG_STREAM, s->connection->log, 0, |
214 "stream log handler"); | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
215 |
6678 | 216 lscf = ngx_stream_get_module_srv_conf(s, ngx_stream_log_module); |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 |
6678 | 218 if (lscf->off || lscf->logs == NULL) { |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
219 return NGX_OK; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
220 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
221 |
6678 | 222 log = lscf->logs->elts; |
223 for (l = 0; l < lscf->logs->nelts; l++) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
224 |
5653
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
225 if (log[l].filter) { |
6678 | 226 if (ngx_stream_complex_value(s, log[l].filter, &val) != NGX_OK) { |
5653
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
227 return NGX_ERROR; |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
228 } |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
229 |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
230 if (val.len == 0 || (val.len == 1 && val.data[0] == '0')) { |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
231 continue; |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
232 } |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
233 } |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
234 |
633 | 235 if (ngx_time() == log[l].disk_full_time) { |
236 | |
237 /* | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
238 * on FreeBSD writing to a full filesystem with enabled softupdates |
633 | 239 * may block process for much longer time than writing to non-full |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
240 * filesystem, so we skip writing to a log for one second |
633 | 241 */ |
242 | |
243 continue; | |
244 } | |
245 | |
6678 | 246 ngx_stream_script_flush_no_cacheable_variables(s, |
247 log[l].format->flushes); | |
2261 | 248 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
249 len = 0; |
2261 | 250 op = log[l].format->ops->elts; |
251 for (i = 0; i < log[l].format->ops->nelts; i++) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
252 if (op[i].len == 0) { |
6678 | 253 len += op[i].getlen(s, op[i].data); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
254 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
255 } else { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
256 len += op[i].len; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
257 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
258 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
259 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
260 if (log[l].syslog_peer) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
261 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
262 /* length of syslog's PRI and HEADER message parts */ |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
263 len += sizeof("<255>Jan 01 00:00:00 ") - 1 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
264 + ngx_cycle->hostname.len + 1 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
265 + log[l].syslog_peer->tag.len + 2; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
266 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
267 goto alloc_line; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
268 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
269 |
571 | 270 len += NGX_LINEFEED_SIZE; |
271 | |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
272 buffer = log[l].file ? log[l].file->data : NULL; |
571 | 273 |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
274 if (buffer) { |
571 | 275 |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
276 if (len > (size_t) (buffer->last - buffer->pos)) { |
571 | 277 |
6678 | 278 ngx_stream_log_write(s, &log[l], buffer->start, |
279 buffer->pos - buffer->start); | |
571 | 280 |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
281 buffer->pos = buffer->start; |
571 | 282 } |
283 | |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
284 if (len <= (size_t) (buffer->last - buffer->pos)) { |
571 | 285 |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
286 p = buffer->pos; |
571 | 287 |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
288 if (buffer->event && p == buffer->start) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
289 ngx_add_timer(buffer->event, buffer->flush); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
290 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
291 |
2261 | 292 for (i = 0; i < log[l].format->ops->nelts; i++) { |
6678 | 293 p = op[i].run(s, p, &op[i]); |
571 | 294 } |
295 | |
296 ngx_linefeed(p); | |
297 | |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
298 buffer->pos = p; |
571 | 299 |
300 continue; | |
301 } | |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
302 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
303 if (buffer->event && buffer->event->timer_set) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
304 ngx_del_timer(buffer->event); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
305 } |
571 | 306 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
307 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
308 alloc_line: |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
309 |
6678 | 310 line = ngx_pnalloc(s->connection->pool, len); |
501 | 311 if (line == NULL) { |
473 | 312 return NGX_ERROR; |
313 } | |
314 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
315 p = line; |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
316 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
317 if (log[l].syslog_peer) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
318 p = ngx_syslog_add_header(log[l].syslog_peer, line); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
319 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
320 |
2261 | 321 for (i = 0; i < log[l].format->ops->nelts; i++) { |
6678 | 322 p = op[i].run(s, p, &op[i]); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
323 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
324 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
325 if (log[l].syslog_peer) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
326 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
327 size = p - line; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
328 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
329 n = ngx_syslog_send(log[l].syslog_peer, line, size); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
330 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
331 if (n < 0) { |
6678 | 332 ngx_log_error(NGX_LOG_WARN, s->connection->log, 0, |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
333 "send() to syslog failed"); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
334 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
335 } else if ((size_t) n != size) { |
6678 | 336 ngx_log_error(NGX_LOG_WARN, s->connection->log, 0, |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
337 "send() to syslog has written only %z of %uz", |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
338 n, size); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
339 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
340 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
341 continue; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
342 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
343 |
571 | 344 ngx_linefeed(p); |
345 | |
6678 | 346 ngx_stream_log_write(s, &log[l], line, p - line); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
347 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
348 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
349 return NGX_OK; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
350 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
351 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
352 |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
353 static void |
6678 | 354 ngx_stream_log_write(ngx_stream_session_t *s, ngx_stream_log_t *log, |
355 u_char *buf, size_t len) | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
356 { |
6678 | 357 u_char *name; |
358 time_t now; | |
359 ssize_t n; | |
360 ngx_err_t err; | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
361 #if (NGX_ZLIB) |
6678 | 362 ngx_stream_log_buf_t *buffer; |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
363 #endif |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
364 |
2072 | 365 if (log->script == NULL) { |
366 name = log->file->name.data; | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
367 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
368 #if (NGX_ZLIB) |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
369 buffer = log->file->data; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
370 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
371 if (buffer && buffer->gzip) { |
6678 | 372 n = ngx_stream_log_gzip(log->file->fd, buf, len, buffer->gzip, |
373 s->connection->log); | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
374 } else { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
375 n = ngx_write_fd(log->file->fd, buf, len); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
376 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
377 #else |
2072 | 378 n = ngx_write_fd(log->file->fd, buf, len); |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
379 #endif |
2072 | 380 |
381 } else { | |
382 name = NULL; | |
6678 | 383 n = ngx_stream_log_script_write(s, log->script, &name, buf, len); |
2072 | 384 } |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
385 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
386 if (n == (ssize_t) len) { |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
387 return; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
388 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
389 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
390 now = ngx_time(); |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
391 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
392 if (n == -1) { |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
393 err = ngx_errno; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
394 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
395 if (err == NGX_ENOSPC) { |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
396 log->disk_full_time = now; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
397 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
398 |
1161
6002e0253221
use 60 seconds interval but not 61 seconds
Igor Sysoev <igor@sysoev.ru>
parents:
1074
diff
changeset
|
399 if (now - log->error_log_time > 59) { |
6678 | 400 ngx_log_error(NGX_LOG_ALERT, s->connection->log, err, |
2072 | 401 ngx_write_fd_n " to \"%s\" failed", name); |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
402 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
403 log->error_log_time = now; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
404 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
405 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
406 return; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
407 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
408 |
1161
6002e0253221
use 60 seconds interval but not 61 seconds
Igor Sysoev <igor@sysoev.ru>
parents:
1074
diff
changeset
|
409 if (now - log->error_log_time > 59) { |
6678 | 410 ngx_log_error(NGX_LOG_ALERT, s->connection->log, 0, |
2072 | 411 ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz", |
412 name, n, len); | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
413 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
414 log->error_log_time = now; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
415 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
416 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
417 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
418 |
2072 | 419 static ssize_t |
6678 | 420 ngx_stream_log_script_write(ngx_stream_session_t *s, |
421 ngx_stream_log_script_t *script, u_char **name, u_char *buf, size_t len) | |
2072 | 422 { |
6678 | 423 ssize_t n; |
424 ngx_str_t log; | |
425 ngx_open_file_info_t of; | |
426 ngx_stream_log_srv_conf_t *lscf; | |
4494
13e09cf11d4e
Disable symlinks: initialization of the "disable_symlinks" field in
Valentin Bartenev <vbart@nginx.com>
parents:
4478
diff
changeset
|
427 |
6678 | 428 if (ngx_stream_script_run(s, &log, script->lengths->elts, 1, |
429 script->values->elts) | |
2072 | 430 == NULL) |
431 { | |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4494
diff
changeset
|
432 /* simulate successful logging */ |
2072 | 433 return len; |
434 } | |
435 | |
436 log.data[log.len - 1] = '\0'; | |
437 *name = log.data; | |
438 | |
6678 | 439 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0, |
440 "stream log \"%s\"", log.data); | |
2072 | 441 |
6678 | 442 lscf = ngx_stream_get_module_srv_conf(s, ngx_stream_log_module); |
2072 | 443 |
444 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); | |
445 | |
446 of.log = 1; | |
6678 | 447 of.valid = lscf->open_file_cache_valid; |
448 of.min_uses = lscf->open_file_cache_min_uses; | |
2277 | 449 of.directio = NGX_OPEN_FILE_DIRECTIO_OFF; |
4494
13e09cf11d4e
Disable symlinks: initialization of the "disable_symlinks" field in
Valentin Bartenev <vbart@nginx.com>
parents:
4478
diff
changeset
|
450 |
6678 | 451 if (ngx_open_cached_file(lscf->open_file_cache, &log, &of, |
452 s->connection->pool) | |
2072 | 453 != NGX_OK) |
454 { | |
6948
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6927
diff
changeset
|
455 if (of.err == 0) { |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6927
diff
changeset
|
456 /* simulate successful logging */ |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6927
diff
changeset
|
457 return len; |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6927
diff
changeset
|
458 } |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6927
diff
changeset
|
459 |
6678 | 460 ngx_log_error(NGX_LOG_CRIT, s->connection->log, ngx_errno, |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
461 "%s \"%s\" failed", of.failed, log.data); |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4494
diff
changeset
|
462 /* simulate successful logging */ |
2077 | 463 return len; |
2072 | 464 } |
465 | |
6678 | 466 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0, |
467 "stream log #%d", of.fd); | |
2072 | 468 |
469 n = ngx_write_fd(of.fd, buf, len); | |
470 | |
471 return n; | |
472 } | |
473 | |
474 | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
475 #if (NGX_ZLIB) |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
476 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
477 static ssize_t |
6678 | 478 ngx_stream_log_gzip(ngx_fd_t fd, u_char *buf, size_t len, ngx_int_t level, |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
479 ngx_log_t *log) |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
480 { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
481 int rc, wbits, memlevel; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
482 u_char *out; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
483 size_t size; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
484 ssize_t n; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
485 z_stream zstream; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
486 ngx_err_t err; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
487 ngx_pool_t *pool; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
488 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
489 wbits = MAX_WBITS; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
490 memlevel = MAX_MEM_LEVEL - 1; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
491 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
492 while ((ssize_t) len < ((1 << (wbits - 1)) - 262)) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
493 wbits--; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
494 memlevel--; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
495 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
496 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
497 /* |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
498 * This is a formula from deflateBound() for conservative upper bound of |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
499 * compressed data plus 18 bytes of gzip wrapper. |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
500 */ |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
501 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
502 size = len + ((len + 7) >> 3) + ((len + 63) >> 6) + 5 + 18; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
503 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
504 ngx_memzero(&zstream, sizeof(z_stream)); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
505 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
506 pool = ngx_create_pool(256, log); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
507 if (pool == NULL) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
508 /* simulate successful logging */ |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
509 return len; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
510 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
511 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
512 pool->log = log; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
513 |
6678 | 514 zstream.zalloc = ngx_stream_log_gzip_alloc; |
515 zstream.zfree = ngx_stream_log_gzip_free; | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
516 zstream.opaque = pool; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
517 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
518 out = ngx_pnalloc(pool, size); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
519 if (out == NULL) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
520 goto done; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
521 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
522 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
523 zstream.next_in = buf; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
524 zstream.avail_in = len; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
525 zstream.next_out = out; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
526 zstream.avail_out = size; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
527 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
528 rc = deflateInit2(&zstream, (int) level, Z_DEFLATED, wbits + 16, memlevel, |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
529 Z_DEFAULT_STRATEGY); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
530 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
531 if (rc != Z_OK) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
532 ngx_log_error(NGX_LOG_ALERT, log, 0, "deflateInit2() failed: %d", rc); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
533 goto done; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
534 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
535 |
6678 | 536 ngx_log_debug4(NGX_LOG_DEBUG_STREAM, log, 0, |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
537 "deflate in: ni:%p no:%p ai:%ud ao:%ud", |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
538 zstream.next_in, zstream.next_out, |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
539 zstream.avail_in, zstream.avail_out); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
540 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
541 rc = deflate(&zstream, Z_FINISH); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
542 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
543 if (rc != Z_STREAM_END) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
544 ngx_log_error(NGX_LOG_ALERT, log, 0, |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
545 "deflate(Z_FINISH) failed: %d", rc); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
546 goto done; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
547 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
548 |
6678 | 549 ngx_log_debug5(NGX_LOG_DEBUG_STREAM, log, 0, |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
550 "deflate out: ni:%p no:%p ai:%ud ao:%ud rc:%d", |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
551 zstream.next_in, zstream.next_out, |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
552 zstream.avail_in, zstream.avail_out, |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
553 rc); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
554 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
555 size -= zstream.avail_out; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
556 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
557 rc = deflateEnd(&zstream); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
558 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
559 if (rc != Z_OK) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
560 ngx_log_error(NGX_LOG_ALERT, log, 0, "deflateEnd() failed: %d", rc); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
561 goto done; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
562 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
563 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
564 n = ngx_write_fd(fd, out, size); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
565 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
566 if (n != (ssize_t) size) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
567 err = (n == -1) ? ngx_errno : 0; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
568 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
569 ngx_destroy_pool(pool); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
570 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
571 ngx_set_errno(err); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
572 return -1; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
573 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
574 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
575 done: |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
576 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
577 ngx_destroy_pool(pool); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
578 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
579 /* simulate successful logging */ |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
580 return len; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
581 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
582 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
583 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
584 static void * |
6678 | 585 ngx_stream_log_gzip_alloc(void *opaque, u_int items, u_int size) |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
586 { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
587 ngx_pool_t *pool = opaque; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
588 |
6678 | 589 ngx_log_debug2(NGX_LOG_DEBUG_STREAM, pool->log, 0, |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
590 "gzip alloc: n:%ud s:%ud", items, size); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
591 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
592 return ngx_palloc(pool, items * size); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
593 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
594 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
595 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
596 static void |
6678 | 597 ngx_stream_log_gzip_free(void *opaque, void *address) |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
598 { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
599 #if 0 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
600 ngx_pool_t *pool = opaque; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
601 |
6678 | 602 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, pool->log, 0, |
603 "gzip free: %p", address); | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
604 #endif |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
605 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
606 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
607 #endif |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
608 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
609 |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
610 static void |
6678 | 611 ngx_stream_log_flush(ngx_open_file_t *file, ngx_log_t *log) |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
612 { |
6678 | 613 size_t len; |
614 ssize_t n; | |
615 ngx_stream_log_buf_t *buffer; | |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
616 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
617 buffer = file->data; |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
618 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
619 len = buffer->pos - buffer->start; |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
620 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
621 if (len == 0) { |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
622 return; |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
623 } |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
624 |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
625 #if (NGX_ZLIB) |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
626 if (buffer->gzip) { |
6678 | 627 n = ngx_stream_log_gzip(file->fd, buffer->start, len, buffer->gzip, |
628 log); | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
629 } else { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
630 n = ngx_write_fd(file->fd, buffer->start, len); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
631 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
632 #else |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
633 n = ngx_write_fd(file->fd, buffer->start, len); |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
634 #endif |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
635 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
636 if (n == -1) { |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
637 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
638 ngx_write_fd_n " to \"%s\" failed", |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
639 file->name.data); |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
640 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
641 } else if ((size_t) n != len) { |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
642 ngx_log_error(NGX_LOG_ALERT, log, 0, |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
643 ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz", |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
644 file->name.data, n, len); |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
645 } |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
646 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
647 buffer->pos = buffer->start; |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
648 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
649 if (buffer->event && buffer->event->timer_set) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
650 ngx_del_timer(buffer->event); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
651 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
652 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
653 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
654 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
655 static void |
6678 | 656 ngx_stream_log_flush_handler(ngx_event_t *ev) |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
657 { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
658 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
6678 | 659 "stream log buffer flush handler"); |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
660 |
6927
c36d160cd4e0
Access log: removed dead ev->timedout check in flush timer handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6840
diff
changeset
|
661 ngx_stream_log_flush(ev->data, ev->log); |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
662 } |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
663 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
664 |
497 | 665 static u_char * |
6678 | 666 ngx_stream_log_copy_short(ngx_stream_session_t *s, u_char *buf, |
667 ngx_stream_log_op_t *op) | |
479 | 668 { |
669 size_t len; | |
670 uintptr_t data; | |
671 | |
672 len = op->len; | |
673 data = op->data; | |
674 | |
675 while (len--) { | |
676 *buf++ = (u_char) (data & 0xff); | |
677 data >>= 8; | |
678 } | |
679 | |
680 return buf; | |
681 } | |
682 | |
683 | |
497 | 684 static u_char * |
6678 | 685 ngx_stream_log_copy_long(ngx_stream_session_t *s, u_char *buf, |
686 ngx_stream_log_op_t *op) | |
479 | 687 { |
688 return ngx_cpymem(buf, (u_char *) op->data, op->len); | |
689 } | |
690 | |
691 | |
497 | 692 static ngx_int_t |
6678 | 693 ngx_stream_log_variable_compile(ngx_conf_t *cf, ngx_stream_log_op_t *op, |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
694 ngx_str_t *value, ngx_uint_t escape) |
501 | 695 { |
509 | 696 ngx_int_t index; |
501 | 697 |
6678 | 698 index = ngx_stream_get_variable_index(cf, value); |
509 | 699 if (index == NGX_ERROR) { |
501 | 700 return NGX_ERROR; |
701 } | |
702 | |
703 op->len = 0; | |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
704 |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
705 switch (escape) { |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
706 case NGX_STREAM_LOG_ESCAPE_JSON: |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
707 op->getlen = ngx_stream_log_json_variable_getlen; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
708 op->run = ngx_stream_log_json_variable; |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
709 break; |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
710 |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
711 case NGX_STREAM_LOG_ESCAPE_NONE: |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
712 op->getlen = ngx_stream_log_unescaped_variable_getlen; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
713 op->run = ngx_stream_log_unescaped_variable; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
714 break; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
715 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
716 default: /* NGX_STREAM_LOG_ESCAPE_DEFAULT */ |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
717 op->getlen = ngx_stream_log_variable_getlen; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
718 op->run = ngx_stream_log_variable; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
719 } |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
720 |
509 | 721 op->data = index; |
501 | 722 |
723 return NGX_OK; | |
724 } | |
725 | |
726 | |
727 static size_t | |
6678 | 728 ngx_stream_log_variable_getlen(ngx_stream_session_t *s, uintptr_t data) |
501 | 729 { |
6678 | 730 uintptr_t len; |
731 ngx_stream_variable_value_t *value; | |
501 | 732 |
6678 | 733 value = ngx_stream_get_indexed_variable(s, data); |
501 | 734 |
573 | 735 if (value == NULL || value->not_found) { |
501 | 736 return 1; |
737 } | |
738 | |
6678 | 739 len = ngx_stream_log_escape(NULL, value->data, value->len); |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
740 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
741 value->escape = len ? 1 : 0; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
742 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
743 return value->len + len * 3; |
501 | 744 } |
745 | |
746 | |
747 static u_char * | |
6678 | 748 ngx_stream_log_variable(ngx_stream_session_t *s, u_char *buf, |
749 ngx_stream_log_op_t *op) | |
501 | 750 { |
6678 | 751 ngx_stream_variable_value_t *value; |
501 | 752 |
6678 | 753 value = ngx_stream_get_indexed_variable(s, op->data); |
501 | 754 |
573 | 755 if (value == NULL || value->not_found) { |
501 | 756 *buf = '-'; |
757 return buf + 1; | |
758 } | |
759 | |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
760 if (value->escape == 0) { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
761 return ngx_cpymem(buf, value->data, value->len); |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
762 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
763 } else { |
6678 | 764 return (u_char *) ngx_stream_log_escape(buf, value->data, value->len); |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
765 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
766 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
767 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
768 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
769 static uintptr_t |
6678 | 770 ngx_stream_log_escape(u_char *dst, u_char *src, size_t size) |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
771 { |
3275 | 772 ngx_uint_t n; |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
773 static u_char hex[] = "0123456789ABCDEF"; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
774 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
775 static uint32_t escape[] = { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
776 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
777 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
778 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
779 0x00000004, /* 0000 0000 0000 0000 0000 0000 0000 0100 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
780 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
781 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
782 0x10000000, /* 0001 0000 0000 0000 0000 0000 0000 0000 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
783 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
784 /* ~}| {zyx wvut srqp onml kjih gfed cba` */ |
4191
08d8af70760c
Improved access log escaping to better protect other software.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
785 0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */ |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
786 |
4191
08d8af70760c
Improved access log escaping to better protect other software.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
787 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
08d8af70760c
Improved access log escaping to better protect other software.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
788 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
08d8af70760c
Improved access log escaping to better protect other software.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
789 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
08d8af70760c
Improved access log escaping to better protect other software.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
790 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
791 }; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
792 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
793 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
794 if (dst == NULL) { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
795 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
796 /* find the number of the characters to be escaped */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
797 |
3115 | 798 n = 0; |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
799 |
3275 | 800 while (size) { |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5927
diff
changeset
|
801 if (escape[*src >> 5] & (1U << (*src & 0x1f))) { |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
802 n++; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
803 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
804 src++; |
3275 | 805 size--; |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
806 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
807 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
808 return (uintptr_t) n; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
809 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
810 |
3275 | 811 while (size) { |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5927
diff
changeset
|
812 if (escape[*src >> 5] & (1U << (*src & 0x1f))) { |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
813 *dst++ = '\\'; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
814 *dst++ = 'x'; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
815 *dst++ = hex[*src >> 4]; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
816 *dst++ = hex[*src & 0xf]; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
817 src++; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
818 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
819 } else { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
820 *dst++ = *src++; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
821 } |
3275 | 822 size--; |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
823 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
824 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
825 return (uintptr_t) dst; |
501 | 826 } |
827 | |
828 | |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
829 static size_t |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
830 ngx_stream_log_json_variable_getlen(ngx_stream_session_t *s, uintptr_t data) |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
831 { |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
832 uintptr_t len; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
833 ngx_stream_variable_value_t *value; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
834 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
835 value = ngx_stream_get_indexed_variable(s, data); |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
836 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
837 if (value == NULL || value->not_found) { |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
838 return 0; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
839 } |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
840 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
841 len = ngx_escape_json(NULL, value->data, value->len); |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
842 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
843 value->escape = len ? 1 : 0; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
844 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
845 return value->len + len; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
846 } |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
847 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
848 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
849 static u_char * |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
850 ngx_stream_log_json_variable(ngx_stream_session_t *s, u_char *buf, |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
851 ngx_stream_log_op_t *op) |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
852 { |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
853 ngx_stream_variable_value_t *value; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
854 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
855 value = ngx_stream_get_indexed_variable(s, op->data); |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
856 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
857 if (value == NULL || value->not_found) { |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
858 return buf; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
859 } |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
860 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
861 if (value->escape == 0) { |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
862 return ngx_cpymem(buf, value->data, value->len); |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
863 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
864 } else { |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
865 return (u_char *) ngx_escape_json(buf, value->data, value->len); |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
866 } |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
867 } |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
868 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
869 |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
870 static size_t |
7224 | 871 ngx_stream_log_unescaped_variable_getlen(ngx_stream_session_t *s, |
872 uintptr_t data) | |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
873 { |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
874 ngx_stream_variable_value_t *value; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
875 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
876 value = ngx_stream_get_indexed_variable(s, data); |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
877 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
878 if (value == NULL || value->not_found) { |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
879 return 0; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
880 } |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
881 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
882 value->escape = 0; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
883 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
884 return value->len; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
885 } |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
886 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
887 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
888 static u_char * |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
889 ngx_stream_log_unescaped_variable(ngx_stream_session_t *s, u_char *buf, |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
890 ngx_stream_log_op_t *op) |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
891 { |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
892 ngx_stream_variable_value_t *value; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
893 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
894 value = ngx_stream_get_indexed_variable(s, op->data); |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
895 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
896 if (value == NULL || value->not_found) { |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
897 return buf; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
898 } |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
899 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
900 return ngx_cpymem(buf, value->data, value->len); |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
901 } |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
902 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
903 |
497 | 904 static void * |
6678 | 905 ngx_stream_log_create_main_conf(ngx_conf_t *cf) |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
906 { |
6678 | 907 ngx_stream_log_main_conf_t *conf; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
908 |
6678 | 909 conf = ngx_pcalloc(cf->pool, sizeof(ngx_stream_log_main_conf_t)); |
501 | 910 if (conf == NULL) { |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2756
diff
changeset
|
911 return NULL; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
912 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
913 |
6678 | 914 if (ngx_array_init(&conf->formats, cf->pool, 4, |
915 sizeof(ngx_stream_log_fmt_t)) | |
573 | 916 != NGX_OK) |
497 | 917 { |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2756
diff
changeset
|
918 return NULL; |
497 | 919 } |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
920 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
921 return conf; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
922 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
923 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
924 |
497 | 925 static void * |
6678 | 926 ngx_stream_log_create_srv_conf(ngx_conf_t *cf) |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
927 { |
6678 | 928 ngx_stream_log_srv_conf_t *conf; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
929 |
6678 | 930 conf = ngx_pcalloc(cf->pool, sizeof(ngx_stream_log_srv_conf_t)); |
501 | 931 if (conf == NULL) { |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2756
diff
changeset
|
932 return NULL; |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
933 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
934 |
2072 | 935 conf->open_file_cache = NGX_CONF_UNSET_PTR; |
936 | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
937 return conf; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
938 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
939 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
940 |
497 | 941 static char * |
6678 | 942 ngx_stream_log_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
943 { |
6678 | 944 ngx_stream_log_srv_conf_t *prev = parent; |
945 ngx_stream_log_srv_conf_t *conf = child; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
946 |
2072 | 947 if (conf->open_file_cache == NGX_CONF_UNSET_PTR) { |
948 | |
949 conf->open_file_cache = prev->open_file_cache; | |
950 conf->open_file_cache_valid = prev->open_file_cache_valid; | |
951 conf->open_file_cache_min_uses = prev->open_file_cache_min_uses; | |
952 | |
953 if (conf->open_file_cache == NGX_CONF_UNSET_PTR) { | |
954 conf->open_file_cache = NULL; | |
955 } | |
956 } | |
957 | |
1074 | 958 if (conf->logs || conf->off) { |
959 return NGX_CONF_OK; | |
960 } | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
961 |
2078
9acbc5e7bcbd
fix variable access_log merging
Igor Sysoev <igor@sysoev.ru>
parents:
2077
diff
changeset
|
962 conf->logs = prev->logs; |
9acbc5e7bcbd
fix variable access_log merging
Igor Sysoev <igor@sysoev.ru>
parents:
2077
diff
changeset
|
963 conf->off = prev->off; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
964 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
965 return NGX_CONF_OK; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
966 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
967 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
968 |
497 | 969 static char * |
6678 | 970 ngx_stream_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
971 { |
6678 | 972 ngx_stream_log_srv_conf_t *lscf = conf; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
973 |
6678 | 974 ssize_t size; |
975 ngx_int_t gzip; | |
976 ngx_uint_t i, n; | |
977 ngx_msec_t flush; | |
978 ngx_str_t *value, name, s; | |
979 ngx_stream_log_t *log; | |
980 ngx_syslog_peer_t *peer; | |
981 ngx_stream_log_buf_t *buffer; | |
982 ngx_stream_log_fmt_t *fmt; | |
983 ngx_stream_script_compile_t sc; | |
984 ngx_stream_log_main_conf_t *lmcf; | |
985 ngx_stream_compile_complex_value_t ccv; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
986 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
987 value = cf->args->elts; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
988 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
989 if (ngx_strcmp(value[1].data, "off") == 0) { |
6678 | 990 lscf->off = 1; |
3038
cd8738e76610
strict testing "access_log off"
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
991 if (cf->args->nelts == 2) { |
cd8738e76610
strict testing "access_log off"
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
992 return NGX_CONF_OK; |
cd8738e76610
strict testing "access_log off"
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
993 } |
cd8738e76610
strict testing "access_log off"
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
994 |
cd8738e76610
strict testing "access_log off"
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
995 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
cd8738e76610
strict testing "access_log off"
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
996 "invalid parameter \"%V\"", &value[2]); |
cd8738e76610
strict testing "access_log off"
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
997 return NGX_CONF_ERROR; |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
998 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
999 |
6678 | 1000 if (lscf->logs == NULL) { |
1001 lscf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_stream_log_t)); | |
1002 if (lscf->logs == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1003 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1004 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1005 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
1006 |
6678 | 1007 lmcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_log_module); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
1008 |
6678 | 1009 log = ngx_array_push(lscf->logs); |
501 | 1010 if (log == NULL) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1011 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1012 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1013 |
6678 | 1014 ngx_memzero(log, sizeof(ngx_stream_log_t)); |
2072 | 1015 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1016 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1017 if (ngx_strncmp(value[1].data, "syslog:", 7) == 0) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1018 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1019 peer = ngx_pcalloc(cf->pool, sizeof(ngx_syslog_peer_t)); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1020 if (peer == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1021 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1022 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1023 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1024 if (ngx_syslog_process_conf(cf, peer) != NGX_CONF_OK) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1025 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1026 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1027 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1028 log->syslog_peer = peer; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1029 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1030 goto process_formats; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1031 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1032 |
6678 | 1033 n = ngx_stream_script_variables_count(&value[1]); |
2072 | 1034 |
1035 if (n == 0) { | |
1036 log->file = ngx_conf_open_file(cf->cycle, &value[1]); | |
1037 if (log->file == NULL) { | |
1038 return NGX_CONF_ERROR; | |
1039 } | |
1040 | |
1041 } else { | |
5330
314c3d7cc3a5
Backed out f1a91825730a and 7094bd12c1ff.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5317
diff
changeset
|
1042 if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) { |
2072 | 1043 return NGX_CONF_ERROR; |
1044 } | |
1045 | |
6678 | 1046 log->script = ngx_pcalloc(cf->pool, sizeof(ngx_stream_log_script_t)); |
2072 | 1047 if (log->script == NULL) { |
1048 return NGX_CONF_ERROR; | |
1049 } | |
1050 | |
6678 | 1051 ngx_memzero(&sc, sizeof(ngx_stream_script_compile_t)); |
2072 | 1052 |
1053 sc.cf = cf; | |
1054 sc.source = &value[1]; | |
1055 sc.lengths = &log->script->lengths; | |
1056 sc.values = &log->script->values; | |
1057 sc.variables = n; | |
1058 sc.complete_lengths = 1; | |
1059 sc.complete_values = 1; | |
1060 | |
6678 | 1061 if (ngx_stream_script_compile(&sc) != NGX_OK) { |
2072 | 1062 return NGX_CONF_ERROR; |
1063 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1064 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1065 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1066 process_formats: |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5653
diff
changeset
|
1067 |
571 | 1068 if (cf->args->nelts >= 3) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1069 name = value[2]; |
581 | 1070 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1071 } else { |
6678 | 1072 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1073 "log format is not specified"); | |
1074 return NGX_CONF_ERROR; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1075 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1076 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1077 fmt = lmcf->formats.elts; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1078 for (i = 0; i < lmcf->formats.nelts; i++) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1079 if (fmt[i].name.len == name.len |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1080 && ngx_strcasecmp(fmt[i].name.data, name.data) == 0) |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1081 { |
2261 | 1082 log->format = &fmt[i]; |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1083 break; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1084 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1085 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
1086 |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1087 if (log->format == NULL) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1088 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1089 "unknown log format \"%V\"", &name); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1090 return NGX_CONF_ERROR; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1091 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1092 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1093 size = 0; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1094 flush = 0; |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1095 gzip = 0; |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1096 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1097 for (i = 3; i < cf->args->nelts; i++) { |
487 | 1098 |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1099 if (ngx_strncmp(value[i].data, "buffer=", 7) == 0) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1100 s.len = value[i].len - 7; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1101 s.data = value[i].data + 7; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1102 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1103 size = ngx_parse_size(&s); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1104 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1105 if (size == NGX_ERROR || size == 0) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1106 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1107 "invalid buffer size \"%V\"", &s); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1108 return NGX_CONF_ERROR; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1109 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1110 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1111 continue; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1112 } |
571 | 1113 |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1114 if (ngx_strncmp(value[i].data, "flush=", 6) == 0) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1115 s.len = value[i].len - 6; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1116 s.data = value[i].data + 6; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1117 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1118 flush = ngx_parse_time(&s, 0); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1119 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1120 if (flush == (ngx_msec_t) NGX_ERROR || flush == 0) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1121 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1122 "invalid flush time \"%V\"", &s); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1123 return NGX_CONF_ERROR; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1124 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1125 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1126 continue; |
571 | 1127 } |
1128 | |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1129 if (ngx_strncmp(value[i].data, "gzip", 4) == 0 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1130 && (value[i].len == 4 || value[i].data[4] == '=')) |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1131 { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1132 #if (NGX_ZLIB) |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1133 if (size == 0) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1134 size = 64 * 1024; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1135 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1136 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1137 if (value[i].len == 4) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1138 gzip = Z_BEST_SPEED; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1139 continue; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1140 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1141 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1142 s.len = value[i].len - 5; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1143 s.data = value[i].data + 5; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1144 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1145 gzip = ngx_atoi(s.data, s.len); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1146 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1147 if (gzip < 1 || gzip > 9) { |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1148 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1149 "invalid compression level \"%V\"", &s); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1150 return NGX_CONF_ERROR; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1151 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1152 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1153 continue; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1154 |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1155 #else |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1156 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1157 "nginx was built without zlib support"); |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1158 return NGX_CONF_ERROR; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1159 #endif |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1160 } |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1161 |
5653
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
1162 if (ngx_strncmp(value[i].data, "if=", 3) == 0) { |
5833
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1163 s.len = value[i].len - 3; |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1164 s.data = value[i].data + 3; |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1165 |
6678 | 1166 ngx_memzero(&ccv, sizeof(ngx_stream_compile_complex_value_t)); |
5833
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1167 |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1168 ccv.cf = cf; |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1169 ccv.value = &s; |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1170 ccv.complex_value = ngx_palloc(cf->pool, |
6678 | 1171 sizeof(ngx_stream_complex_value_t)); |
5833
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1172 if (ccv.complex_value == NULL) { |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1173 return NGX_CONF_ERROR; |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1174 } |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1175 |
6678 | 1176 if (ngx_stream_compile_complex_value(&ccv) != NGX_OK) { |
5833
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1177 return NGX_CONF_ERROR; |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1178 } |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1179 |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1180 log->filter = ccv.complex_value; |
e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
Valentin Bartenev <vbart@nginx.com>
parents:
5799
diff
changeset
|
1181 |
5653
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
1182 continue; |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
1183 } |
cb308813b453
Access log: the "if" parameter of the "access_log" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5361
diff
changeset
|
1184 |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1185 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1186 "invalid parameter \"%V\"", &value[i]); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1187 return NGX_CONF_ERROR; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1188 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1189 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1190 if (flush && size == 0) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1191 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1192 "no buffer is defined for access_log \"%V\"", |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1193 &value[1]); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1194 return NGX_CONF_ERROR; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1195 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1196 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1197 if (size) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1198 |
2072 | 1199 if (log->script) { |
1200 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
4133
59b99f217c6d
Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents:
3991
diff
changeset
|
1201 "buffered logs cannot have variables in name"); |
2072 | 1202 return NGX_CONF_ERROR; |
1203 } | |
1204 | |
5799
b1f8285297a7
Access log: allowed logs to syslog with "if=" (ticket #596).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5719
diff
changeset
|
1205 if (log->syslog_peer) { |
b1f8285297a7
Access log: allowed logs to syslog with "if=" (ticket #596).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5719
diff
changeset
|
1206 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
b1f8285297a7
Access log: allowed logs to syslog with "if=" (ticket #596).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5719
diff
changeset
|
1207 "logs to syslog cannot be buffered"); |
b1f8285297a7
Access log: allowed logs to syslog with "if=" (ticket #596).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5719
diff
changeset
|
1208 return NGX_CONF_ERROR; |
b1f8285297a7
Access log: allowed logs to syslog with "if=" (ticket #596).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5719
diff
changeset
|
1209 } |
b1f8285297a7
Access log: allowed logs to syslog with "if=" (ticket #596).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5719
diff
changeset
|
1210 |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1211 if (log->file->data) { |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1212 buffer = log->file->data; |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1213 |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1214 if (buffer->last - buffer->start != size |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1215 || buffer->flush != flush |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1216 || buffer->gzip != gzip) |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1217 { |
4984
7737f0d788c1
Access log: fixed redundant buffer reallocation.
Valentin Bartenev <vbart@nginx.com>
parents:
4893
diff
changeset
|
1218 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
7737f0d788c1
Access log: fixed redundant buffer reallocation.
Valentin Bartenev <vbart@nginx.com>
parents:
4893
diff
changeset
|
1219 "access_log \"%V\" already defined " |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1220 "with conflicting parameters", |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1221 &value[1]); |
4984
7737f0d788c1
Access log: fixed redundant buffer reallocation.
Valentin Bartenev <vbart@nginx.com>
parents:
4893
diff
changeset
|
1222 return NGX_CONF_ERROR; |
7737f0d788c1
Access log: fixed redundant buffer reallocation.
Valentin Bartenev <vbart@nginx.com>
parents:
4893
diff
changeset
|
1223 } |
7737f0d788c1
Access log: fixed redundant buffer reallocation.
Valentin Bartenev <vbart@nginx.com>
parents:
4893
diff
changeset
|
1224 |
7737f0d788c1
Access log: fixed redundant buffer reallocation.
Valentin Bartenev <vbart@nginx.com>
parents:
4893
diff
changeset
|
1225 return NGX_CONF_OK; |
571 | 1226 } |
1227 | |
6678 | 1228 buffer = ngx_pcalloc(cf->pool, sizeof(ngx_stream_log_buf_t)); |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1229 if (buffer == NULL) { |
571 | 1230 return NGX_CONF_ERROR; |
1231 } | |
1232 | |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1233 buffer->start = ngx_pnalloc(cf->pool, size); |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1234 if (buffer->start == NULL) { |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1235 return NGX_CONF_ERROR; |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1236 } |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1237 |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1238 buffer->pos = buffer->start; |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1239 buffer->last = buffer->start + size; |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1240 |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1241 if (flush) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1242 buffer->event = ngx_pcalloc(cf->pool, sizeof(ngx_event_t)); |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1243 if (buffer->event == NULL) { |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1244 return NGX_CONF_ERROR; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1245 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1246 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1247 buffer->event->data = log->file; |
6678 | 1248 buffer->event->handler = ngx_stream_log_flush_handler; |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1249 buffer->event->log = &cf->cycle->new_log; |
5897
dff86e2246a5
Access log: cancel the flush timer on graceful shutdown.
Valentin Bartenev <vbart@nginx.com>
parents:
5833
diff
changeset
|
1250 buffer->event->cancelable = 1; |
4986
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1251 |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1252 buffer->flush = flush; |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1253 } |
3efc49b156d9
Access log: the "flush" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
1254 |
4988
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1255 buffer->gzip = gzip; |
3849bb380605
Access log: the "gzip" parameter of the "access_log" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4986
diff
changeset
|
1256 |
6678 | 1257 log->file->flush = ngx_stream_log_flush; |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4984
diff
changeset
|
1258 log->file->data = buffer; |
571 | 1259 } |
1260 | |
1261 return NGX_CONF_OK; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
1262 } |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1263 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1264 |
497 | 1265 static char * |
6678 | 1266 ngx_stream_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1267 { |
6678 | 1268 ngx_stream_log_main_conf_t *lmcf = conf; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1269 |
6678 | 1270 ngx_str_t *value; |
1271 ngx_uint_t i; | |
1272 ngx_stream_log_fmt_t *fmt; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1273 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1274 value = cf->args->elts; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1275 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1276 fmt = lmcf->formats.elts; |
573 | 1277 for (i = 0; i < lmcf->formats.nelts; i++) { |
1278 if (fmt[i].name.len == value[1].len | |
1279 && ngx_strcmp(fmt[i].name.data, value[1].data) == 0) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1280 { |
2036 | 1281 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1282 "duplicate \"log_format\" name \"%V\"", | |
1283 &value[1]); | |
1284 return NGX_CONF_ERROR; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1285 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1286 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1287 |
501 | 1288 fmt = ngx_array_push(&lmcf->formats); |
1289 if (fmt == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1290 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1291 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1292 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1293 fmt->name = value[1]; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1294 |
2261 | 1295 fmt->flushes = ngx_array_create(cf->pool, 4, sizeof(ngx_int_t)); |
1296 if (fmt->flushes == NULL) { | |
1297 return NGX_CONF_ERROR; | |
1298 } | |
1299 | |
6678 | 1300 fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_stream_log_op_t)); |
501 | 1301 if (fmt->ops == NULL) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1302 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1303 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1304 |
6678 | 1305 return ngx_stream_log_compile_format(cf, fmt->flushes, fmt->ops, |
1306 cf->args, 2); | |
573 | 1307 } |
1308 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1309 |
573 | 1310 static char * |
6678 | 1311 ngx_stream_log_compile_format(ngx_conf_t *cf, ngx_array_t *flushes, |
2261 | 1312 ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s) |
573 | 1313 { |
6678 | 1314 u_char *data, *p, ch; |
1315 size_t i, len; | |
1316 ngx_str_t *value, var; | |
1317 ngx_int_t *flush; | |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
1318 ngx_uint_t bracket, escape; |
6678 | 1319 ngx_stream_log_op_t *op; |
573 | 1320 |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
1321 escape = NGX_STREAM_LOG_ESCAPE_DEFAULT; |
573 | 1322 value = args->elts; |
1323 | |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1324 if (s < args->nelts && ngx_strncmp(value[s].data, "escape=", 7) == 0) { |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1325 data = value[s].data + 7; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1326 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1327 if (ngx_strcmp(data, "json") == 0) { |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
1328 escape = NGX_STREAM_LOG_ESCAPE_JSON; |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
1329 |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
1330 } else if (ngx_strcmp(data, "none") == 0) { |
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
1331 escape = NGX_STREAM_LOG_ESCAPE_NONE; |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1332 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1333 } else if (ngx_strcmp(data, "default") != 0) { |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1334 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1335 "unknown log format escaping \"%s\"", data); |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1336 return NGX_CONF_ERROR; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1337 } |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1338 |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1339 s++; |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1340 } |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1341 |
573 | 1342 for ( /* void */ ; s < args->nelts; s++) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1343 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1344 i = 0; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1345 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1346 while (i < value[s].len) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1347 |
573 | 1348 op = ngx_array_push(ops); |
501 | 1349 if (op == NULL) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1350 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1351 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1352 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1353 data = &value[s].data[i]; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1354 |
880 | 1355 if (value[s].data[i] == '$') { |
569 | 1356 |
1357 if (++i == value[s].len) { | |
1358 goto invalid; | |
1359 } | |
1360 | |
1361 if (value[s].data[i] == '{') { | |
1362 bracket = 1; | |
1363 | |
1364 if (++i == value[s].len) { | |
1365 goto invalid; | |
1366 } | |
1367 | |
1368 var.data = &value[s].data[i]; | |
1369 | |
1370 } else { | |
1371 bracket = 0; | |
1372 var.data = &value[s].data[i]; | |
1373 } | |
1374 | |
1375 for (var.len = 0; i < value[s].len; i++, var.len++) { | |
1376 ch = value[s].data[i]; | |
1377 | |
1378 if (ch == '}' && bracket) { | |
1379 i++; | |
1380 bracket = 0; | |
1381 break; | |
1382 } | |
1383 | |
1384 if ((ch >= 'A' && ch <= 'Z') | |
1385 || (ch >= 'a' && ch <= 'z') | |
1386 || (ch >= '0' && ch <= '9') | |
1387 || ch == '_') | |
1388 { | |
1389 continue; | |
1390 } | |
1391 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1392 break; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1393 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1394 |
569 | 1395 if (bracket) { |
1396 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1397 "the closing bracket in \"%V\" " | |
1398 "variable is missing", &var); | |
1399 return NGX_CONF_ERROR; | |
1400 } | |
1401 | |
1402 if (var.len == 0) { | |
1403 goto invalid; | |
1404 } | |
1405 | |
7223
265c29b0b8b8
Access log: support for disabling escaping (ticket #1450).
Vladimir Homutov <vl@nginx.com>
parents:
6948
diff
changeset
|
1406 if (ngx_stream_log_variable_compile(cf, op, &var, escape) |
6840
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1407 != NGX_OK) |
0cf4e82e7c48
Access log: support for json escaping.
Valentin Bartenev <vbart@nginx.com>
parents:
6693
diff
changeset
|
1408 { |
569 | 1409 return NGX_CONF_ERROR; |
1410 } | |
1411 | |
2261 | 1412 if (flushes) { |
1413 | |
1414 flush = ngx_array_push(flushes); | |
1415 if (flush == NULL) { | |
1416 return NGX_CONF_ERROR; | |
1417 } | |
1418 | |
1419 *flush = op->data; /* variable index */ | |
1420 } | |
1421 | |
573 | 1422 continue; |
1423 } | |
1424 | |
1425 i++; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1426 |
880 | 1427 while (i < value[s].len && value[s].data[i] != '$') { |
573 | 1428 i++; |
1429 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1430 |
573 | 1431 len = &value[s].data[i] - data; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1432 |
573 | 1433 if (len) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1434 |
573 | 1435 op->len = len; |
1436 op->getlen = NULL; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1437 |
573 | 1438 if (len <= sizeof(uintptr_t)) { |
6678 | 1439 op->run = ngx_stream_log_copy_short; |
573 | 1440 op->data = 0; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1441 |
573 | 1442 while (len--) { |
1443 op->data <<= 8; | |
1444 op->data |= data[len]; | |
1445 } | |
1446 | |
1447 } else { | |
6678 | 1448 op->run = ngx_stream_log_copy_long; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1449 |
2049 | 1450 p = ngx_pnalloc(cf->pool, len); |
573 | 1451 if (p == NULL) { |
1452 return NGX_CONF_ERROR; | |
1453 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1454 |
573 | 1455 ngx_memcpy(p, data, len); |
1456 op->data = (uintptr_t) p; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1457 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1458 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1459 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1460 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1461 |
569 | 1462 return NGX_CONF_OK; |
1463 | |
1464 invalid: | |
1465 | |
1466 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%s\"", data); | |
1467 | |
1468 return NGX_CONF_ERROR; | |
1469 } | |
1470 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1471 |
2072 | 1472 static char * |
6678 | 1473 ngx_stream_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
2072 | 1474 { |
6678 | 1475 ngx_stream_log_srv_conf_t *lscf = conf; |
2072 | 1476 |
1477 time_t inactive, valid; | |
1478 ngx_str_t *value, s; | |
1479 ngx_int_t max, min_uses; | |
1480 ngx_uint_t i; | |
1481 | |
6678 | 1482 if (lscf->open_file_cache != NGX_CONF_UNSET_PTR) { |
2072 | 1483 return "is duplicate"; |
1484 } | |
1485 | |
1486 value = cf->args->elts; | |
1487 | |
1488 max = 0; | |
1489 inactive = 10; | |
1490 valid = 60; | |
1491 min_uses = 1; | |
1492 | |
1493 for (i = 1; i < cf->args->nelts; i++) { | |
1494 | |
1495 if (ngx_strncmp(value[i].data, "max=", 4) == 0) { | |
1496 | |
1497 max = ngx_atoi(value[i].data + 4, value[i].len - 4); | |
1498 if (max == NGX_ERROR) { | |
1499 goto failed; | |
1500 } | |
1501 | |
1502 continue; | |
1503 } | |
1504 | |
1505 if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) { | |
1506 | |
1507 s.len = value[i].len - 9; | |
1508 s.data = value[i].data + 9; | |
1509 | |
1510 inactive = ngx_parse_time(&s, 1); | |
4474 | 1511 if (inactive == (time_t) NGX_ERROR) { |
2072 | 1512 goto failed; |
1513 } | |
1514 | |
1515 continue; | |
1516 } | |
1517 | |
1518 if (ngx_strncmp(value[i].data, "min_uses=", 9) == 0) { | |
1519 | |
1520 min_uses = ngx_atoi(value[i].data + 9, value[i].len - 9); | |
1521 if (min_uses == NGX_ERROR) { | |
1522 goto failed; | |
1523 } | |
1524 | |
1525 continue; | |
1526 } | |
1527 | |
1528 if (ngx_strncmp(value[i].data, "valid=", 6) == 0) { | |
1529 | |
1530 s.len = value[i].len - 6; | |
1531 s.data = value[i].data + 6; | |
1532 | |
1533 valid = ngx_parse_time(&s, 1); | |
4474 | 1534 if (valid == (time_t) NGX_ERROR) { |
2072 | 1535 goto failed; |
1536 } | |
1537 | |
1538 continue; | |
1539 } | |
1540 | |
1541 if (ngx_strcmp(value[i].data, "off") == 0) { | |
1542 | |
6678 | 1543 lscf->open_file_cache = NULL; |
2072 | 1544 |
1545 continue; | |
1546 } | |
1547 | |
1548 failed: | |
1549 | |
1550 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1551 "invalid \"open_log_file_cache\" parameter \"%V\"", | |
1552 &value[i]); | |
1553 return NGX_CONF_ERROR; | |
1554 } | |
1555 | |
6678 | 1556 if (lscf->open_file_cache == NULL) { |
2072 | 1557 return NGX_CONF_OK; |
1558 } | |
1559 | |
1560 if (max == 0) { | |
1561 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1562 "\"open_log_file_cache\" must have \"max\" parameter"); | |
1563 return NGX_CONF_ERROR; | |
1564 } | |
1565 | |
6678 | 1566 lscf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive); |
2072 | 1567 |
6678 | 1568 if (lscf->open_file_cache) { |
2072 | 1569 |
6678 | 1570 lscf->open_file_cache_valid = valid; |
1571 lscf->open_file_cache_min_uses = min_uses; | |
2072 | 1572 |
1573 return NGX_CONF_OK; | |
1574 } | |
1575 | |
1576 return NGX_CONF_ERROR; | |
1577 } | |
1578 | |
1579 | |
569 | 1580 static ngx_int_t |
6678 | 1581 ngx_stream_log_init(ngx_conf_t *cf) |
569 | 1582 { |
6693 | 1583 ngx_stream_handler_pt *h; |
6678 | 1584 ngx_stream_core_main_conf_t *cmcf; |
573 | 1585 |
6678 | 1586 cmcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_core_module); |
573 | 1587 |
6693 | 1588 h = ngx_array_push(&cmcf->phases[NGX_STREAM_LOG_PHASE].handlers); |
1589 if (h == NULL) { | |
1590 return NGX_ERROR; | |
1591 } | |
1592 | |
1593 *h = ngx_stream_log_handler; | |
569 | 1594 |
1595 return NGX_OK; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1596 } |