You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2010/01/30 16:09:11 UTC
svn commit: r904784 - /httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c
Author: trawick
Date: Sat Jan 30 15:09:11 2010
New Revision: 904784
URL: http://svn.apache.org/viewvc?rev=904784&view=rev
Log:
improve handling of a couple of fatal startup errors in the
process manager
before: httpd restarts continually
after: httpd terminates
(more effort needed to resolve general handling of process
manager exits)
Modified:
httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c
Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c?rev=904784&r1=904783&r2=904784&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c Sat Jan 30 15:09:11 2010
@@ -40,6 +40,15 @@
#define ap_unixd_setup_child unixd_setup_child
#endif
+/* 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
+
static apr_status_t create_process_manager(server_rec * main_server,
apr_pool_t * configpool);
@@ -121,18 +130,33 @@
apr_proc_other_child_unregister(data);
if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state) == APR_SUCCESS
&& mpm_state != AP_MPMQ_STOPPING) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "mod_fcgid: fcgid process manager died, restarting the server");
-
- /* HACK: I can't just call create_process_manager() to
- restart a process manager, because it will use the dirty
- share memory, I have to kill myself a SIGHUP, to make
- a clean restart */
- if (kill(getpid(), SIGHUP) < 0) {
- ap_log_error(APLOG_MARK, APLOG_EMERG,
- apr_get_os_error(), NULL,
- "mod_fcgid: can't send SIGHUP to self");
- exit(0);
+ if (status == DAEMON_STARTUP_ERROR) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL,
+ "mod_fcgid: fcgid process manager failed to initialize; "
+ "stopping httpd");
+ /* mod_fcgid requests will hang due to lack of a process manager;
+ * try to terminate httpd
+ */
+ kill(getpid(), SIGTERM);
+
+ }
+ else {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "mod_fcgid: fcgid process manager died, restarting the server");
+
+ /* HACK: I can't just call create_process_manager() to
+ restart a process manager, because it will use the dirty
+ share memory, I have to kill myself a SIGHUP, to make
+ a clean restart */
+ /* FIXME: This is the httpd parent; mod_fcgid is doing a hard
+ * restart of the server!
+ */
+ if (kill(getpid(), SIGHUP) < 0) {
+ ap_log_error(APLOG_MARK, APLOG_EMERG,
+ apr_get_os_error(), NULL,
+ "mod_fcgid: can't send SIGHUP to self");
+ exit(0);
+ }
}
}
break;
@@ -142,6 +166,9 @@
case APR_OC_REASON_LOST:
apr_proc_other_child_unregister(data);
/* It hack here too, a note above */
+ /* FIXME: This is the httpd parent; mod_fcgid is doing a hard
+ * restart of the server!
+ */
if (kill(getpid(), SIGHUP) < 0) {
ap_log_error(APLOG_MARK, APLOG_EMERG,
apr_get_os_error(), NULL,
@@ -243,7 +270,7 @@
if ((rv = init_signal(main_server)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
"mod_fcgid: can't install signal handler, exiting now");
- exit(1);
+ exit(DAEMON_STARTUP_ERROR);
}
/* if running as root, switch to configured user */
@@ -251,7 +278,7 @@
if (getuid() != 0) {
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, main_server,
"mod_fcgid: current user is not root while suexec is enabled, exiting now");
- exit(1);
+ exit(DAEMON_STARTUP_ERROR);
}
suexec_setup_child();
} else