Don't count an application exit towards the number of
authorrobs <robs>
Thu, 15 Apr 2004 01:23:05 +0000 (15 01:23 +0000)
committerrobs <robs>
Thu, 15 Apr 2004 01:23:05 +0000 (15 01:23 +0000)
failures when doing restart backoff handling if the exit
status is 0.  ["Rob Saccoccio" <robs fastcgi.com>]

Modified Files: fcgi_pm.c CHANGES

CHANGES
fcgi_pm.c

diff --git a/CHANGES b/CHANGES
index e15abfa..2c16fbc 100644 (file)
--- 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" <robs fastcgi.com>]
+
  *) [*nix] Don't use suexec when there is no user/group in effect.
     This change is consistent with Apache2 handling.  Identified
     by ["Florian Effenberger" <floeff arcor.de>].
index 31638db..c614804 100644 (file)
--- 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;