Author: stevehay
Date: Thu Sep 11 07:46:40 2014
New Revision: 1624218

URL: http://svn.apache.org/r1624218
Log:
Don't answer anything to the client before it's done sending the POST data

LWP::Protocol::http sends long POST requests with several write() calls.
If it gets a response with a full HTTP header (up to the two newlines)
before it's done with the later write() calls sending the actual POST data,
it will stop writing. This leads to a deadlock and a test failure after
timeout.

The problem only shows up with large POSTED strings like the one in
read3.pm, but update read2.pm too for correctness.

Thread at
 
http://mail-archives.apache.org/mod_mbox/perl-dev/201408.mbox/%3C20140809104131.GA3670@estella.local.invalid%3E

Bug-Debian: https://bugs.debian.org/697682

Patch by Niko Tyni <nt...@debian.org>.

Modified:
    perl/modperl/trunk/t/response/TestApache/read2.pm
    perl/modperl/trunk/t/response/TestApache/read3.pm

Modified: perl/modperl/trunk/t/response/TestApache/read2.pm
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/t/response/TestApache/read2.pm?rev=1624218&r1=1624217&r2=1624218&view=diff
==============================================================================
--- perl/modperl/trunk/t/response/TestApache/read2.pm (original)
+++ perl/modperl/trunk/t/response/TestApache/read2.pm Thu Sep 11 07:46:40 2014
@@ -20,8 +20,6 @@ my $expected = "foobar";
 sub handler {
     my $r = shift;
 
-    plan $r, tests => 1;
-
     # test the case where the buffer to be filled has set magic
     # attached. which is the case when one passes an non-existing hash
     # entry value. it's not autovivified when passed to the function
@@ -30,6 +28,10 @@ sub handler {
     my $data;
     my $len = $r->read($data->{buffer}, $r->headers_in->{'Content-Length'});
 
+    # only print the plan out after reading to avoid chances of a deadlock
+    # see 
http://mail-archives.apache.org/mod_mbox/perl-dev/201408.mbox/%3C20140809104131.GA3670@estella.local.invalid%3E
+    plan $r, tests => 1;
+
     ok t_cmp($data->{buffer},
              $expected,
              "reading into an autovivified hash entry");

Modified: perl/modperl/trunk/t/response/TestApache/read3.pm
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/t/response/TestApache/read3.pm?rev=1624218&r1=1624217&r2=1624218&view=diff
==============================================================================
--- perl/modperl/trunk/t/response/TestApache/read3.pm (original)
+++ perl/modperl/trunk/t/response/TestApache/read3.pm Thu Sep 11 07:46:40 2014
@@ -20,8 +20,6 @@ my $expected = "foobar"x2000;
 sub handler {
     my $r = shift;
 
-    plan $r, tests => 1;
-
     # test to read data up to end of file is signaled
     my $data = '';
     my $where = 0;
@@ -31,6 +29,10 @@ sub handler {
         $where += $len;
     } while ($len > 0);
 
+    # only print the plan out after reading to avoid chances of a deadlock
+    # see 
http://mail-archives.apache.org/mod_mbox/perl-dev/201408.mbox/%3C20140809104131.GA3670@estella.local.invalid%3E
+    plan $r, tests => 1;
+
     ok t_cmp($data, $expected, "reading up to end of file");
 
     Apache2::Const::OK;


Reply via email to