aboutsummaryrefslogtreecommitdiff
path: root/src/stream/ngx_stream_proxy_module.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stream/ngx_stream_proxy_module.c')
-rw-r--r--src/stream/ngx_stream_proxy_module.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c
index edffaf8e5..ed802e7e1 100644
--- a/src/stream/ngx_stream_proxy_module.c
+++ b/src/stream/ngx_stream_proxy_module.c
@@ -684,6 +684,10 @@ ngx_stream_proxy_connect(ngx_stream_session_t *s)
u = s->upstream;
+ if (u->state) {
+ u->state->response_time = ngx_current_msec - u->state->response_time;
+ }
+
u->state = ngx_array_push(s->upstream_states);
if (u->state == NULL) {
ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
@@ -692,6 +696,10 @@ ngx_stream_proxy_connect(ngx_stream_session_t *s)
ngx_memzero(u->state, sizeof(ngx_stream_upstream_state_t));
+ u->state->connect_time = (ngx_msec_t) -1;
+ u->state->first_byte_time = (ngx_msec_t) -1;
+ u->state->response_time = ngx_current_msec;
+
rc = ngx_event_connect_peer(&u->peer);
ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0, "proxy connect: %i", rc);
@@ -813,6 +821,8 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s)
}
}
+ u->state->connect_time = ngx_current_msec - u->state->response_time;
+
c->log->action = "proxying connection";
if (u->upstream_buf.start == NULL) {
@@ -1518,6 +1528,13 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
}
}
+ if (from_upstream) {
+ if (u->state->first_byte_time == (ngx_msec_t) -1) {
+ u->state->first_byte_time = ngx_current_msec
+ - u->state->response_time;
+ }
+ }
+
if (c->type == SOCK_DGRAM && ++u->responses == pscf->responses)
{
src->read->ready = 0;
@@ -1664,6 +1681,8 @@ ngx_stream_proxy_finalize(ngx_stream_session_t *s, ngx_uint_t rc)
pc = u->peer.connection;
if (u->state) {
+ u->state->response_time = ngx_current_msec - u->state->response_time;
+
if (pc) {
u->state->bytes_received = u->received;
u->state->bytes_sent = pc->sent;