Mercurial > hg > nginx
comparison src/stream/ngx_stream_proxy_module.c @ 6221:7565e056fad6
Stream: the "tcp_nodelay" directive.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 10 Aug 2015 12:14:41 +0300 |
parents | b544f8e0d921 |
children | 1bd5eb20bd7c |
comparison
equal
deleted
inserted
replaced
6220:5e6142609e48 | 6221:7565e056fad6 |
---|---|
476 | 476 |
477 | 477 |
478 static void | 478 static void |
479 ngx_stream_proxy_init_upstream(ngx_stream_session_t *s) | 479 ngx_stream_proxy_init_upstream(ngx_stream_session_t *s) |
480 { | 480 { |
481 int tcp_nodelay; | |
481 u_char *p; | 482 u_char *p; |
482 ngx_connection_t *c, *pc; | 483 ngx_connection_t *c, *pc; |
483 ngx_log_handler_pt handler; | 484 ngx_log_handler_pt handler; |
484 ngx_stream_upstream_t *u; | 485 ngx_stream_upstream_t *u; |
486 ngx_stream_core_srv_conf_t *cscf; | |
485 ngx_stream_proxy_srv_conf_t *pscf; | 487 ngx_stream_proxy_srv_conf_t *pscf; |
486 | 488 |
487 u = s->upstream; | 489 u = s->upstream; |
490 pc = u->peer.connection; | |
491 | |
492 cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module); | |
493 | |
494 if (cscf->tcp_nodelay && pc->tcp_nodelay == NGX_TCP_NODELAY_UNSET) { | |
495 ngx_log_debug0(NGX_LOG_DEBUG_STREAM, pc->log, 0, "tcp_nodelay"); | |
496 | |
497 tcp_nodelay = 1; | |
498 | |
499 if (setsockopt(pc->fd, IPPROTO_TCP, TCP_NODELAY, | |
500 (const void *) &tcp_nodelay, sizeof(int)) == -1) | |
501 { | |
502 ngx_connection_error(pc, ngx_socket_errno, | |
503 "setsockopt(TCP_NODELAY) failed"); | |
504 ngx_stream_proxy_next_upstream(s); | |
505 return; | |
506 } | |
507 | |
508 pc->tcp_nodelay = NGX_TCP_NODELAY_SET; | |
509 } | |
488 | 510 |
489 if (u->proxy_protocol) { | 511 if (u->proxy_protocol) { |
490 if (ngx_stream_proxy_send_proxy_protocol(s) != NGX_OK) { | 512 if (ngx_stream_proxy_send_proxy_protocol(s) != NGX_OK) { |
491 return; | 513 return; |
492 } | 514 } |
493 | 515 |
494 u->proxy_protocol = 0; | 516 u->proxy_protocol = 0; |
495 } | 517 } |
496 | 518 |
497 pscf = ngx_stream_get_module_srv_conf(s, ngx_stream_proxy_module); | 519 pscf = ngx_stream_get_module_srv_conf(s, ngx_stream_proxy_module); |
498 | |
499 pc = u->peer.connection; | |
500 | 520 |
501 #if (NGX_STREAM_SSL) | 521 #if (NGX_STREAM_SSL) |
502 if (pscf->ssl && pc->ssl == NULL) { | 522 if (pscf->ssl && pc->ssl == NULL) { |
503 ngx_stream_proxy_ssl_init_connection(s); | 523 ngx_stream_proxy_ssl_init_connection(s); |
504 return; | 524 return; |