Mercurial > hg > nginx
comparison src/stream/ngx_stream_core_module.c @ 6436:8f038068f4bc
Stream: UDP proxy.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 20 Jan 2016 19:52:12 +0300 |
parents | cf5e822cf470 |
children | 6f8254ae61b8 |
comparison
equal
deleted
inserted
replaced
6435:d1c791479bbb | 6436:8f038068f4bc |
---|---|
250 { | 250 { |
251 size_t len, off; | 251 size_t len, off; |
252 in_port_t port; | 252 in_port_t port; |
253 ngx_str_t *value; | 253 ngx_str_t *value; |
254 ngx_url_t u; | 254 ngx_url_t u; |
255 ngx_uint_t i; | 255 ngx_uint_t i, backlog; |
256 struct sockaddr *sa; | 256 struct sockaddr *sa; |
257 struct sockaddr_in *sin; | 257 struct sockaddr_in *sin; |
258 ngx_stream_listen_t *ls; | 258 ngx_stream_listen_t *ls; |
259 ngx_stream_core_main_conf_t *cmcf; | 259 ngx_stream_core_main_conf_t *cmcf; |
260 #if (NGX_HAVE_INET6) | 260 #if (NGX_HAVE_INET6) |
341 | 341 |
342 ngx_memcpy(&ls->u.sockaddr, u.sockaddr, u.socklen); | 342 ngx_memcpy(&ls->u.sockaddr, u.sockaddr, u.socklen); |
343 | 343 |
344 ls->socklen = u.socklen; | 344 ls->socklen = u.socklen; |
345 ls->backlog = NGX_LISTEN_BACKLOG; | 345 ls->backlog = NGX_LISTEN_BACKLOG; |
346 ls->type = SOCK_STREAM; | |
346 ls->wildcard = u.wildcard; | 347 ls->wildcard = u.wildcard; |
347 ls->ctx = cf->ctx; | 348 ls->ctx = cf->ctx; |
348 | 349 |
349 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) | 350 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) |
350 ls->ipv6only = 1; | 351 ls->ipv6only = 1; |
351 #endif | 352 #endif |
352 | 353 |
354 backlog = 0; | |
355 | |
353 for (i = 2; i < cf->args->nelts; i++) { | 356 for (i = 2; i < cf->args->nelts; i++) { |
357 | |
358 #if !(NGX_WIN32) | |
359 if (ngx_strcmp(value[i].data, "udp") == 0) { | |
360 ls->type = SOCK_DGRAM; | |
361 continue; | |
362 } | |
363 #endif | |
354 | 364 |
355 if (ngx_strcmp(value[i].data, "bind") == 0) { | 365 if (ngx_strcmp(value[i].data, "bind") == 0) { |
356 ls->bind = 1; | 366 ls->bind = 1; |
357 continue; | 367 continue; |
358 } | 368 } |
364 if (ls->backlog == NGX_ERROR || ls->backlog == 0) { | 374 if (ls->backlog == NGX_ERROR || ls->backlog == 0) { |
365 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 375 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
366 "invalid backlog \"%V\"", &value[i]); | 376 "invalid backlog \"%V\"", &value[i]); |
367 return NGX_CONF_ERROR; | 377 return NGX_CONF_ERROR; |
368 } | 378 } |
379 | |
380 backlog = 1; | |
369 | 381 |
370 continue; | 382 continue; |
371 } | 383 } |
372 | 384 |
373 if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) { | 385 if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) { |
528 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 540 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
529 "the invalid \"%V\" parameter", &value[i]); | 541 "the invalid \"%V\" parameter", &value[i]); |
530 return NGX_CONF_ERROR; | 542 return NGX_CONF_ERROR; |
531 } | 543 } |
532 | 544 |
545 if (ls->type == SOCK_DGRAM) { | |
546 if (backlog) { | |
547 return "\"backlog\" parameter is incompatible with \"udp\""; | |
548 } | |
549 | |
550 #if (NGX_STREAM_SSL) | |
551 if (ls->ssl) { | |
552 return "\"ssl\" parameter is incompatible with \"udp\""; | |
553 } | |
554 #endif | |
555 | |
556 if (ls->so_keepalive) { | |
557 return "\"so_keepalive\" parameter is incompatible with \"udp\""; | |
558 } | |
559 } | |
560 | |
533 return NGX_CONF_OK; | 561 return NGX_CONF_OK; |
534 } | 562 } |