perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2] pool object dependant methods insanity
Date Mon, 27 Dec 2004 02:18:46 GMT
Joe Schaefer wrote:
> Stas Bekman <stas@stason.org> writes:
> 
> [...]
> 
> 
>>As most of the time internal mp magic doesn't use the mg_obj slot, I'm
>>trying to just to hang the pool object there. that will solve the problem of
>>double magic 
> 
> 
> +1- I used that fact in certain places within apreq2 to avoid it,
> so I think it can work.

Yes, it seems to work fine.

>>(I still can't figure how using perl public API one finds more than
>>one magic of the same type)
> 
> 
> You can't use mg_find, but you could walk the SvMAGIC linked-list
> manually (it's a public struct).  I think people used mg_ptr as
> a tag string to differentiate different ext-magics, but I have not
> actually seen it done in practice.

Manipulating internal structs manually sounds scary, but it's not the 
first time modperl does something like that. I just hoped that mg_find 
could be used to some iterate over magic chain.

>>and will save some memory too.
>>
>>#define mpxs_add_pool_magic(obj, pool_obj)                       \
>>     if (mpxs_pool_is_custom(SvRV(pool_obj))) {                   \
>>         MAGIC *mg = mg_find(SvRV(obj), PERL_MAGIC_ext);          \
>>         if (mg) {                                                \
>>             if (mg->mg_obj == Nullsv) {                          \
>>                 mg->mg_obj = SvREFCNT_inc(pool_obj);             \
>>                 mg->mg_flags |= MGf_REFCOUNTED;                  \
>>             }                                                    \
>>             else {                                               \
>>                 Perl_croak(aTHX_ "Fixme: don't know how to "     \
>>                            "handle non-Nullsv magic");           \
>>             }                                                    \
>>         }                                                        \
>>         else {                                                   \
>>             mpxs_add_pool_magic_doit(obj, pool_obj);             \
>>         }                                                        \
>>     }
> 
> 
> Looks good!

there was a buglet in it but now fixed.

I still have a problem with APR::Pool->new->new, trying to figure out how 
to hang APR::Pool magic on APR::Pool objects themselves. At the moment 
things crash badly, after mg_free call.

The only other remaining problem is the one with  $bucket->setaside($pool) 
  which I think has an implementation problem:
http://marc.theaimsgroup.com/?l=apache-modperl-dev&m=110391757729115&w=2
I'd like to hear your thoughts on that one, Joe.

-- 
__________________________________________________________________
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