 +                ngx_http_upstream_finalize_request(r, u, 0);
 +
 +            } else {
-+
 +                ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
 +            }
 +
              return;
          }
      }
-@@ -3073,6 +3087,13 @@
+@@ -3073,6 +3086,13 @@
          && rc != NGX_HTTP_REQUEST_TIME_OUT
          && (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE))
      {

                 b->pos = b->start;
                 b->last = b->start;
             }
@@ -2710,7 +2714,17 @@
 #if 0
             ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
 #endif

--- nginx-1.2.3/src/http/ngx_http_upstream.c	2012-08-06 10:34:08.000000000 -0700
+++ nginx-1.2.3-patched/src/http/ngx_http_upstream.c	2012-09-09 21:58:04.727761891 -0700
@@ -2383,7 +2383,7 @@
 
     if (c->read->timedout) {
