]> granicus.if.org Git - apache/commitdiff
* Introduce environment variable proxy-initial-not-pooled to avoid reusing
authorRuediger Pluem <rpluem@apache.org>
Sat, 9 Aug 2008 21:33:09 +0000 (21:33 +0000)
committerRuediger Pluem <rpluem@apache.org>
Sat, 9 Aug 2008 21:33:09 +0000 (21:33 +0000)
  pooled connections if the client connection is an initial connection.
  This avoids the "proxy: error reading status line from remote server"
  error caused by the race condition that the backend server closed the
  connection after the connection check on our side and before our data
  reached the backend. Yes, this downgrades performance, especially with
  HTTP/1.0 clients. Hence it is configurable and off by default.

PR: 37770

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@684351 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/mod_proxy_http.c
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index c78b4e01f2d9ec7f01ce20a2157836b858c4c1fb..8764bddc03263bdb565791fc04c7af08471edc10 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) mod_proxy_http: Introduce environment variable proxy-initial-not-pooled to
+     avoid reusing pooled connections if the client connection is an initial
+     connection. PR 37770. [Ruediger Pluem]
+
   *) mod_proxy: Add connectiontimeout parameter for proxy workers in order to
      be able to set the timeout for connecting to the backend separately.
      PR 45445. [Ruediger Pluem, rahul <rahul sun.com>]
index c7be88ff715340fa9bf50d056f8d5fc85f9f26c4..4b9912844249f0ecb863be5f98f98faade9d8fc7 100644 (file)
@@ -1927,6 +1927,19 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker,
         ap_proxy_ssl_connection_cleanup(backend, r);
     }
 
+    /*
+     * In the case that we are handling a reverse proxy connection and this
+     * is not a request that is coming over an already kept alive connection
+     * with the client, do NOT reuse the connection to the backend, because
+     * we cannot forward a failure to the client in this case as the client
+     * does NOT expects this in this situation.
+     * Yes, this creates a performance penalty.
+     */
+    if ((r->proxyreq == PROXYREQ_REVERSE) && (!c->keepalives)
+        && (apr_table_get(r->subprocess_env, "proxy-initial-not-pooled"))) {
+        backend->close = 1;
+    }
+
     /* Step One: Determine Who To Connect To */
     if ((status = ap_proxy_determine_connection(p, r, conf, worker, backend,
                                                 uri, &url, proxyname,
index 2a55c5bcacd603bcc5c79f15d2a63188408a91aa..fd46206ebe37cb8f6b9b6cdf0c42fa8d16899424 100644 (file)
@@ -2167,6 +2167,11 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
     else {
         conn->addr = worker->cp->addr;
     }
+    /* Close a possible existing socket if we are told to do so */
+    if (conn->close) {
+        socket_cleanup(conn);
+        conn->close = 0;
+    }
 
     if (err != APR_SUCCESS) {
         return ap_proxyerror(r, HTTP_BAD_GATEWAY,