aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2006-12-06 11:33:18 +0000
committerIgor Sysoev <igor@sysoev.ru>2006-12-06 11:33:18 +0000
commit8f98581bbf1d163719f53146ff56af403d8cfc94 (patch)
treee55f6b5cb65ad94a48fa179f349172a7c7625af8 /src
parent8b6844c747ce533fba9ab26f3a6eff96e9b318c4 (diff)
downloadnginx-8f98581bbf1d163719f53146ff56af403d8cfc94.tar.gz
nginx-8f98581bbf1d163719f53146ff56af403d8cfc94.zip
the previous fix does not actually fix overflow
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_upstream.c26
-rw-r--r--src/http/ngx_http_upstream.h3
2 files changed, 15 insertions, 14 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 03b590f5b..a268f193f 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -493,17 +493,16 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
{
ngx_int_t rc;
ngx_time_t *tp;
- ngx_msec_int_t ms;
ngx_connection_t *c;
r->connection->log->action = "connecting to upstream";
r->connection->single_connection = 0;
- if (u->state && u->state->response_time) {
+ if (u->state && u->state->response_sec) {
tp = ngx_timeofday();
- ms = (ngx_msec_t) tp->sec * 1000 + tp->msec - u->state->response_time;
- u->state->response_time = (ms >= 0) ? ms : 0;
+ u->state->response_sec = tp->sec - u->state->response_sec;
+ u->state->response_msec = tp->msec - u->state->response_msec;
}
u->state = ngx_array_push(&u->states);
@@ -516,7 +515,8 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
tp = ngx_timeofday();
- u->state->response_time = (ngx_msec_t) tp->sec * 1000 + tp->msec;
+ u->state->response_sec = tp->sec;
+ u->state->response_msec = tp->msec;
rc = ngx_event_connect_peer(&u->peer);
@@ -2043,18 +2043,17 @@ static void
ngx_http_upstream_finalize_request(ngx_http_request_t *r,
ngx_http_upstream_t *u, ngx_int_t rc)
{
- ngx_time_t *tp;
- ngx_msec_int_t ms;
+ ngx_time_t *tp;
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"finalize http upstream request: %i", rc);
*u->cleanup = NULL;
- if (u->state->response_time) {
+ if (u->state->response_sec) {
tp = ngx_timeofday();
- ms = (ngx_msec_t) tp->sec * 1000 + tp->msec - u->state->response_time;
- u->state->response_time = (ms >= 0) ? ms : 0;
+ u->state->response_sec = tp->sec - u->state->response_sec;
+ u->state->response_msec = tp->msec - u->state->response_msec;
}
u->finalize_request(r, rc);
@@ -2531,6 +2530,7 @@ ngx_http_upstream_response_time_variable(ngx_http_request_t *r,
u_char *p;
size_t len;
ngx_uint_t i;
+ ngx_msec_int_t ms;
ngx_http_upstream_t *u;
ngx_http_upstream_state_t *state;
@@ -2562,9 +2562,9 @@ ngx_http_upstream_response_time_variable(ngx_http_request_t *r,
*p++ = '-';
} else {
- p = ngx_sprintf(p, "%d.%03d",
- state[i].response_time / 1000,
- state[i].response_time % 1000);
+ ms = state[i].response_sec * 1000 + state[i].response_msec;
+ ms = (ms >= 0) ? ms : 0;
+ p = ngx_sprintf(p, "%d.%03d", ms / 1000, ms % 1000);
}
if (++i == u->states.nelts) {
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
index 80c4d82b2..185964e2c 100644
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -35,7 +35,8 @@ typedef struct {
ngx_uint_t bl_state;
ngx_uint_t status;
- ngx_msec_t response_time;
+ time_t response_sec;
+ ngx_uint_t response_msec;
ngx_str_t *peer;
} ngx_http_upstream_state_t;