APR::Pool: - mpxs_apr_pool_create (not sure about this one)
Joe, any ideas how to solve this tricky one? This is the APR::Pool->new itself, when called as $p->new:
Index: xs/APR/Pool/APR__Pool.h =================================================================== --- xs/APR/Pool/APR__Pool.h (revision 123255) +++ xs/APR/Pool/APR__Pool.h (working copy) @@ -106,7 +106,7 @@
/* XXX: should we make it a new global tracing category * MOD_PERL_TRACE=p for tracing pool management? */ -#define MP_POOL_TRACE_DO 0 +#define MP_POOL_TRACE_DO 1
#if MP_POOL_TRACE_DO && defined(MP_TRACE)
#define MP_POOL_TRACE modperl_trace
@@ -198,6 +198,10 @@
MP_POOL_TRACE(MP_FUNC, "sub-pool p: 0x%lx, sv: 0x%lx, rv: 0x%lx",
(unsigned long)child_pool, sv, rv);+ if (parent_pool) {
+ mpxs_add_pool_magic(rv, parent_pool_obj);
+ }
+
return rv;
}
}
Index: t/lib/TestAPRlib/pool.pm
===================================================================
--- t/lib/TestAPRlib/pool.pm (revision 123255)
+++ t/lib/TestAPRlib/pool.pm (working copy)
@@ -11,7 +11,7 @@
use APR::Table (); sub num_of_tests {
- return 74;
+ return 75;
} sub test {
@@ -387,9 +387,13 @@
ok 1;
}+ # out-of-scope pools
+ {
+ my $sp = APR::Pool->new->new;
+ # the parent temp pool must stick around
+ ok t_cmp(1, ancestry_count($sp), "parent pool is still alive");
+ }-
-
# other stuff
{
my $p = APR::Pool->new;It doesn't quite work, since
1) APR::Pool already uses _ext magic (but we can't use: sv_magicext as it needs to work with 5.6.x).
2) even if I use sv_magicext it segfaults in mg_free in:
#define MP_APR_POOL_SV_DROPS_OWNERSHIP(acct) STMT_START { \
dTHXa(acct->perl); \
mg_free(acct->sv);ideas? Should we somehow integrate that object as an alternative to just hanging off a string magic in MP_APR_POOL_SV_TAKES_OWNERSHIP(acct_sv, pool)?
btw, this will be committed soon (but it's already used in the patch above)
Index: xs/modperl_xs_util.h
===================================================================
--- xs/modperl_xs_util.h (revision 123255)
+++ xs/modperl_xs_util.h (working copy)
@@ -104,4 +104,20 @@
MARK++; \
}+/* several methods need to ensure that the pool that they take as an + * object doesn't go out of scope before the object that they return, + * since if this happens, the data contained in the later object + * becomes corrupted. this macro is used in various xs files where + * it's needed */ +#if ((PERL_REVISION == 5) && (PERL_VERSION >= 8)) + /* modperl_hash_tie already attached another _ext magic under + * 5.8+, so must use sv_magicext to have two magics with the + * type */ +#define mpxs_add_pool_magic(obj, pool_obj) \ + sv_magicext(SvRV(obj), pool_obj, PERL_MAGIC_ext, NULL, Nullch, -1) +#else +#define mpxs_add_pool_magic(obj) \ + sv_magic(SvRV(obj), pool_obj, PERL_MAGIC_ext, Nullch, -1) +#endif + #endif /* MODPERL_XS_H */
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
