Search the web
Sign In
New User? Sign Up
new-httpd
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
[1.3 PATCH] don't hold accept mutex while running 3rd-party code at   Message List  
Reply | Forward Message #44070 of 56488 |
two scenarios make it a bad idea to be able to hold the accept mutex
when exiting a child process for idle child cleanup:

1) a child exit hook or a pchild cleanup takes a while

This results in a brief server outage since other children can't accept
new connections.

(If a child exit hook or a pchild cleanup takes forever/deadlocks, we're
toast anyway, since the scoreboard slot is occupied and we won't be able
to keep creating new child processes.)

2) a child exit hook or a pchild cleanup segfaults and accept mutex
mechanism isn't automatically cleaned up by the OS

(mechanism = pthread, 3rd party module = XXX)

deadlock :(

If anybody wants a toy 1.3 module to sleep or segfault in child exit
hook, just let me know. It is much easier to install than the
commercial version.


Fri May 9, 2003 2:51 pm

trawick@...
Send Email Send Email

Index: src/main/http_main.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.602
diff -u -r1.602 http_main.c
--- src/main/http_main.c 25 Apr 2003 13:50:23 -0000 1.602
+++ src/main/http_main.c 9 May 2003 14:35:32 -0000
@@ -372,6 +372,7 @@
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)
{
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);
}
@@ -4211,10 +4220,15 @@
* 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


Forward
Message #44070 of 56488 |
Expand Messages Author Sort by Date

two scenarios make it a bad idea to be able to hold the accept mutex when exiting a child process for idle child cleanup: 1) a child exit hook or a pchild...
Jeff Trawick
trawick@...
Send Email
May 9, 2003
2:52 pm

... Yes, we're always talking about single-threaded processes here (we're agnostic about other threads). The base level of understanding required is this: When...
Jeff Trawick
trawick@...
Send Email
May 9, 2003
7:43 pm

... In 1.3 (on Unix), I would expect that the thread that does the accept would be the same thread that runs the child exit hook and pchild cleanups. When...
Bill Stoddard
bill@...
Send Email
May 9, 2003
9:06 pm

... Any comments on releasing the accept mutex in the child before running 3rd-party child exit hooks or cleanups? I see that 1.3.28 headed for the runway....
Jeff Trawick
trawick@...
Send Email
May 17, 2003
10:19 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help