You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2008/10/22 21:13:57 UTC
svn commit: r707163 - /httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
Author: jim
Date: Wed Oct 22 12:13:57 2008
New Revision: 707163
URL: http://svn.apache.org/viewvc?rev=707163&view=rev
Log:
Remove potential for memory leak... allocate on this
request which is now viable due to connection pooling.
Modified:
httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_http.c?rev=707163&r1=707162&r2=707163&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_http.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_http.c Wed Oct 22 12:13:57 2008
@@ -1869,23 +1869,13 @@
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, ':');
@@ -1893,7 +1883,7 @@
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? */