]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r707163 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 11 Nov 2008 20:00:10 +0000 (20:00 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 11 Nov 2008 20:00:10 +0000 (20:00 +0000)
Remove potential for memory leak... allocate on this
request which is now viable due to connection pooling.

Reviewed by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@713143 13f79535-47bb-0310-9956-ffa450edef68

STATUS
modules/proxy/mod_proxy_http.c

diff --git a/STATUS b/STATUS
index adf7f35bf12b476c72e907907852a667aa9f204d..03eaeef3b3895b37f094d3fe8dbc054ef55b95ff 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -105,14 +105,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
         http://people.apache.org/~rpluem/patches/milli_seconds.diff
      +1: rpluem, pgollucci, jim
 
-   * mod_proxy: Remove potential for memory leak. Allocate from request
-     pool which is now viable due to connection pooling
-     Trunk version of patch:
-        http://svn.apache.org/viewcvs.cgi?rev=707163&view=rev
-     Backport version for 2.2.x of patch:
-        Trunk version of patch works
-     +1: rpluem, jim, pgollucci
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 9175baec65ff1e1ecdc2c4c35e931927b67f7052..3d002c9207b91bacab7ae5b1c47fea014d76ca33 100644 (file)
@@ -1872,23 +1872,13 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker,
     const char *u;
     proxy_conn_rec *backend = NULL;
     int is_ssl = 0;
-
-    /* Note: Memory pool allocation.
-     * A downstream keepalive connection is always connected to the existence
-     * (or not) of an upstream keepalive connection. If this is not done then
-     * load balancing against multiple backend servers breaks (one backend
-     * server ends up taking 100% of the load), and the risk is run of
-     * downstream keepalive connections being kept open unnecessarily. This
-     * keeps webservers busy and ties up resources.
-     *
-     * As a result, we allocate all sockets out of the upstream connection
-     * pool, and when we want to reuse a socket, we check first whether the
-     * connection ID of the current upstream connection is the same as that
-     * of the connection when the socket was opened.
-     */
-    apr_pool_t *p = r->connection->pool;
     conn_rec *c = r->connection;
-    apr_uri_t *uri = apr_palloc(r->connection->pool, sizeof(*uri));
+    /*
+     * Use a shorter-lived pool to reduce memory usage
+     * and avoid a memory leak
+     */
+    apr_pool_t *p = r->pool;
+    apr_uri_t *uri = apr_palloc(p, sizeof(*uri));
 
     /* find the scheme */
     u = strchr(url, ':');
@@ -1896,7 +1886,7 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker,
        return DECLINED;
     if ((u - url) > 14)
         return HTTP_BAD_REQUEST;
-    scheme = apr_pstrndup(c->pool, url, u - url);
+    scheme = apr_pstrndup(p, url, u - url);
     /* scheme is lowercase */
     ap_str_tolower(scheme);
     /* is it for us? */