svn rev #25177: trunk/src/kdc/
ghudson@MIT.EDU
ghudson at MIT.EDU
Wed Sep 14 12:12:36 EDT 2011
http://src.mit.edu/fisheye/changelog/krb5/?cs=25177
Commit By: ghudson
Log Message:
Set up monitor signal handlers before forking.
This avoids a race condition where a child reports "starting..." and
begins to service requests before the monitor is ready to handle
termination signals. Really only an issue for the test suite. From
npmccallum at redhat.com.
Changed Files:
U trunk/src/kdc/main.c
Modified: trunk/src/kdc/main.c
===================================================================
--- trunk/src/kdc/main.c 2011-09-14 16:12:33 UTC (rev 25176)
+++ trunk/src/kdc/main.c 2011-09-14 16:12:36 UTC (rev 25177)
@@ -543,6 +543,26 @@
struct sigaction s_action;
#endif /* POSIX_SIGNALS */
+ /*
+ * Setup our signal handlers which will forward to the children.
+ * These handlers will be overriden in the child processes.
+ */
+#ifdef POSIX_SIGNALS
+ (void) sigemptyset(&s_action.sa_mask);
+ s_action.sa_flags = 0;
+ s_action.sa_handler = on_monitor_signal;
+ (void) sigaction(SIGINT, &s_action, (struct sigaction *) NULL);
+ (void) sigaction(SIGTERM, &s_action, (struct sigaction *) NULL);
+ (void) sigaction(SIGQUIT, &s_action, (struct sigaction *) NULL);
+ s_action.sa_handler = on_monitor_sighup;
+ (void) sigaction(SIGHUP, &s_action, (struct sigaction *) NULL);
+#else /* POSIX_SIGNALS */
+ signal(SIGINT, on_monitor_signal);
+ signal(SIGTERM, on_monitor_signal);
+ signal(SIGQUIT, on_monitor_signal);
+ signal(SIGHUP, on_monitor_sighup);
+#endif /* POSIX_SIGNALS */
+
/* Create child worker processes; return in each child. */
krb5_klog_syslog(LOG_INFO, _("creating %d worker processes"), num);
pids = calloc(num, sizeof(pid_t));
@@ -580,23 +600,6 @@
/* We're going to use our own main loop here. */
loop_free(ctx);
- /* Setup our signal handlers which will forward to the children. */
-#ifdef POSIX_SIGNALS
- (void) sigemptyset(&s_action.sa_mask);
- s_action.sa_flags = 0;
- s_action.sa_handler = on_monitor_signal;
- (void) sigaction(SIGINT, &s_action, (struct sigaction *) NULL);
- (void) sigaction(SIGTERM, &s_action, (struct sigaction *) NULL);
- (void) sigaction(SIGQUIT, &s_action, (struct sigaction *) NULL);
- s_action.sa_handler = on_monitor_sighup;
- (void) sigaction(SIGHUP, &s_action, (struct sigaction *) NULL);
-#else /* POSIX_SIGNALS */
- signal(SIGINT, on_monitor_signal);
- signal(SIGTERM, on_monitor_signal);
- signal(SIGQUIT, on_monitor_signal);
- signal(SIGHUP, on_monitor_sighup);
-#endif /* POSIX_SIGNALS */
-
/* Supervise the worker processes. */
numleft = num;
while (!signal_received) {
More information about the cvs-krb5
mailing list