Changes with Apache 2.0.34-dev
+ *) Fix a mod_cgid problem that left daemon processes stranded
+ in some server restart scenarios. [Jeff Trawick]
+
*) Added exp_foo and rel_foo variables to config_vars.mk for
all Apache and Autoconf path variables (like --sysconfdir,
--sbindir, etc). exp_foo is the "expanded" version, which means
static apr_pool_t *pcgi;
static int total_modules = 0;
static pid_t daemon_pid;
+static int daemon_should_exit = 0;
/* KLUDGE --- for back-combatibility, we don't have to check Execcgid
* in ScriptAliased directories, which means we need to know if this
/* we get here when pcgi is cleaned up; pcgi gets cleaned
* up when pconf gets cleaned up
*/
- kill(*sd, SIGHUP);
+ kill(*sd, SIGHUP); /* send signal to daemon telling it to die */
break;
}
}
#endif
}
+static void daemon_signal_handler(int sig)
+{
+ if (sig == SIGHUP) {
+ ++daemon_should_exit;
+ }
+}
+
static int cgid_server(void *data)
{
struct sockaddr_un unix_addr;
apr_pool_create(&ptrans, pcgi);
apr_signal(SIGCHLD, SIG_IGN);
+ apr_signal(SIGHUP, daemon_signal_handler);
+
if (unlink(sconf->sockname) < 0 && errno != ENOENT) {
ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
"Couldn't unlink unix domain socket %s",
}
unixd_setup_child(); /* if running as root, switch to configured user/group */
- while (1) {
+
+ while (!daemon_should_exit) {
int errfileno = STDERR_FILENO;
char *argv0;
char **env;
for (m = ap_preloaded_modules; *m != NULL; m++)
total_modules++;
+ daemon_should_exit = 0; /* clear setting from previous generation */
if ((daemon_pid = fork()) < 0) {
ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
"Couldn't spawn cgid daemon process");