]> granicus.if.org Git - apache/commitdiff
mod_cgid: Don't try to restart the daemon if it fails to initialize the socket.
authorJeff Trawick <trawick@apache.org>
Wed, 7 May 2008 19:38:50 +0000 (19:38 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 7 May 2008 19:38:50 +0000 (19:38 +0000)
It won't get any better without intervention, and it will fork() until some
sort of intervention.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@654232 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/generators/mod_cgid.c

diff --git a/CHANGES b/CHANGES
index b8bfac24d61e7fb259a7b848705965b3ada206ad..bdb4c6a1474d043578e847d3311decc20f40b2a4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) mod_cgid: Don't try to restart the daemon if it fails to initialize
+     the socket.  [Jeff Trawick]
 
   *) core: Do not allow Options ALL if not all options are allowed to be
      overwritten. PR 44262 [Michał Grzędzicki <lazy iq.pl>]
index 70efc49b808e0b728ad17b8005d19e5ed7e894e8..670a4734b1bcf80a46e7db11c5864195ce1fbc0f 100644 (file)
@@ -91,6 +91,15 @@ static const char *sockname;
 static pid_t parent_pid;
 static ap_unix_identity_t empty_ugid = { (uid_t)-1, (gid_t)-1, -1 };
 
+/* The APR other-child API doesn't tell us how the daemon exited
+ * (SIGSEGV vs. exit(1)).  The other-child maintenance function
+ * needs to decide whether to restart the daemon after a failure
+ * based on whether or not it exited due to a fatal startup error
+ * or something that happened at steady-state.  This exit status
+ * is unlikely to collide with exit signals.
+ */
+#define DAEMON_STARTUP_ERROR 254
+
 /* Read and discard the data in the brigade produced by a CGI script */
 static void discard_script_output(apr_bucket_brigade *bb);
 
@@ -254,9 +263,15 @@ static void cgid_maint(int reason, void *data, apr_wait_t status)
                 stopping = 0;
             }
             if (!stopping) {
-                ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
-                             "cgid daemon process died, restarting");
-                cgid_start(root_pool, root_server, proc);
+                if (status == DAEMON_STARTUP_ERROR) {
+                    ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL,
+                                 "cgid daemon failed to initialize");
+                }
+                else {
+                    ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+                                 "cgid daemon process died, restarting");
+                    cgid_start(root_pool, root_server, proc);
+                }
             }
             break;
         case APR_OC_REASON_RESTART:
@@ -785,7 +800,7 @@ static int cgid_server(void *data)
         apr_hash_set(script_hash, key, sizeof(cgid_req.conn_id),
                      (void *)((long)procnew->pid));
     }
-    return -1;
+    return -1; /* should be <= 0 to distinguish from startup errors */
 }
 
 static int cgid_start(apr_pool_t *p, server_rec *main_server,
@@ -802,8 +817,7 @@ static int cgid_start(apr_pool_t *p, server_rec *main_server,
         if (pcgi == NULL) {
             apr_pool_create(&pcgi, p);
         }
-        cgid_server(main_server);
-        exit(-1);
+        exit(cgid_server(main_server) > 0 ? DAEMON_STARTUP_ERROR : -1);
     }
     procnew->pid = daemon_pid;
     procnew->err = procnew->in = procnew->out = NULL;