httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1800066 - in /httpd/test/framework/trunk: Misc.pm t/modules/proxy_fcgi.t
Date Tue, 27 Jun 2017 14:28:50 GMT
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;
-
-        # Listen for and respond to exactly one request from the client.
-        my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
-                                    $sock, &FCGI::FAIL_ACCEPT_ON_INTR);
-
-        if ($request->Accept() == 0) {
-            # Run the handler.
-            $handler_func->();
-            $request->Finish();
-        }
-
-        # Clean up and exit.
-        FCGI::CloseSocket($sock);
-        exit;
+    # Listen for and respond to exactly one request from the client.
+    my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
+                                $sock, &FCGI::FAIL_ACCEPT_ON_INTR);
+
+    if ($request->Accept() == 0) {
+        # Run the handler.
+        $handler_func->(@_);
+        $request->Finish();
     }
 
-    # Parent process. Wait for the daemon to launch.
-    unless (IO::Select->new((\*READ_END,))->can_read(2)) {
-        t_debug "timed out waiting for FCGI process to start";
-        ok 0;
-
-        kill 'TERM', $pid;
-        # Note that we don't waitpid() here because Perl's fork() implementation
-        # on some platforms (Windows) doesn't guarantee that the pseudo-TERM
-        # signal will be delivered. Just wait for the child to be cleaned up
-        # when we exit.
-
-        exit;
-    }
+    # Clean up and exit.
+    FCGI::CloseSocket($sock);
+}
 
-    return $pid;
+sub run_fcgi_handler
+{
+    return Misc::do_do_run_run("FCGI process", \&fcgi_request, @_);
 }
 
 # Convenience wrapper for run_fcgi_handler() that will echo back the envvars in



Mime
View raw message