stas 2003/12/13 15:40:31
Modified: src/modules/perl modperl_filter.c modperl_types.h . Changes Log: Postpone the allocation of the wbucket in filters till the moment it's needed (if at all). Since non-streaming filters aren't going to use that buffer, it's a waste to allocate/free it. Revision Changes Path 1.78 +27 -8 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.77 retrieving revision 1.78 diff -u -u -r1.77 -r1.78 --- modperl_filter.c 11 Dec 2003 07:38:41 -0000 1.77 +++ modperl_filter.c 13 Dec 2003 23:40:31 -0000 1.78 @@ -20,6 +20,25 @@ #define MP_FILTER_POOL(f) f->r ? f->r->pool : f->c->pool +/* allocate wbucket memory using malloc and not request pools, since + * we may need many of these if the filter is invoked multiple + * times */ +#define WBUCKET_INIT(wb, p, next_filter) \ + if (!wb) { \ + wb = (modperl_wbucket_t *)safemalloc(sizeof(*wb)); \ + wb->pool = p; \ + wb->filters = &next_filter; \ + wb->outcnt = 0; \ + wb->r = NULL; \ + wb->header_parse = 0; \ + } + +#define FILTER_FREE(filter) \ + if (filter->wbucket) { \ + safefree(filter->wbucket); \ + } \ + safefree(filter); + /* this function is for tracing only, it's not optimized for performance */ static int is_modperl_filter(ap_filter_t *f) { @@ -264,9 +283,7 @@ filter->mode = mode; filter->f = f; filter->pool = p; - filter->wbucket.pool = p; - filter->wbucket.filters = &f->next; - filter->wbucket.outcnt = 0; + filter->wbucket = NULL; if (mode == MP_INPUT_FILTER_MODE) { filter->bb_in = NULL; @@ -393,7 +410,7 @@ status = modperl_errsv(aTHX_ status, r, s); } - safefree(filter); + FILTER_FREE(filter); SvREFCNT_dec((SV*)args); MP_INTERP_PUTBACK(interp); @@ -739,7 +756,8 @@ filter->flush = 0; } - filter->rc = modperl_wbucket_flush(&filter->wbucket, add_flush_bucket); + WBUCKET_INIT(filter->wbucket, filter->pool, filter->f->next); + filter->rc = modperl_wbucket_flush(filter->wbucket, add_flush_bucket); if (filter->rc != APR_SUCCESS) { return filter->rc; } @@ -779,7 +797,8 @@ const char *buf, apr_size_t *len) { - return modperl_wbucket_write(aTHX_ &filter->wbucket, buf, len); + WBUCKET_INIT(filter->wbucket, filter->pool, filter->f->next); + return modperl_wbucket_write(aTHX_ filter->wbucket, buf, len); } apr_status_t modperl_output_filter_handler(ap_filter_t *f, @@ -800,7 +819,7 @@ filter = modperl_filter_new(f, bb, MP_OUTPUT_FILTER_MODE, 0, 0, 0); status = modperl_run_filter(filter); - safefree(filter); + FILTER_FREE(filter); } switch (status) { @@ -834,7 +853,7 @@ filter = modperl_filter_new(f, bb, MP_INPUT_FILTER_MODE, input_mode, block, readbytes); status = modperl_run_filter(filter); - safefree(filter); + FILTER_FREE(filter); } switch (status) { 1.70 +1 -1 modperl-2.0/src/modules/perl/modperl_types.h Index: modperl_types.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_types.h,v retrieving revision 1.69 retrieving revision 1.70 diff -u -u -r1.69 -r1.70 --- modperl_types.h 19 Aug 2003 05:01:22 -0000 1.69 +++ modperl_types.h 13 Dec 2003 23:40:31 -0000 1.70 @@ -193,7 +193,7 @@ ap_filter_t *f; char *leftover; apr_ssize_t remaining; - modperl_wbucket_t wbucket; + modperl_wbucket_t *wbucket; apr_bucket *bucket; apr_bucket_brigade *bb_in; apr_bucket_brigade *bb_out; 1.279 +4 -0 modperl-2.0/Changes Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.278 retrieving revision 1.279 diff -u -u -r1.278 -r1.279 --- Changes 12 Dec 2003 07:14:40 -0000 1.278 +++ Changes 13 Dec 2003 23:40:31 -0000 1.279 @@ -12,6 +12,10 @@ =item 1.99_12-dev +Postpone the allocation of the wbucket in filters till the moment it's +needed (if at all). Since non-streaming filters aren't going to use +that buffer, it's a waste to allocate/free it. [Stas] + Extend the autogenerated bug report to include information about installed modules of special interest (which may aid in understanding the bug report), such as CGI.pm, Apache::Request, LWP, etc. [Stas]