perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: cvs commit: modperl-2.0/t/response/TestAPR pool.pm
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/apr_functions.map
> ===================================================================
> RCS file: /home/cvspublic/modperl-2.0/xs/maps/apr_functions.map,v
> retrieving revision 1.57
> diff -u -r1.57 apr_functions.map
> --- xs/maps/apr_functions.map   4 Sep 2003 16:39:44 -0000       1.57
> +++ xs/maps/apr_functions.map   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_functions.map: apr_uuid_DESTROY

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message