]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Close the accepted socket before creating the CGI process in mod_cgid.
authorRyan Bloom <rbb@apache.org>
Wed, 21 Feb 2001 19:07:21 +0000 (19:07 +0000)
committerRyan Bloom <rbb@apache.org>
Wed, 21 Feb 2001 19:07:21 +0000 (19:07 +0000)
This is safe, because we have already dup'ed the socket for the CGI
process itself.  This change allows CGI processes to fork long-lived
child processes without affecting how quickly the response gets back
to the broswer.

PR: 7273
Submitted by: Taketo Kabe <kabe@sra-tohoku.co.jp>
Reviewed by: Ryan Bloom

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88264 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/generators/mod_cgid.c

diff --git a/CHANGES b/CHANGES
index 5cc1e4ea5dc31e85ed34e613f0e102d8a83a1073..442a67045b8603267b1fbce1950f3396c35f35a8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,11 @@
 Changes with Apache 2.0.12-dev
 
+  *) Close one copy of the CGI's stdout before creating the new process.
+     The CGI will still have stdout, because we have already dup'ed it.
+     This keeps Apache from waiting forever to send the results of a CGI
+     process that has forked a long-lived child process.
+     [Taketo Kabe <kabe@sra-tohoku.co.jp>]
+
   *) Remove the rest of the pthreads functions from the threaded MPM.
      This requires the APR support for a signal thread that was just
      added.  [Ryan Bloom]
index dc7b647a4789b6fbb830f2a13c9106b398853139..a7e1618f8568090cae28259a8050b9f75e810d21 100644 (file)
@@ -549,11 +549,20 @@ static int cgid_server(void *data)
         }
         else {
             argv = (const char * const *)create_argv(r->pool, NULL, NULL, NULL, argv0, r->args);
+
+           /* We want to sd2 close for new CGI process too.
+            * If it's remained open it'll make ap_pass_brigade() block
+            * waiting for EOF if CGI forked something running long.
+            * close(sd2) here should be okay, as CGI channel
+            * is already dup()ed by apr_procattr_child_{in,out}_set()
+            * above.
+            */
+            close(sd2);
+
             rc = ap_os_create_privileged_process(r, procnew, argv0, argv, 
                                                  (const char * const *)env, 
                                                  procattr, p);
 
-            close(sd2);
             if (rc != APR_SUCCESS) {
                 /* Bad things happened. Everyone should have cleaned up. */
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,