[nginx] svn commit: r5143 - trunk/src/http

mdounin at mdounin.ru mdounin at mdounin.ru
Wed Mar 27 15:18:34 UTC 2013


Author: mdounin
Date: 2013-03-27 15:18:34 +0000 (Wed, 27 Mar 2013)
New Revision: 5143
URL: http://trac.nginx.org/nginx/changeset/5143/nginx

Log:
Upstream: fixed tcp_nodelay with connection upgrade (ticket #325).


Modified:
   trunk/src/http/ngx_http_upstream.c

Modified: trunk/src/http/ngx_http_upstream.c
===================================================================
--- trunk/src/http/ngx_http_upstream.c	2013-03-27 15:16:45 UTC (rev 5142)
+++ trunk/src/http/ngx_http_upstream.c	2013-03-27 15:18:34 UTC (rev 5143)
@@ -2413,32 +2413,39 @@
     r->read_event_handler = ngx_http_upstream_upgraded_read_downstream;
     r->write_event_handler = ngx_http_upstream_upgraded_write_downstream;
 
-    if (clcf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) {
-        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");
-
+    if (clcf->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_http_upstream_finalize_request(r, u, 0);
-            return;
+        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,
+                           (const void *) &tcp_nodelay, sizeof(int)) == -1)
+            {
+                ngx_connection_error(c, ngx_socket_errno,
+                                     "setsockopt(TCP_NODELAY) failed");
+                ngx_http_upstream_finalize_request(r, u, 0);
+                return;
+            }
+
+            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,
-                       (const void *) &tcp_nodelay, sizeof(int)) == -1)
-        {
-            ngx_connection_error(u->peer.connection, ngx_socket_errno,
-                                 "setsockopt(TCP_NODELAY) failed");
-            ngx_http_upstream_finalize_request(r, u, 0);
-            return;
+            if (setsockopt(u->peer.connection->fd, IPPROTO_TCP, TCP_NODELAY,
+                           (const void *) &tcp_nodelay, sizeof(int)) == -1)
+            {
+                ngx_connection_error(u->peer.connection, ngx_socket_errno,
+                                     "setsockopt(TCP_NODELAY) failed");
+                ngx_http_upstream_finalize_request(r, u, 0);
+                return;
+            }
+
+            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) {



More information about the nginx-devel mailing list