nginx-0.1.43-RELEASE import

    *) Feature: the listen(2) backlog in the "listen" directive can be
       changed using the -HUP signal.

    *) Feature: the geo2nginx.pl script was added to contrib.

    *) Change: the FastCGI parameters with the empty values now are passed
       to a server.

    *) Bugfix: the segmentation fault occurred or the worker process may
       got caught in an endless loop if the proxied or FastCGI server sent
       the "Cache-Control" header line and the "expires" directive was
       used; in the proxied mode the the bug had appeared in 0.1.29.
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index f59ff17..c575347 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -241,7 +241,9 @@
 
     u = r->upstream;
 
-    u->request_bufs = r->request_body->bufs;
+    if (r->request_body) {
+        u->request_bufs = r->request_body->bufs;
+    }
 
     if (u->conf->method == NGX_CONF_UNSET_UINT) {
         u->method = r->method;
@@ -250,7 +252,7 @@
         u->method = u->conf->method;
     }
 
-    if (u->create_request(r) == NGX_ERROR) {
+    if (u->create_request(r) != NGX_OK) {
         ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
         return;
     }
@@ -615,9 +617,8 @@
         && !u->request_sent
         && c->write->pending_eof)
     {
-        ngx_log_error(NGX_LOG_ERR, c->log, c->write->kq_errno,
-                      "connect() failed");
-
+        (void) ngx_connection_error(c, c->write->kq_errno,
+                                    "kevent() reported that connect() failed");
         ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
         return;
     }
@@ -716,12 +717,6 @@
         return;
     }
 
-    if (r->connection->write->eof && (!u->cachable || !u->request_sent)) {
-        ngx_http_upstream_finalize_request(r, u,
-                                           NGX_HTTP_INTERNAL_SERVER_ERROR);
-        return;
-    }
-
     ngx_http_upstream_send_request(r, u);
 }
 
@@ -1788,6 +1783,7 @@
 ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, size_t len)
 {
     u_char                 *p;
+    ngx_str_t               line;
     uintptr_t               escape;
     ngx_http_upstream_t    *u;
     ngx_peer_connection_t  *peer;
@@ -1824,32 +1820,34 @@
             buf += r->uri.len - u->conf->location->len + escape;
             len -= r->uri.len - u->conf->location->len + escape;
 
-            if (r->args.len) {
-                p = ngx_snprintf(buf, len, "?%V", &r->args);
-                len -= p - buf;
-                buf = p;
+        } else {
+            p = ngx_palloc(r->pool,
+                           r->uri.len - u->conf->location->len + escape);
+            if (p == NULL) {
+                return buf;
             }
 
-            return ngx_http_log_error_info(r, buf, len);
+            ngx_escape_uri(p, r->uri.data + u->conf->location->len,
+                           r->uri.len - u->conf->location->len, NGX_ESCAPE_URI);
+
+            line.len = len;
+            line.data = p;
+
+            return ngx_snprintf(buf, len, "%V", &line);
         }
 
-        p = ngx_palloc(r->pool, r->uri.len - u->conf->location->len + escape);
-        if (p == NULL) {
-            return buf;
-        }
-
-        ngx_escape_uri(p, r->uri.data + u->conf->location->len,
-                       r->uri.len - u->conf->location->len, NGX_ESCAPE_URI);
-
-        p = ngx_cpymem(buf, p, r->uri.len - u->conf->location->len + escape);
-
     } else {
-        p = ngx_cpymem(buf, r->uri.data + u->conf->location->len,
-                       r->uri.len - u->conf->location->len);
-    }
+        line.len = r->uri.len - u->conf->location->len;
+        if (line.len > len) {
+            line.len = len;
+        }
 
-    len -= p - buf;
-    buf = p;
+        line.data = r->uri.data + u->conf->location->len;
+        p = ngx_snprintf(buf, len, "%V", &line);
+
+        len -= p - buf;
+        buf = p;
+    }
 
     if (r->args.len) {
         p = ngx_snprintf(buf, len, "?%V", &r->args);