Hi folks.

I'm in the midst of porting a fairly large application over from
mod_perl 1 to mod_perl 2.0. The app I am currently working on runs as a
"perl-script" handler using PerlResponseHandler My::Package::Name under
mod_perl 2.

One situation I have is that I sometimes have to do a "long running
process" that may take up to 1-2 minutes to complete. Under MP1, I
registered a cleanup handler to do this, and sent the user to a "status"
page that would refresh every 5 seconds until the cleanup handler
finished and spit out the results (which the cleanup handler saved in
the db). Getting the cleanup registered and getting it to fire under
mod_perl 2 was simply a matter of changing $r->post_connection(sub { ...
}) to $r->pool->cleanup_register(sub { ... }). So far so good.

The problem with this is I an %ENV variable called "TEST_MODE", set at
startup time (from startup.pl) which enables certain behavior (e.g.:
allows fake credit card numbers, enables some extra logging statements
etc). mod_perl 2 unfortunately scrubs %ENV before my cleanup handler
gets called, so $ENV{TEST_MODE} is never set when the cleanup handler
runs. I don't really see any way to prevent this from happening from
what the docs say. If anyone has any ideas on how to prevent %ENV from
getting wiped before my cleanup handler fires, or has any suggestions
about how to do a "long running process" under mod_perl 2 while
preserving %ENV from the request, I'd love to hear them .

Thanks
Michael Schout