diff src/stream/ngx_stream_proxy_module.c @ 6676:df3a7c029dec

Stream: $upstream_bytes_sent and $upstream_bytes_received.
author Vladimir Homutov <vl@nginx.com>
date Fri, 02 Sep 2016 18:27:08 +0300
parents ab9b4fd8c5b7
children c02290241cbe
line wrap: on
line diff
--- a/src/stream/ngx_stream_proxy_module.c
+++ b/src/stream/ngx_stream_proxy_module.c
@@ -1630,6 +1630,9 @@ ngx_stream_proxy_next_upstream(ngx_strea
         }
 #endif
 
+        u->state->bytes_received = u->received;
+        u->state->bytes_sent = pc->sent;
+
         ngx_close_connection(pc);
         u->peer.connection = NULL;
     }
@@ -1658,13 +1661,20 @@ ngx_stream_proxy_finalize(ngx_stream_ses
         u->resolved->ctx = NULL;
     }
 
+    pc = u->peer.connection;
+
+    if (u->state) {
+        if (pc) {
+            u->state->bytes_received = u->received;
+            u->state->bytes_sent = pc->sent;
+        }
+    }
+
     if (u->peer.free && u->peer.sockaddr) {
         u->peer.free(&u->peer, u->peer.data, 0);
         u->peer.sockaddr = NULL;
     }
 
-    pc = u->peer.connection;
-
     if (pc) {
         ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0,
                        "close stream proxy upstream connection: %d", pc->fd);