diff src/http/ngx_http_upstream.c @ 262:e0b1d0a6c629 NGINX_0_5_1

nginx 0.5.1 *) Bugfix: the "post_action" directive might not run after a unsuccessful completion of a request. *) Workaround: for Eudora for Mac; bug appeared in 0.4.11. Thanks to Bron Gondwana. *) Bugfix: if the "upstream" name was used in the "fastcgi_pass", then the message "no port in upstream" was issued; bug appeared in 0.5.0. *) Bugfix: if the "proxy_pass" and "fastcgi_pass" directives used the same servers but different ports, then these directives uses the first described port; bug appeared in 0.5.0. *) Bugfix: if the "proxy_pass" and "fastcgi_pass" directives used the unix domain sockets, then these directives used first described socket; bug appeared in 0.5.0. *) Bugfix: ngx_http_auth_basic_module ignored the user if it was in the last line in the password file and there was no the carriage return, the line feed, or the ":" symbol after the password. *) Bugfix: the $upstream_response_time variable might be equal to "0.000", although response time was more than 1 millisecond.
author Igor Sysoev <http://sysoev.ru>
date Mon, 11 Dec 2006 00:00:00 +0300
parents 0effe91f6083
children 4de4f8bc5d07
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -493,17 +493,16 @@ ngx_http_upstream_connect(ngx_http_reque
 {
     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 = 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_reque
     ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
 
     tp = ngx_timeofday();
-    u->state->response_time = 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 = 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
     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
             *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) {
@@ -2843,7 +2843,8 @@ ngx_http_upstream_add(ngx_conf_t *cf, ng
     uscfp = umcf->upstreams.elts;
 
     for (i = 0; i < umcf->upstreams.nelts; i++) {
-        if (uscfp[i]->host.len != u->host.len
+        if (uscfp[i]->port != u->portn
+            || uscfp[i]->host.len != u->host.len
             || ngx_strncasecmp(uscfp[i]->host.data, u->host.data, u->host.len)
                != 0)
         {