exit_hook initialization is now &init-conditional.
authorshort <>
Thu, 22 Sep 2005 12:27:19 +0000 (12:27 +0000)
committershort <>
Thu, 22 Sep 2005 12:27:19 +0000 (12:27 +0000)
 - Untested the case when it is needed.

Web.pm

diff --git a/Web.pm b/Web.pm
index cabea9d..0419bc0 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -152,6 +152,7 @@ my($class,%args)=@_;
        # {"__PACKAGE__"} is mandatory for mod_perl-2.0;
        # $Apache2::Registry::curstash is no longer supported.
        do { cluck "No $_" if !$W->{$_}; } for "__PACKAGE__";
        # {"__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();
 
        # See: &escapeHTML
        do { cluck "charset==$_, expecting ISO-8859-1" if $_ ne "ISO-8859-1"; } for CGI::charset();
@@ -282,18 +283,29 @@ my($apache_request)=@_;
 
 # 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.
 
 # 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
 {
                # &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;
        # 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;
 
 # Be aware other parts of code (non-My::Web) will NOT use this function!
 # Do not: Wprint $W->{"heading"},"undef"=>1;
@@ -494,6 +506,7 @@ my($msg)=@_;
 
 sub footer()
 {
 
 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"}) {
        cluck 'Explicit &footer call is deprecated' if !$W->{"_exit_ran"};
        exit if $W->{"footer_passed"}++;        # deadlock prevention:
        if ($W->{"header_only"}) {