r->connection->log->action = "connecting to upstream";
- if (u->state && u->state->response_time) {
- u->state->response_time = ngx_current_msec - u->state->response_time;
+ if (u->state && u->state->response_time == (ngx_msec_t) -1) {
+ u->state->response_time = ngx_current_msec - u->start_time;
}
u->state = ngx_array_push(r->upstream_states);
ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
- u->state->response_time = ngx_current_msec;
+ u->start_time = ngx_current_msec;
+
+ u->state->response_time = (ngx_msec_t) -1;
u->state->connect_time = (ngx_msec_t) -1;
u->state->header_time = (ngx_msec_t) -1;
"http upstream send request");
if (u->state->connect_time == (ngx_msec_t) -1) {
- u->state->connect_time = ngx_current_msec - u->state->response_time;
+ u->state->connect_time = ngx_current_msec - u->start_time;
}
if (!u->request_sent && ngx_http_upstream_test_connect(c) != NGX_OK) {
/* rc == NGX_OK */
- u->state->header_time = ngx_current_msec - u->state->response_time;
+ u->state->header_time = ngx_current_msec - u->start_time;
if (u->headers_in.status_n >= NGX_HTTP_SPECIAL_RESPONSE) {
u->resolved->ctx = NULL;
}
- if (u->state && u->state->response_time) {
- u->state->response_time = ngx_current_msec - u->state->response_time;
+ if (u->state && u->state->response_time == (ngx_msec_t) -1) {
+ u->state->response_time = ngx_current_msec - u->start_time;
if (u->pipe && u->pipe->read_length) {
u->state->bytes_received += u->pipe->read_length
state = r->upstream_states->elts;
for ( ;; ) {
- if (state[i].status) {
- if (data == 1 && state[i].header_time != (ngx_msec_t) -1) {
- ms = state[i].header_time;
+ if (data == 1) {
+ ms = state[i].header_time;
- } else if (data == 2 && state[i].connect_time != (ngx_msec_t) -1) {
- ms = state[i].connect_time;
+ } else if (data == 2) {
+ ms = state[i].connect_time;
- } else {
- ms = state[i].response_time;
- }
+ } else {
+ ms = state[i].response_time;
+ }
+ if (ms != -1) {
ms = ngx_max(ms, 0);
p = ngx_sprintf(p, "%T.%03M", (time_t) ms / 1000, ms % 1000);
u->proxy_protocol = pscf->proxy_protocol;
if (u->state) {
- u->state->response_time = ngx_current_msec - u->state->response_time;
+ u->state->response_time = ngx_current_msec - u->start_time;
}
u->state = ngx_array_push(s->upstream_states);
ngx_memzero(u->state, sizeof(ngx_stream_upstream_state_t));
+ u->start_time = ngx_current_msec;
+
u->state->connect_time = (ngx_msec_t) -1;
u->state->first_byte_time = (ngx_msec_t) -1;
- u->state->response_time = ngx_current_msec;
+ u->state->response_time = (ngx_msec_t) -1;
rc = ngx_event_connect_peer(&u->peer);
}
}
- u->state->connect_time = ngx_current_msec - u->state->response_time;
+ u->state->connect_time = ngx_current_msec - u->start_time;
if (u->peer.notify) {
u->peer.notify(&u->peer, u->peer.data,
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;
+ - u->start_time;
}
}
pc = u->peer.connection;
if (u->state) {
- u->state->response_time = ngx_current_msec - u->state->response_time;
+ if (u->state->response_time == (ngx_msec_t) -1) {
+ u->state->response_time = ngx_current_msec - u->start_time;
+ }
if (pc) {
u->state->bytes_received = u->received;
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;