Mercurial > hg > nginx
comparison src/stream/ngx_stream_proxy_module.c @ 7397:860d3907da1c
Upstream: revised upstream response time variables.
Variables now do not depend on presence of the HTTP status code in response.
If the corresponding event occurred, variables contain time between request
creation and the event, and "-" otherwise.
Previously, intermediate value of the $upstream_response_time variable held
unix timestamp.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 21 Nov 2018 13:40:40 +0300 |
parents | 4698cede59ff |
children | 6d4bc025c5a7 |
comparison
equal
deleted
inserted
replaced
7396:e8bdd322d7a6 | 7397:860d3907da1c |
---|---|
688 | 688 |
689 u->connected = 0; | 689 u->connected = 0; |
690 u->proxy_protocol = pscf->proxy_protocol; | 690 u->proxy_protocol = pscf->proxy_protocol; |
691 | 691 |
692 if (u->state) { | 692 if (u->state) { |
693 u->state->response_time = ngx_current_msec - u->state->response_time; | 693 u->state->response_time = ngx_current_msec - u->start_time; |
694 } | 694 } |
695 | 695 |
696 u->state = ngx_array_push(s->upstream_states); | 696 u->state = ngx_array_push(s->upstream_states); |
697 if (u->state == NULL) { | 697 if (u->state == NULL) { |
698 ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR); | 698 ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
699 return; | 699 return; |
700 } | 700 } |
701 | 701 |
702 ngx_memzero(u->state, sizeof(ngx_stream_upstream_state_t)); | 702 ngx_memzero(u->state, sizeof(ngx_stream_upstream_state_t)); |
703 | 703 |
704 u->start_time = ngx_current_msec; | |
705 | |
704 u->state->connect_time = (ngx_msec_t) -1; | 706 u->state->connect_time = (ngx_msec_t) -1; |
705 u->state->first_byte_time = (ngx_msec_t) -1; | 707 u->state->first_byte_time = (ngx_msec_t) -1; |
706 u->state->response_time = ngx_current_msec; | 708 u->state->response_time = (ngx_msec_t) -1; |
707 | 709 |
708 rc = ngx_event_connect_peer(&u->peer); | 710 rc = ngx_event_connect_peer(&u->peer); |
709 | 711 |
710 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0, "proxy connect: %i", rc); | 712 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0, "proxy connect: %i", rc); |
711 | 713 |
815 | 817 |
816 c->log->handler = handler; | 818 c->log->handler = handler; |
817 } | 819 } |
818 } | 820 } |
819 | 821 |
820 u->state->connect_time = ngx_current_msec - u->state->response_time; | 822 u->state->connect_time = ngx_current_msec - u->start_time; |
821 | 823 |
822 if (u->peer.notify) { | 824 if (u->peer.notify) { |
823 u->peer.notify(&u->peer, u->peer.data, | 825 u->peer.notify(&u->peer, u->peer.data, |
824 NGX_STREAM_UPSTREAM_NOTIFY_CONNECT); | 826 NGX_STREAM_UPSTREAM_NOTIFY_CONNECT); |
825 } | 827 } |
1620 } | 1622 } |
1621 | 1623 |
1622 if (from_upstream) { | 1624 if (from_upstream) { |
1623 if (u->state->first_byte_time == (ngx_msec_t) -1) { | 1625 if (u->state->first_byte_time == (ngx_msec_t) -1) { |
1624 u->state->first_byte_time = ngx_current_msec | 1626 u->state->first_byte_time = ngx_current_msec |
1625 - u->state->response_time; | 1627 - u->start_time; |
1626 } | 1628 } |
1627 } | 1629 } |
1628 | 1630 |
1629 for (ll = out; *ll; ll = &(*ll)->next) { /* void */ } | 1631 for (ll = out; *ll; ll = &(*ll)->next) { /* void */ } |
1630 | 1632 |
1855 } | 1857 } |
1856 | 1858 |
1857 pc = u->peer.connection; | 1859 pc = u->peer.connection; |
1858 | 1860 |
1859 if (u->state) { | 1861 if (u->state) { |
1860 u->state->response_time = ngx_current_msec - u->state->response_time; | 1862 if (u->state->response_time == (ngx_msec_t) -1) { |
1863 u->state->response_time = ngx_current_msec - u->start_time; | |
1864 } | |
1861 | 1865 |
1862 if (pc) { | 1866 if (pc) { |
1863 u->state->bytes_received = u->received; | 1867 u->state->bytes_received = u->received; |
1864 u->state->bytes_sent = pc->sent; | 1868 u->state->bytes_sent = pc->sent; |
1865 } | 1869 } |