Mercurial > hg > nginx-quic
comparison src/stream/ngx_stream_proxy_module.c @ 7007:ed1101bbf19f
Introduced ngx_tcp_nodelay().
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Fri, 26 May 2017 22:52:48 +0300 |
parents | 08dc60979133 |
children | 7bfbf73db920 |
comparison
equal
deleted
inserted
replaced
7006:9552758a786e | 7007:ed1101bbf19f |
---|---|
727 | 727 |
728 | 728 |
729 static void | 729 static void |
730 ngx_stream_proxy_init_upstream(ngx_stream_session_t *s) | 730 ngx_stream_proxy_init_upstream(ngx_stream_session_t *s) |
731 { | 731 { |
732 int tcp_nodelay; | |
733 u_char *p; | 732 u_char *p; |
734 ngx_chain_t *cl; | 733 ngx_chain_t *cl; |
735 ngx_connection_t *c, *pc; | 734 ngx_connection_t *c, *pc; |
736 ngx_log_handler_pt handler; | 735 ngx_log_handler_pt handler; |
737 ngx_stream_upstream_t *u; | 736 ngx_stream_upstream_t *u; |
743 | 742 |
744 cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module); | 743 cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module); |
745 | 744 |
746 if (pc->type == SOCK_STREAM | 745 if (pc->type == SOCK_STREAM |
747 && cscf->tcp_nodelay | 746 && cscf->tcp_nodelay |
748 && pc->tcp_nodelay == NGX_TCP_NODELAY_UNSET) | 747 && ngx_tcp_nodelay(pc) != NGX_OK) |
749 { | 748 { |
750 ngx_log_debug0(NGX_LOG_DEBUG_STREAM, pc->log, 0, "tcp_nodelay"); | 749 ngx_stream_proxy_next_upstream(s); |
751 | 750 return; |
752 tcp_nodelay = 1; | |
753 | |
754 if (setsockopt(pc->fd, IPPROTO_TCP, TCP_NODELAY, | |
755 (const void *) &tcp_nodelay, sizeof(int)) == -1) | |
756 { | |
757 ngx_connection_error(pc, ngx_socket_errno, | |
758 "setsockopt(TCP_NODELAY) failed"); | |
759 ngx_stream_proxy_next_upstream(s); | |
760 return; | |
761 } | |
762 | |
763 pc->tcp_nodelay = NGX_TCP_NODELAY_SET; | |
764 } | 751 } |
765 | 752 |
766 pscf = ngx_stream_get_module_srv_conf(s, ngx_stream_proxy_module); | 753 pscf = ngx_stream_get_module_srv_conf(s, ngx_stream_proxy_module); |
767 | 754 |
768 #if (NGX_STREAM_SSL) | 755 #if (NGX_STREAM_SSL) |