Author: stevehay
Date: Thu Feb  6 14:29:23 2014
New Revision: 1565275

URL: http://svn.apache.org/r1565275
Log:
Fix t/apache/subprocess.t on Windows, using httpd-2.4.x.

This test fails every time for me, but not with httpd-2.2.x, which I don't 
understand. Debugging, if you start up the server, then add a break point in 
APR's read_with_timeout() (in readwrite.c) and walk through the function each 
time it is hit then the test passes. Without debugging it puts a 
"APR::PerlIO::read: (70007) The timeout specified has expired" error in the 
error_log and fails all tests.

Presumably it is trying to read from the process spawned in subprocess.pm 
before the pipe is ready to be read from, and the delay in manually debugging 
fixes that. The comments in read_data() in subprocess.pm note that a delay is 
indeed required, and is achieved by select() in the non-PerlIO case (which I 
imagine nobody uses now anyway) or a apr_wait_for_io_or_timeout() call from 
apr_file_read() in the PerlIO case.

However, whilst that remark is true of the *nix implementation of 
apr_file_read() (in file_io/unix/readwrite.c), it is not true of the Win32 
version (in file_io/win32/readwrite.c).

Thus, adding a short sleep() fixes it on Win32. What I don't understand is why 
this wasn't necessary with httpd-2.2.x. The file_io/win32/readwrite.c file is 
identical in the two versions I'm using (httpd-2.4.6 vs httpd-2.2.25; apr-1.4.8 
in both).

Modified:
    perl/modperl/branches/httpd24threading/t/response/TestApache/subprocess.pm

Modified: 
perl/modperl/branches/httpd24threading/t/response/TestApache/subprocess.pm
URL: 
http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/t/response/TestApache/subprocess.pm?rev=1565275&r1=1565274&r2=1565275&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/t/response/TestApache/subprocess.pm 
(original)
+++ perl/modperl/branches/httpd24threading/t/response/TestApache/subprocess.pm 
Thu Feb  6 14:29:23 2014
@@ -149,18 +149,21 @@ sub read_data {
     #
     # PerlIO-based pipe fh on the other hand does the select
     # internally via apr_wait_for_io_or_timeout() in
-    # apr_file_read(). But you cannot call select() on the
+    # apr_file_read() (on *nix, but not on Win32).
+    # But you cannot call select() on the
     # PerlIO-based, because its fileno() returns (-1), remember that
     # apr_file_t is an opaque object, and on certain platforms
     # fileno() is different from unix
     #
     # so we use the following wrapper: if we are under perlio we just
-    # go ahead and read the data, if we are under non-perlio we first
+    # go ahead and read the data, but with a short sleep first on Win32;
+    # if we are under non-perlio we first
     # select for a few secs. (XXX: is 10 secs enough?)
     #
     # btw: we use perlIO only for perl 5.7+
     #
     if (APR::PerlIO::PERLIO_LAYERS_ARE_ENABLED() || $sel->can_read(10)) {
+        sleep(1) if $^O eq 'MSWin32' && 
APR::PerlIO::PERLIO_LAYERS_ARE_ENABLED();
         @data = wantarray ? (<$fh>) : <$fh>;
     }
 


Reply via email to