On 06/27/2017 07:28 AM, j...@apache.org wrote:
Author: jim
Date: Tue Jun 27 14:28:50 2017
New Revision: 1800066
URL: http://svn.apache.org/viewvc?rev=1800066&view=rev
Log:
Re-use the runner sub function...
Modified:
httpd/test/framework/trunk/Misc.pm
httpd/test/framework/trunk/t/modules/proxy_fcgi.t
Modified: httpd/test/framework/trunk/Misc.pm
URL:
http://svn.apache.org/viewvc/httpd/test/framework/trunk/Misc.pm?rev=1800066&r1=1800065&r2=1800066&view=diff
==============================================================================
--- httpd/test/framework/trunk/Misc.pm (original)
+++ httpd/test/framework/trunk/Misc.pm Tue Jun 27 14:28:50 2017
@@ -28,7 +28,7 @@ BEGIN {
# Just a bunch of useful subs
}
-sub do_do_run_run ($$)
+sub do_do_run_run
{
my $msg = shift;
my $func = shift;
@@ -43,7 +43,7 @@ sub do_do_run_run ($$)
if ($pid == 0) {
print WRITE_END 'x';
close WRITE_END;
- $func->();
+ $func->(@_);
exit;
}
# give time for the system call to take effect
@@ -53,6 +53,7 @@ sub do_do_run_run ($$)
kill 'TERM', $pid;
exit;
}
+ return $pid;
}
Modified: httpd/test/framework/trunk/t/modules/proxy_fcgi.t
URL:
http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/proxy_fcgi.t?rev=1800066&r1=1800065&r2=1800066&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/modules/proxy_fcgi.t (original)
+++ httpd/test/framework/trunk/t/modules/proxy_fcgi.t Tue Jun 27 14:28:50 2017
@@ -5,6 +5,8 @@ use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;
+use Misc;
+
my $have_fcgisetenvif = have_min_apache_version('2.4.26');
my $have_fcgibackendtype = have_min_apache_version('2.4.26');
@@ -24,60 +26,32 @@ Apache::TestRequest::module("proxy_fcgi"
# Launches a short-lived FCGI daemon that will handle exactly one request with
# the given handler function. Returns the child PID; exits on failure.
-sub run_fcgi_handler($$)
+
+sub fcgi_request
{
my $fcgi_port = shift;
my $handler_func = shift;
- # Use a pipe for ready-signalling between the child and parent. Much faster
- # (and more reliable) than just sleeping for a few seconds.
- pipe(READ_END, WRITE_END);
- my $pid = fork();
-
- unless (defined $pid) {
- t_debug "couldn't fork FCGI process";
- ok 0;
- exit;
- }
+ # Child process. Open up a listening socket.
+ my $sock = FCGI::OpenSocket(":$fcgi_port", 10);
- if ($pid == 0) {
- # Child process. Open up a listening socket.
- my $sock = FCGI::OpenSocket(":$fcgi_port", 10);
-
- # Signal the parent process that we're ready.
- print WRITE_END 'x';
- close WRITE_END;
This isn't an equivalent transformation. It's important that the socket
is opened *before* signaling the parent; otherwise there's a race and
the parent might try to ping the child before it's ready.
--Jacob