From bb798d781606e74f0f8af9d6c0184ac1f72a0dd5 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Fri, 14 Jun 2002 03:11:43 +0000 Subject: [PATCH] prefork MPM: Ignore mutex errors during graceful restart. For certain types of mutexes (particularly SysV semaphores), we should expect to occasionally fail to obtain or release the mutex during restart processing. These mutex failures seem to be a pretty rare occurrence, but it was fatal. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95665 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ server/mpm/prefork/prefork.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index e9f1bf7720..32c3c82882 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,10 @@ Changes with Apache 2.0.38 + *) prefork MPM: Ignore mutex errors during graceful restart. For + certain types of mutexes (particularly SysV semaphores), we + should expect to occasionally fail to obtain or release the + mutex during restart processing. [Jeff Trawick] + *) Fix install-bindist.sh so that it finds any perl instead of just early perl 5.x versions. This is consistent with a build/install from source, and it allows the perl scripts installed by a bindist diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 87c13f2775..3d13b13638 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -172,6 +172,7 @@ static pid_t parent_pid; #ifndef MULTITHREAD static int my_child_num; #endif +ap_generation_t volatile ap_my_generation=0; #ifdef TPF int tpf_child = 0; @@ -239,8 +240,17 @@ static void accept_mutex_on(void) { apr_status_t rv = apr_proc_mutex_lock(accept_mutex); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "couldn't grab the accept mutex"); - exit(APEXIT_CHILDFATAL); + const char *msg = "couldn't grab the accept mutex"; + + if (ap_my_generation != + ap_scoreboard_image->global->running_generation) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL, msg); + clean_child_exit(0); + } + else { + ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, msg); + exit(APEXIT_CHILDFATAL); + } } } @@ -248,8 +258,20 @@ static void accept_mutex_off(void) { apr_status_t rv = apr_proc_mutex_unlock(accept_mutex); if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "couldn't release the accept mutex"); - exit(APEXIT_CHILDFATAL); + const char *msg = "couldn't release the accept mutex"; + + if (ap_my_generation != + ap_scoreboard_image->global->running_generation) { + ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL, msg); + /* don't exit here... we have a connection to + * process, after which point we'll see that the + * generation changed and we'll exit cleanly + */ + } + else { + ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, msg); + exit(APEXIT_CHILDFATAL); + } } } @@ -364,7 +386,6 @@ static void just_die(int sig) static int volatile shutdown_pending; static int volatile restart_pending; static int volatile is_graceful; -ap_generation_t volatile ap_my_generation=0; static void sig_term(int sig) { -- 2.50.1