You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by go...@apache.org on 2007/11/13 19:51:55 UTC

svn commit: r594609 - in /perl/modperl/branches/threading: Changes src/modules/perl/mod_perl.c src/modules/perl/modperl_callback.c t/directive/perlcleanuphandler.t t/response/TestDirective/perlcleanuphandler.pm

Author: gozer
Date: Tue Nov 13 10:51:55 2007
New Revision: 594609

URL: http://svn.apache.org/viewvc?rev=594609&view=rev
Log:
Now correctly invokes PerlCleanupHandlers, even if they are the only 
handler type configured for that request

Reviewed-By: gozer
Submitted-By: Torsten Foertsch <to...@gmx.net>
Message-Id: <20...@gmx.net>


Added:
    perl/modperl/branches/threading/t/directive/perlcleanuphandler.t
    perl/modperl/branches/threading/t/response/TestDirective/perlcleanuphandler.pm
Modified:
    perl/modperl/branches/threading/Changes
    perl/modperl/branches/threading/src/modules/perl/mod_perl.c
    perl/modperl/branches/threading/src/modules/perl/modperl_callback.c

Modified: perl/modperl/branches/threading/Changes
URL: http://svn.apache.org/viewvc/perl/modperl/branches/threading/Changes?rev=594609&r1=594608&r2=594609&view=diff
==============================================================================
--- perl/modperl/branches/threading/Changes (original)
+++ perl/modperl/branches/threading/Changes Tue Nov 13 10:51:55 2007
@@ -12,6 +12,9 @@
 
 =item 2.0.4-dev
 
+Now correctly invokes PerlCleanupHandlers, even if they are the only
+handler type configured for that request [Torsten Foertsch]
+
 For threaded MPMs, change interpreter managment to a new, reference-counted
 allocation model. [Torsten Foertsch]
 

Modified: perl/modperl/branches/threading/src/modules/perl/mod_perl.c
URL: http://svn.apache.org/viewvc/perl/modperl/branches/threading/src/modules/perl/mod_perl.c?rev=594609&r1=594608&r2=594609&view=diff
==============================================================================
--- perl/modperl/branches/threading/src/modules/perl/mod_perl.c (original)
+++ perl/modperl/branches/threading/src/modules/perl/mod_perl.c Tue Nov 13 10:51:55 2007
@@ -746,6 +746,7 @@
 #endif
 
     modperl_config_req_init(r, rcfg);
+    modperl_config_req_cleanup_register(r, rcfg);
 
     /* set the default for cgi header parsing On as early as possible
      * so $r->content_type in any phase after header_parser could turn

Modified: perl/modperl/branches/threading/src/modules/perl/modperl_callback.c
URL: http://svn.apache.org/viewvc/perl/modperl/branches/threading/src/modules/perl/modperl_callback.c?rev=594609&r1=594608&r2=594609&view=diff
==============================================================================
--- perl/modperl/branches/threading/src/modules/perl/modperl_callback.c (original)
+++ perl/modperl/branches/threading/src/modules/perl/modperl_callback.c Tue Nov 13 10:51:55 2007
@@ -201,14 +201,6 @@
     }
 #endif
 
-    /* XXX: would like to do this in modperl_hook_create_request()
-     * but modperl_interp_select() is what figures out if
-     * PerlInterpScope eq handler, in which case we do not register
-     * a cleanup.  modperl_hook_create_request() is also currently always
-     * run even if modperl isn't handling any part of the request
-     */
-    modperl_config_req_cleanup_register(r, rcfg);
-
     switch (type) {
       case MP_HANDLER_TYPE_PER_SRV:
         modperl_handler_make_args(aTHX_ &av_args,

Added: perl/modperl/branches/threading/t/directive/perlcleanuphandler.t
URL: http://svn.apache.org/viewvc/perl/modperl/branches/threading/t/directive/perlcleanuphandler.t?rev=594609&view=auto
==============================================================================
--- perl/modperl/branches/threading/t/directive/perlcleanuphandler.t (added)
+++ perl/modperl/branches/threading/t/directive/perlcleanuphandler.t Tue Nov 13 10:51:55 2007
@@ -0,0 +1,19 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest 'GET_BODY';
+
+plan tests => 3;
+
+my $module = 'TestDirective::perlcleanuphandler';
+
+Apache::TestRequest::user_agent(reset => 1, keep_alive=>1);
+sub u {Apache::TestRequest::module2url($module, {path=>$_[0]})}
+
+t_debug("connecting to ".u(''));
+ok t_cmp GET_BODY(u('/get?incr')), 'UNDEF', 'before increment';
+ok t_cmp GET_BODY(u('/get')), '1', 'incremented';
+(undef)=GET_BODY(u('/index.html?incr'));
+ok t_cmp GET_BODY(u('/get')), '2', 'incremented again';

Added: perl/modperl/branches/threading/t/response/TestDirective/perlcleanuphandler.pm
URL: http://svn.apache.org/viewvc/perl/modperl/branches/threading/t/response/TestDirective/perlcleanuphandler.pm?rev=594609&view=auto
==============================================================================
--- perl/modperl/branches/threading/t/response/TestDirective/perlcleanuphandler.pm (added)
+++ perl/modperl/branches/threading/t/response/TestDirective/perlcleanuphandler.pm Tue Nov 13 10:51:55 2007
@@ -0,0 +1,65 @@
+package TestDirective::perlcleanuphandler;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache2::RequestRec ();
+use Apache2::RequestIO ();
+use Apache2::RequestUtil ();
+use Apache2::Connection ();
+use Apache2::ConnectionUtil ();
+use Apache2::Const -compile => 'OK', 'DECLINED';
+
+# This test is to show an error that occurs if in the whole request cycle
+# only a PerlCleanupHandler is defined. In this case it is not called.
+# To check that "/get?incr" is called first. This returns "UNDEF" to the
+# browser and sets the counter to "1". Next "/get" is called again without
+# args to check the counter without increment. Then we fetch
+# "/index.html?incr". Here no other Perl*Handler save the PerlCleanupHandler
+# is involved. So the next "/get" must return "2" but it shows "1".
+
+sub cleanup {
+    my $r=shift;
+    $r->connection->pnotes->{counter}++ if( $r->args eq 'incr' );
+    return Apache2::Const::OK;
+}
+
+sub get {
+    my $r=shift;
+    $r->content_type('text/plain');
+    $r->print($r->connection->pnotes->{counter} || "UNDEF");
+    return Apache2::Const::OK;
+}
+
+1;
+
+__END__
+<VirtualHost TestDirective::perlcleanuphandler>
+
+    <IfDefine PERL_USEITHREADS>
+        # a new interpreter pool
+        PerlOptions +Parent
+        PerlInterpStart         1
+        PerlInterpMax           1
+        PerlInterpMinSpare      0
+        PerlInterpMaxSpare      1
+        PerlInterpScope         connection
+    </IfDefine>
+
+    KeepAlive On
+    KeepAliveTimeout 300
+    MaxKeepAliveRequests 100
+
+    # use test system's @INC
+    PerlSwitches -I@serverroot@
+    PerlRequire "conf/modperl_inc.pl"
+    PerlModule TestDirective::perlcleanuphandler
+
+    <Location /get>
+        SetHandler modperl
+        PerlResponseHandler TestDirective::perlcleanuphandler::get
+    </Location>
+
+    PerlCleanupHandler TestDirective::perlcleanuphandler::cleanup
+
+</VirtualHost>