mirror of
https://github.com/nginx/nginx.git
synced 2025-06-29 18:50:39 +08:00
Upstream: fixed tcp_nodelay with connection upgrade (ticket #325).
This commit is contained in:
parent
3b9e7adcf4
commit
cc0e56370d
@ -2413,11 +2413,12 @@ ngx_http_upstream_upgrade(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
r->read_event_handler = ngx_http_upstream_upgraded_read_downstream;
|
r->read_event_handler = ngx_http_upstream_upgraded_read_downstream;
|
||||||
r->write_event_handler = ngx_http_upstream_upgraded_write_downstream;
|
r->write_event_handler = ngx_http_upstream_upgraded_write_downstream;
|
||||||
|
|
||||||
if (clcf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) {
|
if (clcf->tcp_nodelay) {
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");
|
|
||||||
|
|
||||||
tcp_nodelay = 1;
|
tcp_nodelay = 1;
|
||||||
|
|
||||||
|
if (c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) {
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");
|
||||||
|
|
||||||
if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,
|
if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,
|
||||||
(const void *) &tcp_nodelay, sizeof(int)) == -1)
|
(const void *) &tcp_nodelay, sizeof(int)) == -1)
|
||||||
{
|
{
|
||||||
@ -2428,6 +2429,11 @@ ngx_http_upstream_upgrade(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
}
|
}
|
||||||
|
|
||||||
c->tcp_nodelay = NGX_TCP_NODELAY_SET;
|
c->tcp_nodelay = NGX_TCP_NODELAY_SET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (u->peer.connection->tcp_nodelay == NGX_TCP_NODELAY_UNSET) {
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, u->peer.connection->log, 0,
|
||||||
|
"tcp_nodelay");
|
||||||
|
|
||||||
if (setsockopt(u->peer.connection->fd, IPPROTO_TCP, TCP_NODELAY,
|
if (setsockopt(u->peer.connection->fd, IPPROTO_TCP, TCP_NODELAY,
|
||||||
(const void *) &tcp_nodelay, sizeof(int)) == -1)
|
(const void *) &tcp_nodelay, sizeof(int)) == -1)
|
||||||
@ -2440,6 +2446,7 @@ ngx_http_upstream_upgrade(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
|
|
||||||
u->peer.connection->tcp_nodelay = NGX_TCP_NODELAY_SET;
|
u->peer.connection->tcp_nodelay = NGX_TCP_NODELAY_SET;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ngx_http_send_special(r, NGX_HTTP_FLUSH) == NGX_ERROR) {
|
if (ngx_http_send_special(r, NGX_HTTP_FLUSH) == NGX_ERROR) {
|
||||||
ngx_http_upstream_finalize_request(r, u, 0);
|
ngx_http_upstream_finalize_request(r, u, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user