Re: register_cleanup on mod_perl 2.0
Denis Banovic wrote: Hi! I've a script that looks like this: if ($runnung_on_mod_perl) { Apache-request-register_cleanup(\init_globals); } Under mod_perl 1.0 works fine with Apache::Registry. Can someone give me an Example how to make a register_cleanup with mod_perl 2? A copy-n-paste from Apache/compat.pm: sub register_cleanup { shift-pool-cleanup_register(@_); } if you use Apache::compat, your mp1 code will work under mp2 unmodified. __ Stas BekmanJAm_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
Re: register_cleanup on mod_perl 2.0
Stas Bekman wrote: Denis Banovic wrote: Hi! I've a script that looks like this: if ($runnung_on_mod_perl) { Apache-request-register_cleanup(\init_globals); } Under mod_perl 1.0 works fine with Apache::Registry. Can someone give me an Example how to make a register_cleanup with mod_perl 2? A copy-n-paste from Apache/compat.pm: sub register_cleanup { shift-pool-cleanup_register(@_); } if you use Apache::compat, your mp1 code will work under mp2 unmodified. And it is documented here: http://perl.apache.org/docs/2.0/user/compat/compat.html#C__r_E_gt_register_cleanup_ http://perl.apache.org/docs/2.0/user/compat/compat.html#C__s_E_gt_register_cleanup_ In the future please refer to the docs first, before asking on the list. __ Stas BekmanJAm_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
Re: register_cleanup
Denis Banovic wrote: Hi! I'm trying to migrate some stuff from mod_perl 1. I've read the tutorial on perl.apache.org but it didn't help. I've a perl script that looks like this: if ($runnung_on_mod_perl) { Apache-request-register_cleanup(\init_globals); } Under mod_perl 1.0 works fine with Apache::Registry. But I can't find out how to port this to mod_perl 2. I've tried to use Apache::compat(); but then I got another error from an Module we are using to cache the script's output: ModPerl::Registry: anonymous handlers not (yet) supported at... It's not an error in your code, anon callbacks aren't implemented yet. $self-{r}-push_handlers(PerlHandler = sub {$self-DESTROY}); that should be PerlCleanupHandler, btw. even though it doesn't work yet. 1) How to do a register_cleanup with mod_perl 2.0 ? If you are asking about requests cleanup it's one of these: sub my_cleanup {...} $r-pool-cleanup_register(\my_cleanup); $r-pool-cleanup_register('my_cleanup'); $r-pool-cleanup_register(sub {...}); # anon subs do work here! $r-push_handlers(PerlCleanupHandler = \my_cleanup); $r-push_handlers(PerlCleanupHandler = 'my_cleanup'); Also, your original 1.x code: if ($runnung_on_mod_perl) { Apache-request-register_cleanup(\init_globals); } should work unmodified, under Apache::compat. __ Stas BekmanJAm_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