perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: cvs commit: modperl-2.0/t/response/TestAPR
Date Fri, 05 Sep 2003 19:55:11 GMT
Geoffrey Young wrote:

>>> I fixed things so that DESTROY was available, but it caused all kinds 
>>> of problems with the test suite, so I'm guessing it's a good thing 
>>> that pools need to be explicitly destroyed.
>> what problems? 
> all kinds of problems.  like random modules in the test suite start to 
> fail or hang.  unless I got the fix wrong (below), but it was the only 
> way I could see to create the method, since the #define clearly isn't 
> working (which is interesting, since there are two other classes that 
> only use the alias as well).
>> it's just an object, I suppose that it should just work.
> well, maybe.  if we go destroying major pools (request, server) before 
> it's time that could be bad.  and if $r->pool is paired to an APR::Pool 
> object, and $r goes out of scope, that would call APR::Pool::DESTROY, 
> right?

OK, I see what kind of worms can it opens. r->pool is not an SV*, so it won't 
get destroyed by perl's DESTROY but by httpd internals at the end of the 
request. However if you do: my $r = $r->pool anywhere in the code, its 
reference count will be one, and it'll be DESTROYED at the end of the scope, 
messing things up.

So we want DESTROY to work for privately created pools, but not for internal 
pools, that gets tricky. One solution is to have APR::Pool::new() do something 
special to an SV that it creates, e.g. set some flag or attach magic. When 
DESTROY is called it should do its work only on those SVs marked as DESTROY-able.

> Index: xs/maps/
> ===================================================================
> RCS file: /home/cvspublic/modperl-2.0/xs/maps/,v
> retrieving revision 1.57
> diff -u -r1.57
> --- xs/maps/   4 Sep 2003 16:39:44 -0000       1.57
> +++ xs/maps/   5 Sep 2003 19:27:00 -0000
> @@ -155,6 +155,7 @@
>   apr_pool_clear
>  >apr_pool_clear_debug
>   apr_pool_destroy
> + apr_pool_DESTROY

Do you think it should be here, as there is no apr_pool_DESTROY function. I'd 
think that it should be in modperl_functions, but may be putting all related 
mappings together is better.

After all this is the same:

xs/maps/ apr_uuid_DESTROY

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message