]> git.kaiwu.me - nginx.git/commitdiff
Stream: upstream "connected" flag.
authorRoman Arutyunyan <arut@nginx.com>
Thu, 25 Jun 2015 09:36:52 +0000 (12:36 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Thu, 25 Jun 2015 09:36:52 +0000 (12:36 +0300)
Once upstream is connected, the upstream buffer is allocated.  Previously, the
proxy module used the buffer allocation status to check if upstream is
connected.  Now it's enough to check the flag.

src/stream/ngx_stream_proxy_module.c
src/stream/ngx_stream_upstream.h

index 10ad7d23ccab198d8e4fea9ac7ca3a2bf414060a..ebbe02718eca78831865033d859f7800ba73b00d 100644 (file)
@@ -524,6 +524,8 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s)
     u->upstream_buf.pos = p;
     u->upstream_buf.last = p;
 
+    u->connected = 1;
+
     pc->read->handler = ngx_stream_proxy_upstream_handler;
     pc->write->handler = ngx_stream_proxy_upstream_handler;
 
@@ -870,7 +872,7 @@ ngx_stream_proxy_process_connection(ngx_event_t *ev, ngx_uint_t from_upstream)
                     return;
                 }
 
-                if (u->upstream_buf.start) {
+                if (u->connected) {
                     pc = u->peer.connection;
 
                     if (!c->read->delayed && !pc->read->delayed) {
@@ -901,7 +903,7 @@ ngx_stream_proxy_process_connection(ngx_event_t *ev, ngx_uint_t from_upstream)
         return;
     }
 
-    if (from_upstream && u->upstream_buf.start == NULL) {
+    if (from_upstream && !u->connected) {
         return;
     }
 
@@ -1000,7 +1002,7 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
     u = s->upstream;
 
     c = s->connection;
-    pc = u->upstream_buf.start ? u->peer.connection : NULL;
+    pc = u->connected ? u->peer.connection : NULL;
 
     pscf = ngx_stream_get_module_srv_conf(s, ngx_stream_proxy_module);
 
index fddc2b168e5ac09aa2aa517b6dfca307aa7f114f..80520c2b3b3548cfb5597a24afd82563d20f0d1d 100644 (file)
@@ -87,8 +87,8 @@ typedef struct {
 #if (NGX_STREAM_SSL)
     ngx_str_t                          ssl_name;
 #endif
-    ngx_uint_t                         proxy_protocol;
-                                               /* unsigned  proxy_protocol:1; */
+    unsigned                           connected:1;
+    unsigned                           proxy_protocol:1;
 } ngx_stream_upstream_t;