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/12/31 07:48:58 UTC
svn commit: r607687 - in /perl/modperl/trunk: Changes
t/filter/TestFilter/with_subrequest.pm t/filter/with_subrequest.t
xs/Apache2/SubRequest/Apache2__SubRequest.h
Author: gozer
Date: Sun Dec 30 22:48:57 2007
New Revision: 607687
URL: http://svn.apache.org/viewvc?rev=607687&view=rev
Log:
Fix a crash when running a sub-request from within a filter where
mod_perl was not the content handler.
Running modperl_wbucket_flush(rcfg->wbucket) before the subrequest
is run ensures we've flushed our own content handler if it has
any data in the pipeline. Problem was rcfg->wbucket will not be
set if we are not the content handler.
Solution is to avoid the flush in that particular case.
Added:
perl/modperl/trunk/t/filter/TestFilter/with_subrequest.pm
perl/modperl/trunk/t/filter/with_subrequest.t
Modified:
perl/modperl/trunk/Changes
perl/modperl/trunk/xs/Apache2/SubRequest/Apache2__SubRequest.h
Modified: perl/modperl/trunk/Changes
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/Changes?rev=607687&r1=607686&r2=607687&view=diff
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Sun Dec 30 22:48:57 2007
@@ -12,6 +12,9 @@
=item 2.0.4-dev
+Fix a crash when running a sub-request from within a filter where
+mod_perl was not the content handler. [Gozer]
+
Refactor tests to use keepalives instead of same_interp [Gozer, Phred]
Apache2::Reload has been moved to an externally maintained
Added: perl/modperl/trunk/t/filter/TestFilter/with_subrequest.pm
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/filter/TestFilter/with_subrequest.pm?rev=607687&view=auto
==============================================================================
--- perl/modperl/trunk/t/filter/TestFilter/with_subrequest.pm (added)
+++ perl/modperl/trunk/t/filter/TestFilter/with_subrequest.pm Sun Dec 30 22:48:57 2007
@@ -0,0 +1,38 @@
+package TestFilter::with_subrequest;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache2::Filter ();
+use Apache2::SubRequest ();
+
+use TestCommon::Utils;
+
+use Apache2::Const -compile => 'OK';
+
+sub handler {
+ my $f = shift;
+ my $r = $f->r;
+
+ my $subr;
+ while ($f->read(my $buffer, 1024)) {
+ $f->print(lc $buffer);
+ if (!$subr) {
+ $subr = $r->lookup_uri($r->uri);
+ my $rc = $subr->run;
+ }
+ }
+
+ Apache2::Const::OK;
+}
+
+1;
+__DATA__
+
+<Location /with_subrequest>
+ PerlOutputFilterHandler TestFilter::with_subrequest
+</Location>
+
+<IfModule mod_alias.c>
+ Alias /with_subrequest @top_dir@
+</IfModule>
Added: perl/modperl/trunk/t/filter/with_subrequest.t
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/filter/with_subrequest.t?rev=607687&view=auto
==============================================================================
--- perl/modperl/trunk/t/filter/with_subrequest.t (added)
+++ perl/modperl/trunk/t/filter/with_subrequest.t Sun Dec 30 22:48:57 2007
@@ -0,0 +1,13 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+
+plan tests => 1, need 'mod_alias';
+
+my $location = "/with_subrequest/Makefile";
+
+my $str = GET_BODY $location;
+
+ok $str !~ /[A-Z]/;
Modified: perl/modperl/trunk/xs/Apache2/SubRequest/Apache2__SubRequest.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/xs/Apache2/SubRequest/Apache2__SubRequest.h?rev=607687&r1=607686&r2=607687&view=diff
==============================================================================
--- perl/modperl/trunk/xs/Apache2/SubRequest/Apache2__SubRequest.h (original)
+++ perl/modperl/trunk/xs/Apache2/SubRequest/Apache2__SubRequest.h Sun Dec 30 22:48:57 2007
@@ -23,8 +23,10 @@
if (r->main) {
modperl_config_req_t *rcfg = modperl_config_req_get(r->main);
- MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, FALSE),
- "Apache2::SubRequest::run");
+ if (rcfg->wbucket) {
+ MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, FALSE),
+ "Apache2::SubRequest::run");
+ }
}
return ap_run_sub_req(r);