Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 5142:afea5259e05c
Upstream: fixed tcp_nodelay with connection upgrade (ticket #325).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 27 Mar 2013 15:18:34 +0000 |
parents | 9bcf89ca78d2 |
children | 85ee9d858dcb |
comparison
equal
deleted
inserted
replaced
5141:87faa6b818bc | 5142:afea5259e05c |
---|---|
2411 u->read_event_handler = ngx_http_upstream_upgraded_read_upstream; | 2411 u->read_event_handler = ngx_http_upstream_upgraded_read_upstream; |
2412 u->write_event_handler = ngx_http_upstream_upgraded_write_upstream; | 2412 u->write_event_handler = ngx_http_upstream_upgraded_write_upstream; |
2413 r->read_event_handler = ngx_http_upstream_upgraded_read_downstream; | 2413 r->read_event_handler = ngx_http_upstream_upgraded_read_downstream; |
2414 r->write_event_handler = ngx_http_upstream_upgraded_write_downstream; | 2414 r->write_event_handler = ngx_http_upstream_upgraded_write_downstream; |
2415 | 2415 |
2416 if (clcf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) { | 2416 if (clcf->tcp_nodelay) { |
2417 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay"); | |
2418 | |
2419 tcp_nodelay = 1; | 2417 tcp_nodelay = 1; |
2420 | 2418 |
2421 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, | 2419 if (c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) { |
2422 (const void *) &tcp_nodelay, sizeof(int)) == -1) | 2420 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay"); |
2423 { | 2421 |
2424 ngx_connection_error(c, ngx_socket_errno, | 2422 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, |
2425 "setsockopt(TCP_NODELAY) failed"); | 2423 (const void *) &tcp_nodelay, sizeof(int)) == -1) |
2426 ngx_http_upstream_finalize_request(r, u, 0); | 2424 { |
2427 return; | 2425 ngx_connection_error(c, ngx_socket_errno, |
2428 } | 2426 "setsockopt(TCP_NODELAY) failed"); |
2429 | 2427 ngx_http_upstream_finalize_request(r, u, 0); |
2430 c->tcp_nodelay = NGX_TCP_NODELAY_SET; | 2428 return; |
2431 | 2429 } |
2432 if (setsockopt(u->peer.connection->fd, IPPROTO_TCP, TCP_NODELAY, | 2430 |
2433 (const void *) &tcp_nodelay, sizeof(int)) == -1) | 2431 c->tcp_nodelay = NGX_TCP_NODELAY_SET; |
2434 { | 2432 } |
2435 ngx_connection_error(u->peer.connection, ngx_socket_errno, | 2433 |
2436 "setsockopt(TCP_NODELAY) failed"); | 2434 if (u->peer.connection->tcp_nodelay == NGX_TCP_NODELAY_UNSET) { |
2437 ngx_http_upstream_finalize_request(r, u, 0); | 2435 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, u->peer.connection->log, 0, |
2438 return; | 2436 "tcp_nodelay"); |
2439 } | 2437 |
2440 | 2438 if (setsockopt(u->peer.connection->fd, IPPROTO_TCP, TCP_NODELAY, |
2441 u->peer.connection->tcp_nodelay = NGX_TCP_NODELAY_SET; | 2439 (const void *) &tcp_nodelay, sizeof(int)) == -1) |
2440 { | |
2441 ngx_connection_error(u->peer.connection, ngx_socket_errno, | |
2442 "setsockopt(TCP_NODELAY) failed"); | |
2443 ngx_http_upstream_finalize_request(r, u, 0); | |
2444 return; | |
2445 } | |
2446 | |
2447 u->peer.connection->tcp_nodelay = NGX_TCP_NODELAY_SET; | |
2448 } | |
2442 } | 2449 } |
2443 | 2450 |
2444 if (ngx_http_send_special(r, NGX_HTTP_FLUSH) == NGX_ERROR) { | 2451 if (ngx_http_send_special(r, NGX_HTTP_FLUSH) == NGX_ERROR) { |
2445 ngx_http_upstream_finalize_request(r, u, 0); | 2452 ngx_http_upstream_finalize_request(r, u, 0); |
2446 return; | 2453 return; |