perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rolf Schaufelberger>
Subject register_cleanup
Date Wed, 12 Dec 2007 19:05:13 GMT

I'm on the way moving my app from mod_perl1 to mod_perl2.
The app is build with HTML::Mason an MasonX::WebApp.
Now I have a problem when trying to install a cleanup_handler.
My expectations are, that the funtcion I call returns to the browser and move 
some long time computing to a cleanup_handler.
The code I use (sample):

use APR::Pool (); 
sub cleanup { 
  my $arg = shift; 
  for (1 .. $arg->{cnt} ) { 
    print STDERR "$_ = ", $arg->{name}, "\n"; 
sub T_cleanup { 
  my $self= shift; 
 # either
  my $r = $self->{__apache_req__}; 
  $r->pool->cleanup_register (\&cleanup, {name=> 'test', cnt=>10}); 

# nor this works
#   my $p = APR::Pool->new();  
#  $p->cleanup_register (\&cleanup, {name=> 'test', cnt=>10}); 

So when I call my method T_cleanup, the redirect is done AFTER cleanup has 
counted down , i.e. after 10 seconds. I would expect that it returns at once, 
an cleanup starts working AFTER the redirect. 
The docs says, it would start the executen "after the pool goes out of scope", 
which should be after the request object gets detroyed. Right ? 

So what am I doing wrong ?

Rolf Schaufelberger

View raw message