comparison src/stream/ngx_stream_handler.c @ 6221:7565e056fad6

Stream: the "tcp_nodelay" directive.
author Vladimir Homutov <vl@nginx.com>
date Mon, 10 Aug 2015 12:14:41 +0300
parents 0dcef374b8bb
children d1f94042c29c
comparison
equal deleted inserted replaced
6220:5e6142609e48 6221:7565e056fad6
21 21
22 22
23 void 23 void
24 ngx_stream_init_connection(ngx_connection_t *c) 24 ngx_stream_init_connection(ngx_connection_t *c)
25 { 25 {
26 int tcp_nodelay;
26 u_char text[NGX_SOCKADDR_STRLEN]; 27 u_char text[NGX_SOCKADDR_STRLEN];
27 size_t len; 28 size_t len;
28 ngx_int_t rc; 29 ngx_int_t rc;
29 ngx_uint_t i; 30 ngx_uint_t i;
30 struct sockaddr *sa; 31 struct sockaddr *sa;
163 ngx_stream_close_connection(c); 164 ngx_stream_close_connection(c);
164 return; 165 return;
165 } 166 }
166 } 167 }
167 168
169 if (cscf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) {
170 ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0, "tcp_nodelay");
171
172 tcp_nodelay = 1;
173
174 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,
175 (const void *) &tcp_nodelay, sizeof(int)) == -1)
176 {
177 ngx_connection_error(c, ngx_socket_errno,
178 "setsockopt(TCP_NODELAY) failed");
179 ngx_stream_close_connection(c);
180 return;
181 }
182
183 c->tcp_nodelay = NGX_TCP_NODELAY_SET;
184 }
185
186
168 #if (NGX_STREAM_SSL) 187 #if (NGX_STREAM_SSL)
169 { 188 {
170 ngx_stream_ssl_conf_t *sslcf; 189 ngx_stream_ssl_conf_t *sslcf;
171 190
172 sslcf = ngx_stream_get_module_srv_conf(s, ngx_stream_ssl_module); 191 sslcf = ngx_stream_get_module_srv_conf(s, ngx_stream_ssl_module);