Mercurial > hg > nginx-quic
diff src/stream/ngx_stream_proxy_module.c @ 6677:c02290241cbe
Stream: upstream response time variables.
The $upstream_connect_time, $upstream_first_byte_time and
$upstream_session_time variables keep corresponding times.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 02 Sep 2016 18:27:12 +0300 |
parents | df3a7c029dec |
children | 56fc55e32f23 |
line wrap: on
line diff
--- 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_sess 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_sess 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_strea } } + 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_sess } } + 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_ses 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;