Return-Path: Delivered-To: apmail-perl-modperl-cvs-archive@www.apache.org Received: (qmail 67507 invoked from network); 11 Dec 2003 07:35:10 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 11 Dec 2003 07:35:10 -0000 Received: (qmail 4049 invoked by uid 500); 11 Dec 2003 07:34:47 -0000 Delivered-To: apmail-perl-modperl-cvs-archive@perl.apache.org Received: (qmail 4035 invoked by uid 500); 11 Dec 2003 07:34:47 -0000 Mailing-List: contact modperl-cvs-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@perl.apache.org Delivered-To: mailing list modperl-cvs@perl.apache.org Received: (qmail 4022 invoked by uid 500); 11 Dec 2003 07:34:47 -0000 Delivered-To: apmail-modperl-2.0-cvs@apache.org Date: 11 Dec 2003 07:35:10 -0000 Message-ID: <20031211073510.67499.qmail@minotaur.apache.org> From: stas@apache.org To: modperl-2.0-cvs@apache.org Subject: cvs commit: modperl-2.0 Changes X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N stas 2003/12/10 23:35:09 Modified: src/modules/perl modperl_filter.c . Changes Log: use plain malloc/free to allocate filter structs, since they could be invoked hundreds of times during a single request, causing huge memory demands if the memory is allocated from the pool, which gets destroyed only at the end of a request. Revision Changes Path 1.76 +14 -3 modperl-2.0/src/modules/perl/modperl_filter.c Index: modperl_filter.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v retrieving revision 1.75 retrieving revision 1.76 diff -u -u -r1.75 -r1.76 --- modperl_filter.c 10 Dec 2003 01:46:28 -0000 1.75 +++ modperl_filter.c 11 Dec 2003 07:35:09 -0000 1.76 @@ -251,8 +251,16 @@ apr_read_type_e block, apr_off_t readbytes) { + apr_pool_t *p = MP_FILTER_POOL(f); - modperl_filter_t *filter = apr_pcalloc(p, sizeof(*filter)); + modperl_filter_t *filter; + + /* we can't allocate memory from the pool here, since potentially + * a filter can be called hundreds of times during the same + * request/connection resulting in enormous memory demands + * (sizeof(*filter)*number of invocations) + */ + Newz(0, filter, 1, modperl_filter_t); filter->mode = mode; filter->f = f; @@ -369,6 +377,7 @@ conn_rec *c = f->c; server_rec *s = r ? r->server : c->base_server; apr_pool_t *p = r ? r->pool : c->pool; + modperl_filter_t *filter = modperl_filter_new(f, NULL, mode, 0, 0, 0); MP_dINTERP_SELECT(r, c, s); @@ -378,14 +387,14 @@ "Apache::Filter", f, NULL); - modperl_filter_mg_set(aTHX_ AvARRAY(args)[0], - modperl_filter_new(f, NULL, mode, 0, 0, 0)); + modperl_filter_mg_set(aTHX_ AvARRAY(args)[0], filter); /* XXX filters are VOID handlers. should we ignore the status? */ if ((status = modperl_callback(aTHX_ handler, p, r, s, args)) != OK) { status = modperl_errsv(aTHX_ status, r, s); } + safefree(filter); SvREFCNT_dec((SV*)args); MP_INTERP_PUTBACK(interp); @@ -792,6 +801,7 @@ filter = modperl_filter_new(f, bb, MP_OUTPUT_FILTER_MODE, 0, 0, 0); status = modperl_run_filter(filter); + safefree(filter); } switch (status) { @@ -825,6 +835,7 @@ filter = modperl_filter_new(f, bb, MP_INPUT_FILTER_MODE, input_mode, block, readbytes); status = modperl_run_filter(filter); + safefree(filter); } switch (status) { 1.276 +5 -0 modperl-2.0/Changes Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.275 retrieving revision 1.276 diff -u -u -r1.275 -r1.276 --- Changes 10 Dec 2003 08:41:22 -0000 1.275 +++ Changes 11 Dec 2003 07:35:09 -0000 1.276 @@ -12,6 +12,11 @@ =item 1.99_12-dev +use plain malloc/free to allocate filter structs, since they could be +invoked hundreds of times during a single request, causing huge memory +demands if the memory is allocated from the pool, which gets destroyed +only at the end of a request. [Stas] + Fix a compilation error in APX.xs when MP_HAVE_APR_LIBS is not defined [Fred Moyer ]