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.
This case:
APR::Pool->new->new;
was really tricky, as we have a special tricky case here. We hang the parent object's pool on the child, and when the child is getting destroyed, the parent pool gets destroyed during mg_free, which internally (via libapr) nukes the child pool, but APR::Pool doesn't know about this (since it already verified that it has to free the child, but the rug was pulled after that) and contines freeing the child. So by manually unwinding the magic and postponing the moment the parent goes out of scope, this seems to work:
+#define MP_APR_POOL_SV_DROPS_OWNERSHIP_RUN(acct) STMT_START { \
+ MAGIC *mg = mg_find(acct->sv, PERL_MAGIC_ext); \
+ if (mg && mg->mg_obj) { \
+ sv_2mortal(mg->mg_obj); \
+ mg->mg_obj = Nullsv; \
+ mg->mg_flags &= ~MGf_REFCOUNTED; \
+ } \
+ mg_free(acct->sv); \
+ SvIVX(acct->sv) = 0; \
+} STMT_ENDThis APR::Pool is really a marvel of twisted logic, and is getting more and more complicated. It just shows how hard it is to mix two unrelated memory management systems.
-- __________________________________________________________________ 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]
