# {"__PACKAGE__"} is mandatory for mod_perl-2.0;
# $Apache2::Registry::curstash is no longer supported.
do { cluck "No $_" if !$W->{$_}; } for "__PACKAGE__";
+ exit_hook_start();
# See: &escapeHTML
do { cluck "charset==$_, expecting ISO-8859-1" if $_ ne "ISO-8859-1"; } for CGI::charset();
# PerlResponseHandler is RUN_FIRST and &ModPerl::Util::exit returns OK, so no (sane) go.
# PerlLogHandler is already too late to be able to produce any output.
-my $exit_orig=\&CORE::GLOBAL::exit;
+my $exit_orig;
sub exit_hook
{
# &footer will call us recursively!
footer() if !$W->{"_exit_ran"}++;
return &{$exit_orig}(@_);
}
+sub exit_hook_start
{
+ cluck "exit_hook_start() twice?" if defined $exit_orig;
+ $exit_orig=\&CORE::GLOBAL::exit;
# Prevent: Subroutine CORE::GLOBAL::exit redefined
no warnings 'redefine';
*CORE::GLOBAL::exit=\&exit_hook;
- }
+}
+sub exit_hook_stop
+{
+ do { cluck "exit_hook_stop() without exit_hook_start()?"; return; }
+ if \&exit_hook ne \&CORE::GLOBAL::exit;
+ cluck "INTERNAL: exit_orig uninitialized" if !$exit_orig;
+ *CORE::GLOBAL::exit=$exit_orig;
+ $exit_orig=undef();
+}
# Be aware other parts of code (non-My::Web) will NOT use this function!
# Do not: Wprint $W->{"heading"},"undef"=>1;
sub footer()
{
+ exit_hook_stop();
cluck 'Explicit &footer call is deprecated' if !$W->{"_exit_ran"};
exit if $W->{"footer_passed"}++; # deadlock prevention:
if ($W->{"header_only"}) {