diff options
author | Vladimir Homutov <vl@nginx.com> | 2015-08-10 12:14:41 +0300 |
---|---|---|
committer | Vladimir Homutov <vl@nginx.com> | 2015-08-10 12:14:41 +0300 |
commit | b537def75ef942346122e1f182104851f5e039a0 (patch) | |
tree | 2295bbf72011a19b956c402a7866706916e69022 /src/stream/ngx_stream_handler.c | |
parent | 50ff8b3c3a3eba0984ce55c63ab8ac07dcb65265 (diff) | |
download | nginx-b537def75ef942346122e1f182104851f5e039a0.tar.gz nginx-b537def75ef942346122e1f182104851f5e039a0.zip |
Stream: the "tcp_nodelay" directive.
Diffstat (limited to 'src/stream/ngx_stream_handler.c')
-rw-r--r-- | src/stream/ngx_stream_handler.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/stream/ngx_stream_handler.c b/src/stream/ngx_stream_handler.c index 7b635fa4c..24afbcd35 100644 --- a/src/stream/ngx_stream_handler.c +++ b/src/stream/ngx_stream_handler.c @@ -23,6 +23,7 @@ static void ngx_stream_ssl_handshake_handler(ngx_connection_t *c); void ngx_stream_init_connection(ngx_connection_t *c) { + int tcp_nodelay; u_char text[NGX_SOCKADDR_STRLEN]; size_t len; ngx_int_t rc; @@ -165,6 +166,24 @@ ngx_stream_init_connection(ngx_connection_t *c) } } + if (cscf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) { + ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0, "tcp_nodelay"); + + tcp_nodelay = 1; + + if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, + (const void *) &tcp_nodelay, sizeof(int)) == -1) + { + ngx_connection_error(c, ngx_socket_errno, + "setsockopt(TCP_NODELAY) failed"); + ngx_stream_close_connection(c); + return; + } + + c->tcp_nodelay = NGX_TCP_NODELAY_SET; + } + + #if (NGX_STREAM_SSL) { ngx_stream_ssl_conf_t *sslcf; |