Return-Path: Delivered-To: apmail-perl-dev-archive@www.apache.org Received: (qmail 15320 invoked from network); 18 Dec 2004 04:05:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 18 Dec 2004 04:05:42 -0000 Received: (qmail 6884 invoked by uid 500); 18 Dec 2004 04:05:40 -0000 Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 6873 invoked by uid 500); 18 Dec 2004 04:05:40 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 6853 invoked by uid 99); 18 Dec 2004 04:05:40 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail.logilune.com (HELO mail.logilune.com) (195.80.154.36) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 17 Dec 2004 20:05:37 -0800 Received: from [127.0.0.1] (localhost.logilune.com [127.0.0.1]) by mail.logilune.com (Postfix) with ESMTP id 171B41E1CE9; Sat, 18 Dec 2004 05:05:33 +0100 (CET) Message-ID: <41C3AC8D.3010201@stason.org> Date: Fri, 17 Dec 2004 23:05:33 -0500 From: Stas Bekman Organization: Hope, Humanized User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 X-Accept-Language: en-us, en, he, ru MIME-Version: 1.0 To: Joe Schaefer Cc: dev@perl.apache.org Subject: Re: [mp2] pools that go out of scope aren't a problem anymore? References: <41A60A95.6010904@stason.org> <87fz2x4qu0.fsf@gemini.sunstarsys.com> <41A6411A.3010308@stason.org> <878y8p4p2n.fsf@gemini.sunstarsys.com> <41A66AEA.6090101@stason.org> <41A7A73C.8020701@stason.org> <41A7C343.4010703@stason.org> <41A8C0FE.7020905@stason.org> <41C392C3.60802@stason.org> <878y7wl1n0.fsf@gemini.sunstarsys.com> In-Reply-To: <878y7wl1n0.fsf@gemini.sunstarsys.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Joe Schaefer wrote: > Stas Bekman writes: > > >>>+static MP_INLINE SV *mpxs_APR__Table_make(pTHX_ SV *p_sv, int nelts) >>>+{ >>>+ apr_pool_t *p = mp_xs_sv2_APR__Pool(p_sv); >>>+ apr_table_t *t = apr_table_make(p, nelts); >>>+ SV *t_sv = modperl_hash_tie(aTHX_ "APR::Table", Nullsv, t); >>>+ sv_magic(SvRV(t_sv), p_sv, PERL_MAGIC_ext, Nullch, -1); >>>+ return t_sv; >>>+} >> >>And that just happened to work, since it wasn't 5.8.x+ >> >>sv_magic(SvRV(t_sv), p_sv, PERL_MAGIC_ext, Nullch, -1); >> >>can't be used since it's already used by: >> >>MP_INLINE SV *modperl_hash_tie(pTHX_ >>[...] >> >> /* Prefetch magic requires perl 5.8 */ >>#if ((PERL_REVISION == 5) && (PERL_VERSION >= 8)) >> >> sv_magic(hv, NULL, PERL_MAGIC_ext, Nullch, -1); >> SvMAGIC(hv)->mg_virtual = (MGVTBL *)&modperl_table_magic_prefetch; >> SvMAGIC(hv)->mg_flags |= MGf_COPY; >> >>#endif /* End of prefetch magic */ >> >> sv_magic(hv, rsv, PERL_MAGIC_tied, Nullch, 0); >> >>so it happened to worked before I guess because I was testing with 5.6.x, >> >>with 5.8.x, if I dump the table object it has only one _ext magic. >> >>so we need to use some other magic to create this dependency. > > > You probably just need to use sv_magicext with 5.8.x, because > sv_magic doesn't seem to permit duplicates. The only issue > then is ordering: you want the mpxs_APR__Table_make one further > down the SvMAGIC chain than the modperl_hash_tie one. joe++, it works. but man, talking about automating this kind of wrappers... here is the partial patch with tweaks suggested from Joe: in fact the only reason modperl_hash_tie calls sv_magic is to assign some flags, may be it can be eliminated completely. I haven't looked at the other places where it is used. Why do you think the order matters, if it doesn't really use that magic via mg_find. Index: src/modules/perl/modperl_common_util.c =================================================================== --- src/modules/perl/modperl_common_util.c (revision 122696) +++ src/modules/perl/modperl_common_util.c (working copy) @@ -69,7 +69,7 @@ /* Prefetch magic requires perl 5.8 */ #if ((PERL_REVISION == 5) && (PERL_VERSION >= 8)) - sv_magic(hv, NULL, PERL_MAGIC_ext, Nullch, -1); + sv_magicext(hv, NULL, PERL_MAGIC_ext, NULL, Nullch, -1); SvMAGIC(hv)->mg_virtual = (MGVTBL *)&modperl_table_magic_prefetch; SvMAGIC(hv)->mg_flags |= MGf_COPY; Index: xs/APR/Table/APR__Table.h =================================================================== --- xs/APR/Table/APR__Table.h (revision 122696) +++ xs/APR/Table/APR__Table.h (working copy) @@ -17,6 +17,22 @@ #define mpxs_APR__Table_DELETE apr_table_unset #define mpxs_APR__Table_CLEAR apr_table_clear +static MP_INLINE SV *mpxs_APR__Table_make(pTHX_ SV *p_sv, int nelts) +{ + apr_pool_t *p = mp_xs_sv2_APR__Pool(p_sv); + apr_table_t *t = apr_table_make(p, nelts); + SV *t_sv = modperl_hash_tie(aTHX_ "APR::Table", Nullsv, t); + sv_dump(SvRV(p_sv)); + /* XXX: this seems to be ignored by perl 5.8.x+, since + * modperl_hash_tie already attached another _ext magic */ +#if ((PERL_REVISION == 5) && (PERL_VERSION >= 8)) + sv_magicext(SvRV(t_sv), p_sv, PERL_MAGIC_ext, NULL, Nullch, -1); +#else + sv_magic(SvRV(t_sv), p_sv, PERL_MAGIC_ext, Nullch, -1); +#endif + return t_sv; +} + typedef struct { SV *cv; apr_hash_t *filter; -- __________________________________________________________________ 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