You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by do...@apache.org on 2002/06/21 05:02:54 UTC

cvs commit: modperl-2.0/src/modules/perl modperl_interp.c modperl_interp.h modperl_tipool.c modperl_tipool.h modperl_types.h

dougm       2002/06/20 20:02:54

  Modified:    src/modules/perl modperl_interp.c modperl_interp.h
                        modperl_tipool.c modperl_tipool.h modperl_types.h
  Log:
  stop using an apr_pool_t to allocate items for the interpreter pool:
  -even though we lock, the pool is read by modules other than mod_perl
  -when a PerlInterpreter is released to to PerlInterp{MaxRequests,MinSpare}
  the pool item allocation "leaks" because the server pool is not
  cleared until restart
  
  Revision  Changes    Path
  1.48      +9 -7      modperl-2.0/src/modules/perl/modperl_interp.c
  
  Index: modperl_interp.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_interp.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- modperl_interp.c	21 Jun 2002 00:44:24 -0000	1.47
  +++ modperl_interp.c	21 Jun 2002 03:02:54 -0000	1.48
  @@ -35,14 +35,15 @@
       modperl_xs_dl_handles_clear(aTHX);
   }
   
  -modperl_interp_t *modperl_interp_new(apr_pool_t *p,
  -                                     modperl_interp_pool_t *mip,
  +modperl_interp_t *modperl_interp_new(modperl_interp_pool_t *mip,
                                        PerlInterpreter *perl)
   {
       UV clone_flags = 0;
       modperl_interp_t *interp = 
  -        (modperl_interp_t *)apr_pcalloc(p, sizeof(*interp));
  -    
  +        (modperl_interp_t *)malloc(sizeof(*interp));
  +
  +    memset(interp, '\0', sizeof(*interp));
  +
       interp->mip = mip;
       interp->refcnt = 0; /* for use by APR::Pool->cleanup_register */
   
  @@ -97,6 +98,8 @@
       modperl_perl_destruct(interp->perl);
   
       modperl_xs_dl_handles_close(handles);
  +
  +    free(interp);
   }
   
   apr_status_t modperl_interp_cleanup(void *data)
  @@ -162,7 +165,7 @@
   {
       modperl_interp_pool_t *mip = (modperl_interp_pool_t *)data;
       MP_TRACE_i(MP_FUNC, "adding new interpreter to the pool\n");
  -    return (void *)modperl_interp_new(mip->ap_pool, mip, mip->parent->perl);
  +    return (void *)modperl_interp_new(mip, mip->parent->perl);
   }
   
   static void interp_pool_shrink(modperl_tipool_t *tipool, void *data,
  @@ -206,9 +209,8 @@
                              &interp_pool_func, mip);
   
       mip->tipool = tipool;
  -    mip->ap_pool = p;
       mip->server  = s;
  -    mip->parent = modperl_interp_new(p, mip, NULL);
  +    mip->parent = modperl_interp_new(mip, NULL);
       aTHX = mip->parent->perl = perl;
       
       /* this happens post-config in mod_perl.c:modperl_init_clones() */
  
  
  
  1.16      +1 -2      modperl-2.0/src/modules/perl/modperl_interp.h
  
  Index: modperl_interp.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_interp.h,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- modperl_interp.h	13 Jun 2002 02:59:05 -0000	1.15
  +++ modperl_interp.h	21 Jun 2002 03:02:54 -0000	1.16
  @@ -23,8 +23,7 @@
   
   void modperl_interp_clone_init(modperl_interp_t *interp);
   
  -modperl_interp_t *modperl_interp_new(apr_pool_t *p,
  -                                     modperl_interp_pool_t *mip,
  +modperl_interp_t *modperl_interp_new(modperl_interp_pool_t *mip,
                                        PerlInterpreter *perl);
   
   void modperl_interp_destroy(modperl_interp_t *interp);
  
  
  
  1.8       +6 -4      modperl-2.0/src/modules/perl/modperl_tipool.c
  
  Index: modperl_tipool.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_tipool.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- modperl_tipool.c	8 Mar 2002 02:48:01 -0000	1.7
  +++ modperl_tipool.c	21 Jun 2002 03:02:54 -0000	1.8
  @@ -15,10 +15,11 @@
    * this is another "proof-of-concept", plenty of room for improvement here
    */
   
  -modperl_list_t *modperl_list_new(apr_pool_t *p)
  +modperl_list_t *modperl_list_new()
   {
       modperl_list_t *listp = 
  -        (modperl_list_t *)apr_pcalloc(p, sizeof(*listp));
  +        (modperl_list_t *)malloc(sizeof(*listp));
  +    memset(listp, '\0', sizeof(*listp));
       return listp;
   }
   
  @@ -151,7 +152,6 @@
       modperl_tipool_t *tipool =
           (modperl_tipool_t *)apr_pcalloc(p, sizeof(*tipool));
   
  -    tipool->ap_pool = p;
       tipool->cfg = cfg;
       tipool->func = func;
       tipool->data = data;
  @@ -201,7 +201,7 @@
   
   void modperl_tipool_add(modperl_tipool_t *tipool, void *data)
   {
  -    modperl_list_t *listp = modperl_list_new(tipool->ap_pool);
  +    modperl_list_t *listp = modperl_list_new();
   
       listp->data = data;
   
  @@ -339,6 +339,8 @@
               (*tipool->func->tipool_destroy)(tipool, tipool->data,
                                               listp->data);
           }
  +
  +        free(listp); /* gone for good */
   
           if (max_requests && ((tipool->size - tipool->in_use) <
                                tipool->cfg->min_spare)) {
  
  
  
  1.6       +1 -1      modperl-2.0/src/modules/perl/modperl_tipool.h
  
  Index: modperl_tipool.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_tipool.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- modperl_tipool.h	14 Aug 2000 03:10:45 -0000	1.5
  +++ modperl_tipool.h	21 Jun 2002 03:02:54 -0000	1.6
  @@ -3,7 +3,7 @@
   
   #ifdef USE_ITHREADS
   
  -modperl_list_t *modperl_list_new(apr_pool_t *p);
  +modperl_list_t *modperl_list_new(void);
   
   modperl_list_t *modperl_list_last(modperl_list_t *list);
   
  
  
  
  1.59      +0 -2      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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- modperl_types.h	13 Jun 2002 02:59:05 -0000	1.58
  +++ modperl_types.h	21 Jun 2002 03:02:54 -0000	1.59
  @@ -74,7 +74,6 @@
   struct modperl_tipool_t {
       perl_mutex tiplock;
       perl_cond available;
  -    apr_pool_t *ap_pool;
       modperl_list_t *idle, *busy;
       int in_use; /* number of items currrently in use */
       int size; /* current number of items */
  @@ -84,7 +83,6 @@
   };
   
   struct modperl_interp_pool_t {
  -    apr_pool_t *ap_pool;
       server_rec *server;
       modperl_tipool_t *tipool;
       modperl_tipool_config_t *tipool_cfg;