perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0 Changes
Date Thu, 11 Dec 2003 07:35:10 GMT
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 <fred@taperfriendlymusic.org>]
   
  
  
  

Mime
View raw message