httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Ho <and...@tellme.com>
Subject Re: Apache 1.3.x race condition causes gratuitous 3-second CGI delay
Date Sat, 17 Feb 2001 22:47:27 GMT
Hello,

AH>FWIW, here is a patch to alloc.c which fixed the problem for our
AH>installation; all it does is install a SIGCHLD handler right before the
AH>sleep(3), and now that the signal is being paid attention to, the signal
AH>pops us out of the sleep(). We then re-install any previous SIGCHLD
AH>handler.

JJ>Patch?

Egads! I must've been on shrooms. Here it is:


--- alloc.c.orig        Wed Feb 14 14:08:08 2001
+++ alloc.c     Fri Feb 16 13:22:08 2001
@@ -2613,6 +2613,13 @@
     return pid;
 }

+static void null_sig_chld_handler(int sig) {
+    /* Do nothing; exists so free_proc_chain
+     * can be forced out of its sleep()
+     */
+    return;
+}
+
 static void free_proc_chain(struct process_chain *procs)
 {
     /* Dispose of the subprocesses we've spawned off in the course of
@@ -2623,6 +2630,7 @@
     struct process_chain *p;
     int need_timeout = 0;
     int status;
+    void *old_disp;

     if (procs == NULL)
        return;                 /* No work.  Whew! */
@@ -2693,8 +2701,12 @@

     /* Sleep only if we have to... */

-    if (need_timeout)
-       sleep(3);
+    if (need_timeout) {
+        old_disp = signal(SIGCHLD, null_sig_chld_handler);
+        /* race condition here, we could get a SIGCHLD before we sleep, oh well */
+        sleep(3);
+        signal(SIGCHLD, old_disp);
+    }

     /* OK, the scripts we just timed out for have had a chance to clean up
      * --- now, just get rid of them, and also clean up the system accounting


Humbly,

Andrew

----------------------------------------------------------------------
Andrew Ho               http://www.tellme.com/       andrew@tellme.com
Engineer                   info@tellme.com          Voice 650-930-9062
Tellme Networks, Inc.       1-800-555-TELL            Fax 650-930-9101
----------------------------------------------------------------------


Mime
View raw message