diff options
author | Vladimir Homutov <vl@nginx.com> | 2018-11-21 13:40:40 +0300 |
---|---|---|
committer | Vladimir Homutov <vl@nginx.com> | 2018-11-21 13:40:40 +0300 |
commit | c24146731810f2711da608cd7f3bdca528a3eb14 (patch) | |
tree | 44c5ad93afcaf2c9a5b892c89df657eff1dfa2a3 /src/stream/ngx_stream_upstream.c | |
parent | 0f669b23a84785cdb1891b73d3ecb03a3174ea04 (diff) | |
download | nginx-c24146731810f2711da608cd7f3bdca528a3eb14.tar.gz nginx-c24146731810f2711da608cd7f3bdca528a3eb14.zip |
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.
Diffstat (limited to 'src/stream/ngx_stream_upstream.c')
-rw-r--r-- | src/stream/ngx_stream_upstream.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/stream/ngx_stream_upstream.c b/src/stream/ngx_stream_upstream.c index 7feac4381..eadcf9f9a 100644 --- a/src/stream/ngx_stream_upstream.c +++ b/src/stream/ngx_stream_upstream.c @@ -267,24 +267,22 @@ ngx_stream_upstream_response_time_variable(ngx_stream_session_t *s, for ( ;; ) { if (data == 1) { - if (state[i].first_byte_time == (ngx_msec_t) -1) { - *p++ = '-'; - goto next; - } - ms = state[i].first_byte_time; - } else if (data == 2 && state[i].connect_time != (ngx_msec_t) -1) { + } else if (data == 2) { ms = state[i].connect_time; } else { ms = state[i].response_time; } - ms = ngx_max(ms, 0); - p = ngx_sprintf(p, "%T.%03M", (time_t) ms / 1000, ms % 1000); + if (ms != -1) { + ms = ngx_max(ms, 0); + p = ngx_sprintf(p, "%T.%03M", (time_t) ms / 1000, ms % 1000); - next: + } else { + *p++ = '-'; + } if (++i == s->upstream_states->nelts) { break; |