Mercurial > hg > nginx
annotate src/stream/ngx_stream_handler.c @ 6674:38143d1abdec
Stream: the $status variable.
The stream session status is one of the following:
200 - normal completion
403 - access forbidden
500 - internal server error
502 - bad gateway
503 - limit conn
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 11 Aug 2016 20:22:23 +0300 |
parents | 164a0824ce20 |
children | 0125b151c9a5 |
rev | line source |
---|---|
6115 | 1 |
2 /* | |
3 * Copyright (C) Roman Arutyunyan | |
4 * Copyright (C) Nginx, Inc. | |
5 */ | |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_event.h> | |
11 #include <ngx_stream.h> | |
12 | |
13 | |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
14 static void ngx_stream_close_connection(ngx_connection_t *c); |
6115 | 15 static u_char *ngx_stream_log_error(ngx_log_t *log, u_char *buf, size_t len); |
16 static void ngx_stream_init_session(ngx_connection_t *c); | |
17 | |
18 #if (NGX_STREAM_SSL) | |
19 static void ngx_stream_ssl_init_connection(ngx_ssl_t *ssl, ngx_connection_t *c); | |
20 static void ngx_stream_ssl_handshake_handler(ngx_connection_t *c); | |
21 #endif | |
22 | |
23 | |
24 void | |
25 ngx_stream_init_connection(ngx_connection_t *c) | |
26 { | |
6221
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
27 int tcp_nodelay; |
6175 | 28 u_char text[NGX_SOCKADDR_STRLEN]; |
29 size_t len; | |
30 ngx_int_t rc; | |
31 ngx_uint_t i; | |
6669
164a0824ce20
Stream: the $session_time variable.
Vladimir Homutov <vl@nginx.com>
parents:
6607
diff
changeset
|
32 ngx_time_t *tp; |
6175 | 33 struct sockaddr *sa; |
34 ngx_stream_port_t *port; | |
35 struct sockaddr_in *sin; | |
36 ngx_stream_in_addr_t *addr; | |
37 ngx_stream_session_t *s; | |
38 ngx_stream_addr_conf_t *addr_conf; | |
6115 | 39 #if (NGX_HAVE_INET6) |
6175 | 40 struct sockaddr_in6 *sin6; |
41 ngx_stream_in6_addr_t *addr6; | |
6115 | 42 #endif |
6175 | 43 ngx_stream_core_srv_conf_t *cscf; |
44 ngx_stream_core_main_conf_t *cmcf; | |
6115 | 45 |
46 /* find the server configuration for the address:port */ | |
47 | |
48 port = c->listening->servers; | |
49 | |
50 if (port->naddrs > 1) { | |
51 | |
52 /* | |
53 * There are several addresses on this port and one of them | |
54 * is the "*:port" wildcard so getsockname() is needed to determine | |
55 * the server address. | |
56 * | |
6436 | 57 * AcceptEx() and recvmsg() already gave this address. |
6115 | 58 */ |
59 | |
60 if (ngx_connection_local_sockaddr(c, NULL, 0) != NGX_OK) { | |
61 ngx_stream_close_connection(c); | |
62 return; | |
63 } | |
64 | |
65 sa = c->local_sockaddr; | |
66 | |
67 switch (sa->sa_family) { | |
68 | |
69 #if (NGX_HAVE_INET6) | |
70 case AF_INET6: | |
71 sin6 = (struct sockaddr_in6 *) sa; | |
72 | |
73 addr6 = port->addrs; | |
74 | |
75 /* the last address is "*" */ | |
76 | |
77 for (i = 0; i < port->naddrs - 1; i++) { | |
78 if (ngx_memcmp(&addr6[i].addr6, &sin6->sin6_addr, 16) == 0) { | |
79 break; | |
80 } | |
81 } | |
82 | |
83 addr_conf = &addr6[i].conf; | |
84 | |
85 break; | |
86 #endif | |
87 | |
88 default: /* AF_INET */ | |
89 sin = (struct sockaddr_in *) sa; | |
90 | |
91 addr = port->addrs; | |
92 | |
93 /* the last address is "*" */ | |
94 | |
95 for (i = 0; i < port->naddrs - 1; i++) { | |
96 if (addr[i].addr == sin->sin_addr.s_addr) { | |
97 break; | |
98 } | |
99 } | |
100 | |
101 addr_conf = &addr[i].conf; | |
102 | |
103 break; | |
104 } | |
105 | |
106 } else { | |
107 switch (c->local_sockaddr->sa_family) { | |
108 | |
109 #if (NGX_HAVE_INET6) | |
110 case AF_INET6: | |
111 addr6 = port->addrs; | |
112 addr_conf = &addr6[0].conf; | |
113 break; | |
114 #endif | |
115 | |
116 default: /* AF_INET */ | |
117 addr = port->addrs; | |
118 addr_conf = &addr[0].conf; | |
119 break; | |
120 } | |
121 } | |
122 | |
123 s = ngx_pcalloc(c->pool, sizeof(ngx_stream_session_t)); | |
124 if (s == NULL) { | |
125 ngx_stream_close_connection(c); | |
126 return; | |
127 } | |
128 | |
129 s->signature = NGX_STREAM_MODULE; | |
130 s->main_conf = addr_conf->ctx->main_conf; | |
131 s->srv_conf = addr_conf->ctx->srv_conf; | |
132 | |
133 s->connection = c; | |
134 c->data = s; | |
135 | |
136 cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module); | |
137 | |
6129
187aa751ad62
Core: the ngx_set_connection_log() macro.
Vladimir Homutov <vl@nginx.com>
parents:
6115
diff
changeset
|
138 ngx_set_connection_log(c, cscf->error_log); |
6115 | 139 |
140 len = ngx_sock_ntop(c->sockaddr, c->socklen, text, NGX_SOCKADDR_STRLEN, 1); | |
141 | |
6461
a01e315b3a78
Stream: additional logging for UDP.
Vladimir Homutov <vl@nginx.com>
parents:
6436
diff
changeset
|
142 ngx_log_error(NGX_LOG_INFO, c->log, 0, "*%uA %sclient %*s connected to %V", |
a01e315b3a78
Stream: additional logging for UDP.
Vladimir Homutov <vl@nginx.com>
parents:
6436
diff
changeset
|
143 c->number, c->type == SOCK_DGRAM ? "udp " : "", |
a01e315b3a78
Stream: additional logging for UDP.
Vladimir Homutov <vl@nginx.com>
parents:
6436
diff
changeset
|
144 len, text, &addr_conf->addr_text); |
6115 | 145 |
146 c->log->connection = c->number; | |
147 c->log->handler = ngx_stream_log_error; | |
148 c->log->data = s; | |
149 c->log->action = "initializing connection"; | |
150 c->log_error = NGX_ERROR_INFO; | |
151 | |
6175 | 152 cmcf = ngx_stream_get_module_main_conf(s, ngx_stream_core_module); |
153 | |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
154 s->variables = ngx_pcalloc(s->connection->pool, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
155 cmcf->variables.nelts |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
156 * sizeof(ngx_stream_variable_value_t)); |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
157 |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
158 if (s->variables == NULL) { |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
159 ngx_stream_close_connection(c); |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
160 return; |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
161 } |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6461
diff
changeset
|
162 |
6669
164a0824ce20
Stream: the $session_time variable.
Vladimir Homutov <vl@nginx.com>
parents:
6607
diff
changeset
|
163 tp = ngx_timeofday(); |
164a0824ce20
Stream: the $session_time variable.
Vladimir Homutov <vl@nginx.com>
parents:
6607
diff
changeset
|
164 s->start_sec = tp->sec; |
164a0824ce20
Stream: the $session_time variable.
Vladimir Homutov <vl@nginx.com>
parents:
6607
diff
changeset
|
165 s->start_msec = tp->msec; |
164a0824ce20
Stream: the $session_time variable.
Vladimir Homutov <vl@nginx.com>
parents:
6607
diff
changeset
|
166 |
6197
0dcef374b8bb
Stream: connection limiting module.
Vladimir Homutov <vl@nginx.com>
parents:
6175
diff
changeset
|
167 if (cmcf->limit_conn_handler) { |
0dcef374b8bb
Stream: connection limiting module.
Vladimir Homutov <vl@nginx.com>
parents:
6175
diff
changeset
|
168 rc = cmcf->limit_conn_handler(s); |
0dcef374b8bb
Stream: connection limiting module.
Vladimir Homutov <vl@nginx.com>
parents:
6175
diff
changeset
|
169 |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
170 if (rc == NGX_ERROR) { |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
171 ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
172 return; |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
173 } |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
174 |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
175 if (rc == NGX_ABORT) { |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
176 ngx_stream_finalize_session(s, NGX_STREAM_SERVICE_UNAVAILABLE); |
6197
0dcef374b8bb
Stream: connection limiting module.
Vladimir Homutov <vl@nginx.com>
parents:
6175
diff
changeset
|
177 return; |
0dcef374b8bb
Stream: connection limiting module.
Vladimir Homutov <vl@nginx.com>
parents:
6175
diff
changeset
|
178 } |
0dcef374b8bb
Stream: connection limiting module.
Vladimir Homutov <vl@nginx.com>
parents:
6175
diff
changeset
|
179 } |
0dcef374b8bb
Stream: connection limiting module.
Vladimir Homutov <vl@nginx.com>
parents:
6175
diff
changeset
|
180 |
6175 | 181 if (cmcf->access_handler) { |
182 rc = cmcf->access_handler(s); | |
183 | |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
184 if (rc == NGX_ERROR) { |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
185 ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
186 return; |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
187 } |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
188 |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
189 if (rc == NGX_ABORT) { |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
190 ngx_stream_finalize_session(s, NGX_STREAM_FORBIDDEN); |
6175 | 191 return; |
192 } | |
193 } | |
194 | |
6436 | 195 if (c->type == SOCK_STREAM |
196 && cscf->tcp_nodelay | |
197 && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) | |
198 { | |
6221
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
199 ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0, "tcp_nodelay"); |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
200 |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
201 tcp_nodelay = 1; |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
202 |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
203 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
204 (const void *) &tcp_nodelay, sizeof(int)) == -1) |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
205 { |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
206 ngx_connection_error(c, ngx_socket_errno, |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
207 "setsockopt(TCP_NODELAY) failed"); |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
208 ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
6221
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
209 return; |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
210 } |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
211 |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
212 c->tcp_nodelay = NGX_TCP_NODELAY_SET; |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
213 } |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
214 |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6197
diff
changeset
|
215 |
6115 | 216 #if (NGX_STREAM_SSL) |
217 { | |
218 ngx_stream_ssl_conf_t *sslcf; | |
219 | |
220 sslcf = ngx_stream_get_module_srv_conf(s, ngx_stream_ssl_module); | |
221 | |
222 if (addr_conf->ssl) { | |
223 c->log->action = "SSL handshaking"; | |
224 | |
225 if (sslcf->ssl.ctx == NULL) { | |
226 ngx_log_error(NGX_LOG_ERR, c->log, 0, | |
227 "no \"ssl_certificate\" is defined " | |
228 "in server listening on SSL port"); | |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
229 ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
6115 | 230 return; |
231 } | |
232 | |
233 ngx_stream_ssl_init_connection(&sslcf->ssl, c); | |
234 return; | |
235 } | |
236 } | |
237 #endif | |
238 | |
239 ngx_stream_init_session(c); | |
240 } | |
241 | |
242 | |
243 static void | |
244 ngx_stream_init_session(ngx_connection_t *c) | |
245 { | |
246 ngx_stream_session_t *s; | |
247 ngx_stream_core_srv_conf_t *cscf; | |
248 | |
249 s = c->data; | |
250 c->log->action = "handling client connection"; | |
251 | |
252 cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module); | |
253 | |
254 s->ctx = ngx_pcalloc(c->pool, sizeof(void *) * ngx_stream_max_module); | |
255 if (s->ctx == NULL) { | |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
256 ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
6115 | 257 return; |
258 } | |
259 | |
260 cscf->handler(s); | |
261 } | |
262 | |
263 | |
264 #if (NGX_STREAM_SSL) | |
265 | |
266 static void | |
267 ngx_stream_ssl_init_connection(ngx_ssl_t *ssl, ngx_connection_t *c) | |
268 { | |
269 ngx_stream_session_t *s; | |
270 ngx_stream_ssl_conf_t *sslcf; | |
271 | |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
272 s = c->data; |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
273 |
6115 | 274 if (ngx_ssl_create_connection(ssl, c, 0) == NGX_ERROR) { |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
275 ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
6115 | 276 return; |
277 } | |
278 | |
279 if (ngx_ssl_handshake(c) == NGX_AGAIN) { | |
280 sslcf = ngx_stream_get_module_srv_conf(s, ngx_stream_ssl_module); | |
281 | |
282 ngx_add_timer(c->read, sslcf->handshake_timeout); | |
283 | |
284 c->ssl->handler = ngx_stream_ssl_handshake_handler; | |
285 | |
286 return; | |
287 } | |
288 | |
289 ngx_stream_ssl_handshake_handler(c); | |
290 } | |
291 | |
292 | |
293 static void | |
294 ngx_stream_ssl_handshake_handler(ngx_connection_t *c) | |
295 { | |
296 if (!c->ssl->handshaked) { | |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
297 ngx_stream_finalize_session(c->data, NGX_STREAM_INTERNAL_SERVER_ERROR); |
6115 | 298 return; |
299 } | |
300 | |
301 if (c->read->timer_set) { | |
302 ngx_del_timer(c->read); | |
303 } | |
304 | |
305 ngx_stream_init_session(c); | |
306 } | |
307 | |
308 #endif | |
309 | |
310 | |
311 void | |
6674
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
312 ngx_stream_finalize_session(ngx_stream_session_t *s, ngx_uint_t rc) |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
313 { |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
314 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0, |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
315 "finalize stream session: %i", rc); |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
316 |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
317 s->status = rc; |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
318 |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
319 ngx_stream_close_connection(s->connection); |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
320 } |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
321 |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
322 |
38143d1abdec
Stream: the $status variable.
Roman Arutyunyan <arut@nginx.com>
parents:
6669
diff
changeset
|
323 static void |
6115 | 324 ngx_stream_close_connection(ngx_connection_t *c) |
325 { | |
326 ngx_pool_t *pool; | |
327 | |
328 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0, | |
329 "close stream connection: %d", c->fd); | |
330 | |
331 #if (NGX_STREAM_SSL) | |
332 | |
333 if (c->ssl) { | |
334 if (ngx_ssl_shutdown(c) == NGX_AGAIN) { | |
335 c->ssl->handler = ngx_stream_close_connection; | |
336 return; | |
337 } | |
338 } | |
339 | |
340 #endif | |
341 | |
342 #if (NGX_STAT_STUB) | |
343 (void) ngx_atomic_fetch_add(ngx_stat_active, -1); | |
344 #endif | |
345 | |
346 pool = c->pool; | |
347 | |
348 ngx_close_connection(c); | |
349 | |
350 ngx_destroy_pool(pool); | |
351 } | |
352 | |
353 | |
354 static u_char * | |
355 ngx_stream_log_error(ngx_log_t *log, u_char *buf, size_t len) | |
356 { | |
357 u_char *p; | |
358 ngx_stream_session_t *s; | |
359 | |
360 if (log->action) { | |
361 p = ngx_snprintf(buf, len, " while %s", log->action); | |
362 len -= p - buf; | |
363 buf = p; | |
364 } | |
365 | |
366 s = log->data; | |
367 | |
6461
a01e315b3a78
Stream: additional logging for UDP.
Vladimir Homutov <vl@nginx.com>
parents:
6436
diff
changeset
|
368 p = ngx_snprintf(buf, len, ", %sclient: %V, server: %V", |
a01e315b3a78
Stream: additional logging for UDP.
Vladimir Homutov <vl@nginx.com>
parents:
6436
diff
changeset
|
369 s->connection->type == SOCK_DGRAM ? "udp " : "", |
6115 | 370 &s->connection->addr_text, |
371 &s->connection->listening->addr_text); | |
6223
d1f94042c29c
Stream: fixed potential error log buffer overrun.
Vladimir Homutov <vl@nginx.com>
parents:
6221
diff
changeset
|
372 len -= p - buf; |
d1f94042c29c
Stream: fixed potential error log buffer overrun.
Vladimir Homutov <vl@nginx.com>
parents:
6221
diff
changeset
|
373 buf = p; |
6115 | 374 |
375 if (s->log_handler) { | |
6223
d1f94042c29c
Stream: fixed potential error log buffer overrun.
Vladimir Homutov <vl@nginx.com>
parents:
6221
diff
changeset
|
376 p = s->log_handler(log, buf, len); |
6115 | 377 } |
378 | |
379 return p; | |
380 } |