perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r233275 - in /perl/modperl/trunk: Changes src/modules/perl/modperl_filter.c t/filter/TestFilter/in_str_declined_read.pm t/filter/in_str_declined_read.t
Date Thu, 18 Aug 2005 00:37:11 GMT
Author: stas
Date: Wed Aug 17 17:37:06 2005
New Revision: 233275

URL: http://svn.apache.org/viewcvs?rev=233275&view=rev
Log:
croak in case a filter returns DECLINED after calling $f->read (as it
is not supposed to happen)

Added:
    perl/modperl/trunk/t/filter/TestFilter/in_str_declined_read.pm   (with props)
    perl/modperl/trunk/t/filter/in_str_declined_read.t   (with props)
Modified:
    perl/modperl/trunk/Changes
    perl/modperl/trunk/src/modules/perl/modperl_filter.c

Modified: perl/modperl/trunk/Changes
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/Changes?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Wed Aug 17 17:37:06 2005
@@ -12,6 +12,9 @@
 
 =item 2.0.2-dev
 
+croak in case a filter returns DECLINED after calling $f->read (as it
+is not supposed to happen) [Stas]
+
 another round of cygwin fixes [Nick *** <doink123@abv.bg>]
 
 Multiple fixes to make mod_perl 2.0 work with blead-perl (5.9.3+)

Modified: perl/modperl/trunk/src/modules/perl/modperl_filter.c
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_filter.c?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_filter.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_filter.c Wed Aug 17 17:37:06 2005
@@ -544,6 +544,15 @@
 
     if (filter->mode == MP_INPUT_FILTER_MODE) {
         if (filter->bb_in) {
+            if (status == DECLINED) {
+                /* make sure the filter doesn't try to make mod_perl
+                 * pass the bucket brigade through after it called
+                 * $f->read(), since it causes a pre-fetch of the
+                 * bb */
+                modperl_croak(aTHX_ MODPERL_FILTER_ERROR,
+                              "a filter calling $f->read "
+                              "must return OK and not DECLINED");
+            }
             /* in the streaming mode filter->bb_in is populated on the
              * first modperl_input_filter_read, so it must be
              * destroyed at the end of the filter invocation

Added: perl/modperl/trunk/t/filter/TestFilter/in_str_declined_read.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/filter/TestFilter/in_str_declined_read.pm?rev=233275&view=auto
==============================================================================
--- perl/modperl/trunk/t/filter/TestFilter/in_str_declined_read.pm (added)
+++ perl/modperl/trunk/t/filter/TestFilter/in_str_declined_read.pm Wed Aug 17 17:37:06 2005
@@ -0,0 +1,51 @@
+package TestFilter::in_str_declined_read;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache2::RequestRec ();
+use Apache2::RequestIO ();
+
+use Apache2::Filter ();
+
+use TestCommon::Utils ();
+
+use Apache2::Const -compile => qw(OK DECLINED M_POST);
+
+# a filter must not return DECLINED after calling $r->read, since the
+# latter already fetches the bucket brigade in which case it's up to
+# the user to complete reading it and send it out
+# thefore this filter must fail
+sub handler {
+      my $filter = shift;
+
+      # this causes a fetch of bb
+      $filter->read(my $buffer, 10);
+
+      return Apache2::Const::DECLINED;
+}
+
+sub response {
+    my $r = shift;
+
+    plan $r, tests => 1;
+
+    $r->content_type('text/plain');
+
+    if ($r->method_number == Apache2::Const::M_POST) {
+        # this should fail, because of the failing filter
+        eval { TestCommon::Utils::read_post($r) };
+        ok $@;
+    }
+
+    Apache2::Const::OK;
+}
+1;
+__DATA__
+SetHandler modperl
+PerlModule          TestFilter::in_str_declined_read
+PerlResponseHandler TestFilter::in_str_declined_read::response
+

Propchange: perl/modperl/trunk/t/filter/TestFilter/in_str_declined_read.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Added: perl/modperl/trunk/t/filter/in_str_declined_read.t
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/filter/in_str_declined_read.t?rev=233275&view=auto
==============================================================================
--- perl/modperl/trunk/t/filter/in_str_declined_read.t (added)
+++ perl/modperl/trunk/t/filter/in_str_declined_read.t Wed Aug 17 17:37:06 2005
@@ -0,0 +1,11 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::TestRequest 'POST_BODY_ASSERT';;
+
+my $location = '/TestFilter__in_str_declined_read';
+
+my $chunk = "1234567890";
+my $data = $chunk x 2000;
+
+print POST_BODY_ASSERT $location, content => $data;

Propchange: perl/modperl/trunk/t/filter/in_str_declined_read.t
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message