From 029554cde782cb5e42bff903b44b6f2aacfe09b2 Mon Sep 17 00:00:00 2001 From: robs Date: Thu, 15 Apr 2004 01:23:05 +0000 Subject: [PATCH] Don't count an application exit towards the number of failures when doing restart backoff handling if the exit status is 0. ["Rob Saccoccio" ] Modified Files: fcgi_pm.c CHANGES --- CHANGES | 4 ++++ fcgi_pm.c | 27 ++++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index e15abfa..2c16fbc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ 2.4.3 + *) Don't count an application exit towards the number of + failures when doing restart backoff handling if the exit + status is 0. ["Rob Saccoccio" ] + *) [*nix] Don't use suexec when there is no user/group in effect. This change is consistent with Apache2 handling. Identified by ["Florian Effenberger" ]. diff --git a/fcgi_pm.c b/fcgi_pm.c index 31638db..c614804 100644 --- a/fcgi_pm.c +++ b/fcgi_pm.c @@ -1,5 +1,5 @@ /* - * $Id: fcgi_pm.c,v 1.91 2004/04/15 00:32:56 robs Exp $ + * $Id: fcgi_pm.c,v 1.92 2004/04/15 01:23:05 robs Exp $ */ @@ -1538,10 +1538,15 @@ void child_wait_thread_main(void *dummy) { /* a child fs has died */ /* mark the child as dead */ + GetExitCodeProcess(s->procs[i].handle, &exitStatus); + if (s->directive == APP_CLASS_STANDARD) { /* restart static app */ s->procs[i].state = FCGI_START_STATE; - s->numFailures++; + if (exitStatus != 0) { + /* don't bump failure count on exit 0 */ + s->numFailures++; + } } else { s->numProcesses--; @@ -1553,7 +1558,10 @@ void child_wait_thread_main(void *dummy) { } else { /* dynamic app shouldn't have died or dynamicAutoUpdate killed it*/ - s->numFailures++; + if (exitStatus != 0) { + /* don't bump failure count on exit 0 */ + s->numFailures++; + } if (dynamicAutoRestart || (s->numProcesses <= 0 && dynamicThreshold1 == 0)) { s->procs[i].state = FCGI_START_STATE; @@ -1564,8 +1572,6 @@ void child_wait_thread_main(void *dummy) { } } - GetExitCodeProcess(s->procs[i].handle, &exitStatus); - ap_log_error(FCGI_LOG_WARN_NOERRNO, fcgi_apache_main_server, "FastCGI:%s server \"%s\" (pid %d) terminated with exit with status '%d'", (s->directive == APP_CLASS_DYNAMIC) ? " (dynamic)" : "", @@ -1965,7 +1971,10 @@ ChildFound: if (s->directive == APP_CLASS_STANDARD) { /* Always restart static apps */ s->procs[i].state = FCGI_START_STATE; - s->numFailures++; + if (! (WIFEXITED(waitStatus) && (WEXITSTATUS(waitStatus) == 0))) { + /* don't bump the failure count if the app exited with 0 */ + s->numFailures++; + } } else { s->numProcesses--; @@ -1976,7 +1985,11 @@ ChildFound: } else { /* A dynamic app died or exited without provocation from the PM */ - s->numFailures++; + + if (! (WIFEXITED(waitStatus) && (WEXITSTATUS(waitStatus) == 0))) { + /* don't bump the failure count if the app exited with 0 */ + s->numFailures++; + } if (dynamicAutoRestart || (s->numProcesses <= 0 && dynamicThreshold1 == 0)) s->procs[i].state = FCGI_START_STATE; -- 2.11.4.GIT