Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 6147:74b6ef56ea56
Upstream: $upstream_connect_time.
The variable keeps time spent on establishing a connection with
the upstream server.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Sat, 16 May 2015 01:32:27 +0300 |
parents | 59fc60585f1e |
children | 8b6fa4842133 |
comparison
equal
deleted
inserted
replaced
6146:59fc60585f1e | 6147:74b6ef56ea56 |
---|---|
361 | 361 |
362 { ngx_string("upstream_status"), NULL, | 362 { ngx_string("upstream_status"), NULL, |
363 ngx_http_upstream_status_variable, 0, | 363 ngx_http_upstream_status_variable, 0, |
364 NGX_HTTP_VAR_NOCACHEABLE, 0 }, | 364 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
365 | 365 |
366 { ngx_string("upstream_connect_time"), NULL, | |
367 ngx_http_upstream_response_time_variable, 2, | |
368 NGX_HTTP_VAR_NOCACHEABLE, 0 }, | |
369 | |
366 { ngx_string("upstream_header_time"), NULL, | 370 { ngx_string("upstream_header_time"), NULL, |
367 ngx_http_upstream_response_time_variable, 1, | 371 ngx_http_upstream_response_time_variable, 1, |
368 NGX_HTTP_VAR_NOCACHEABLE, 0 }, | 372 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
369 | 373 |
370 { ngx_string("upstream_response_time"), NULL, | 374 { ngx_string("upstream_response_time"), NULL, |
1316 } | 1320 } |
1317 | 1321 |
1318 ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t)); | 1322 ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t)); |
1319 | 1323 |
1320 u->state->response_time = ngx_current_msec; | 1324 u->state->response_time = ngx_current_msec; |
1325 u->state->connect_time = (ngx_msec_t) -1; | |
1321 u->state->header_time = (ngx_msec_t) -1; | 1326 u->state->header_time = (ngx_msec_t) -1; |
1322 | 1327 |
1323 rc = ngx_event_connect_peer(&u->peer); | 1328 rc = ngx_event_connect_peer(&u->peer); |
1324 | 1329 |
1325 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1330 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1757 | 1762 |
1758 c = u->peer.connection; | 1763 c = u->peer.connection; |
1759 | 1764 |
1760 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | 1765 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1761 "http upstream send request"); | 1766 "http upstream send request"); |
1767 | |
1768 if (u->state->connect_time == (ngx_msec_t) -1) { | |
1769 u->state->connect_time = ngx_current_msec - u->state->response_time; | |
1770 } | |
1762 | 1771 |
1763 if (!u->request_sent && ngx_http_upstream_test_connect(c) != NGX_OK) { | 1772 if (!u->request_sent && ngx_http_upstream_test_connect(c) != NGX_OK) { |
1764 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR); | 1773 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR); |
1765 return; | 1774 return; |
1766 } | 1775 } |
5007 state = r->upstream_states->elts; | 5016 state = r->upstream_states->elts; |
5008 | 5017 |
5009 for ( ;; ) { | 5018 for ( ;; ) { |
5010 if (state[i].status) { | 5019 if (state[i].status) { |
5011 | 5020 |
5012 if (data && state[i].header_time != (ngx_msec_t) -1) { | 5021 if (data == 1 && state[i].header_time != (ngx_msec_t) -1) { |
5013 ms = state[i].header_time; | 5022 ms = state[i].header_time; |
5023 | |
5024 } else if (data == 2 && state[i].connect_time != (ngx_msec_t) -1) { | |
5025 ms = state[i].connect_time; | |
5014 | 5026 |
5015 } else { | 5027 } else { |
5016 ms = state[i].response_time; | 5028 ms = state[i].response_time; |
5017 } | 5029 } |
5018 | 5030 |