]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Make sure the accept mutex is released before calling child exit
authorJeff Trawick <trawick@apache.org>
Fri, 23 May 2003 15:25:24 +0000 (15:25 +0000)
committerJeff Trawick <trawick@apache.org>
Fri, 23 May 2003 15:25:24 +0000 (15:25 +0000)
hooks and cleanups.  Otherwise, modules can segfault in such code
and, with pthread mutexes, leave the server deadlocked.  Even if
the module doesn't segfault, if it performs extensive processing
it can temporarily prevent the server from accepting new
connections.

Reviewed by: Jim, FirstBill

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@100018 13f79535-47bb-0310-9956-ffa450edef68

src/CHANGES
src/main/http_main.c

index 89a6f9214480f7312489892eea44f17b8a3b18a2..dc0dbd040fb753df713ff9c179e4475c27c0b455 100644 (file)
@@ -1,5 +1,12 @@
 Changes with Apache 1.3.28
 
+  *) Make sure the accept mutex is released before calling child exit
+     hooks and cleanups.  Otherwise, modules can segfault in such code
+     and, with pthread mutexes, leave the server deadlocked.  Even if
+     the module doesn't segfault, if it performs extensive processing
+     it can temporarily prevent the server from accepting new
+     connections.  [Jeff Trawick]
+
   *) Fix mod_rewrite's handling of absolute URIs. The escaping routines
      now work scheme dependent and the query string will only be
      appended if supported by the particular scheme.  [AndrĂ© Malo]
index dc0323a091486585ef45086b94357805bb790ce1..106b4f7438b069120e10b2d25300907f13b8ca6e 100644 (file)
@@ -372,6 +372,7 @@ static pool *pconf;         /* Pool for config stuff */
 static pool *plog;             /* Pool for error-logging files */
 static pool *ptrans;           /* Pool for per-transaction stuff */
 static pool *pchild;           /* Pool for httpd child stuff */
+static pool *pmutex;            /* Pool for accept mutex in child */
 static pool *pcommands;        /* Pool for -C and -c switches */
 
 #ifndef NETWARE
@@ -515,6 +516,14 @@ static void clean_child_exit(int code) __attribute__ ((noreturn));
 static void clean_child_exit(int code)
 {
     if (pchild) {
+        /* make sure the accept mutex is released before calling child
+         * exit hooks and cleanups...  otherwise, modules can segfault
+         * in such code and, depending on the mutex mechanism, leave
+         * the server deadlocked...  even if the module doesn't segfault,
+         * if it performs extensive processing it can temporarily prevent
+         * the server from accepting new connections
+         */
+        ap_clear_pool(pmutex);
        ap_child_exit_modules(pchild, server_conf);
        ap_destroy_pool(pchild);
     }
@@ -4255,10 +4264,15 @@ static void child_main(int child_num_arg)
      * we can have cleanups occur when the child exits.
      */
     pchild = ap_make_sub_pool(pconf);
+    /* associate accept mutex cleanup with a subpool of pchild so we can
+     * make sure the mutex is released before calling module code at
+     * termination
+     */
+    pmutex = ap_make_sub_pool(pchild);
 
     /* needs to be done before we switch UIDs so we have permissions */
     reopen_scoreboard(pchild);
-    SAFE_ACCEPT(accept_mutex_child_init(pchild));
+    SAFE_ACCEPT(accept_mutex_child_init(pmutex));
 
     set_group_privs();
 #ifdef MPE