Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 850:a164e55b4067
fix negative upstream response time
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 15 Nov 2006 20:51:07 +0000 |
parents | b310630d129e |
children | 3b763d36e055 |
comparison
equal
deleted
inserted
replaced
849:b723b63008e3 | 850:a164e55b4067 |
---|---|
510 static void | 510 static void |
511 ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u) | 511 ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u) |
512 { | 512 { |
513 ngx_int_t rc; | 513 ngx_int_t rc; |
514 ngx_time_t *tp; | 514 ngx_time_t *tp; |
515 ngx_msec_int_t ms; | |
515 ngx_connection_t *c; | 516 ngx_connection_t *c; |
516 | 517 |
517 r->connection->log->action = "connecting to upstream"; | 518 r->connection->log->action = "connecting to upstream"; |
518 | 519 |
519 r->connection->single_connection = 0; | 520 r->connection->single_connection = 0; |
520 | 521 |
521 if (u->state && u->state->response_time) { | 522 if (u->state && u->state->response_time) { |
522 tp = ngx_timeofday(); | 523 tp = ngx_timeofday(); |
523 u->state->response_time = tp->sec * 1000 + tp->msec | 524 ms = tp->sec * 1000 + tp->msec - u->state->response_time; |
524 - u->state->response_time; | 525 u->state->response_time = (ms >= 0) ? ms : 0; |
525 } | 526 } |
526 | 527 |
527 u->state = ngx_array_push(&u->states); | 528 u->state = ngx_array_push(&u->states); |
528 if (u->state == NULL) { | 529 if (u->state == NULL) { |
529 ngx_http_upstream_finalize_request(r, u, | 530 ngx_http_upstream_finalize_request(r, u, |
2055 | 2056 |
2056 static void | 2057 static void |
2057 ngx_http_upstream_finalize_request(ngx_http_request_t *r, | 2058 ngx_http_upstream_finalize_request(ngx_http_request_t *r, |
2058 ngx_http_upstream_t *u, ngx_int_t rc) | 2059 ngx_http_upstream_t *u, ngx_int_t rc) |
2059 { | 2060 { |
2060 ngx_time_t *tp; | 2061 ngx_time_t *tp; |
2062 ngx_msec_int_t ms; | |
2061 | 2063 |
2062 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 2064 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2063 "finalize http upstream request: %i", rc); | 2065 "finalize http upstream request: %i", rc); |
2064 | 2066 |
2065 *u->cleanup = NULL; | 2067 *u->cleanup = NULL; |
2066 | 2068 |
2067 if (u->state->response_time) { | 2069 if (u->state->response_time) { |
2068 tp = ngx_timeofday(); | 2070 tp = ngx_timeofday(); |
2069 u->state->response_time = tp->sec * 1000 + tp->msec | 2071 ms = tp->sec * 1000 + tp->msec - u->state->response_time; |
2070 - u->state->response_time; | 2072 u->state->response_time = (ms >= 0) ? ms : 0; |
2071 } | 2073 } |
2072 | 2074 |
2073 u->finalize_request(r, rc); | 2075 u->finalize_request(r, rc); |
2074 | 2076 |
2075 if (u->peer.connection) { | 2077 if (u->peer.connection) { |