From: Jeff Trawick Date: Fri, 23 May 2003 15:25:24 +0000 (+0000) Subject: Make sure the accept mutex is released before calling child exit X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf25e26aedd025c44e102cb0d8b93fcf989d935c;p=thirdparty%2Fapache%2Fhttpd.git 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. 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 --- diff --git a/src/CHANGES b/src/CHANGES index 89a6f921448..dc0dbd040fb 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -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] diff --git a/src/main/http_main.c b/src/main/http_main.c index dc0323a0914..106b4f7438b 100644 --- a/src/main/http_main.c +++ b/src/main/http_main.c @@ -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