From dev-return-20784-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Fri Jul 18 23:09:38 2008 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 15612 invoked from network); 18 Jul 2008 23:09:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2008 23:09:38 -0000 Received: (qmail 57277 invoked by uid 500); 18 Jul 2008 23:09:37 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 57034 invoked by uid 500); 18 Jul 2008 23:09:36 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 57023 invoked by uid 99); 18 Jul 2008 23:09:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 16:09:36 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bojan@rexursive.com designates 203.171.74.242 as permitted sender) Received: from [203.171.74.242] (HELO beauty.rexursive.com) (203.171.74.242) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 23:08:43 +0000 Received: from [10.1.120.24] (shrek.rexursive.com [10.1.120.24]) by beauty.rexursive.com (Postfix) with ESMTP id 0A84D4C009C; Sat, 19 Jul 2008 09:08:36 +1000 (EST) Subject: Re: svn commit: r677505 - /apr/apr-util/trunk/misc/apr_reslist.c From: Bojan Smojver To: Mladen Turk Cc: dev@apr.apache.org In-Reply-To: <1216421945.2754.44.camel@shrek.rexursive.com> References: <20080717054557.AA2E02388A45@eris.apache.org> <20080717195057.213327svh8rbt1xc@www.rexursive.com> <487F1E0A.2040102@apache.org> <20080717212420.3879209jc5q4grmo@www.rexursive.com> <487F340D.8020600@apache.org> <1216344035.2754.11.camel@shrek.rexursive.com> <1216353712.2754.17.camel@shrek.rexursive.com> <48801B35.9090107@apache.org> <1216356687.2754.26.camel@shrek.rexursive.com> <1216360793.2754.29.camel@shrek.rexursive.com> <1216362614.2754.40.camel@shrek.rexursive.com> <1216375421.2754.42.camel@shrek.rexursive.com> <488071B1.5080205@apache.org> <1216421945.2754.44.camel@shrek.rexursive.com> Content-Type: multipart/mixed; boundary="=-0QYVT+BmCfl1uBjky6m8" Date: Sat, 19 Jul 2008 09:08:36 +1000 Message-Id: <1216422516.2754.47.camel@shrek.rexursive.com> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 (2.22.3.1-1.fc9) X-Virus-Checked: Checked by ClamAV on apache.org --=-0QYVT+BmCfl1uBjky6m8 Content-Type: text/plain Content-Transfer-Encoding: 7bit On Sat, 2008-07-19 at 08:59 +1000, Bojan Smojver wrote: > Does this solve it? Eh, sorry - not being careful enough with that cleanup registration. This should be better. -- Bojan --=-0QYVT+BmCfl1uBjky6m8 Content-Disposition: attachment; filename=apu-memcache-leak.patch Content-Type: text/x-patch; name=apu-memcache-leak.patch; charset=utf-8 Content-Transfer-Encoding: 7bit Index: memcache/apr_memcache.c =================================================================== --- memcache/apr_memcache.c (revision 677819) +++ memcache/apr_memcache.c (working copy) @@ -295,7 +295,15 @@ return rv; } +static apr_status_t conn_clean(void *data) +{ + apr_memcache_conn_t *conn = data; + conn->p = NULL; /* so that destructor does not destroy the pool again */ + + return APR_SUCCESS; +} + static apr_status_t mc_conn_construct(void **conn_, void *params, apr_pool_t *pool) { @@ -310,7 +318,7 @@ return rv; } - conn = apr_palloc(np, sizeof( apr_memcache_conn_t )); + conn = malloc(sizeof( apr_memcache_conn_t )); /* non-pool space! */ conn->p = np; @@ -334,8 +342,10 @@ rv = conn_connect(conn); if (rv != APR_SUCCESS) { apr_pool_destroy(np); + free(conn); } else { + apr_pool_cleanup_register(np, conn, conn_clean, apr_pool_cleanup_null); *conn_ = conn; } @@ -359,6 +369,12 @@ /* Return values not checked, since we just want to make it go away. */ apr_socket_sendv(conn->sock, vec, 2, &written); apr_socket_close(conn->sock); + + if (conn->p) { + apr_pool_destroy(conn->p); + } + + free(conn); /* free non-pool space */ return APR_SUCCESS; } --=-0QYVT+BmCfl1uBjky6m8--