Make the KDC use a multi-process model.
We now fork(2) a number of separate KDC processes rather than a single process. By default, the number is selected by asking how many CPUs the machine has. We also have a master process which monitors all of the children (which do the actual work) and it will restart kids who die for any reason. The children will die when the parent dies. In the case of MacOS X, we also move the bonjour code into another separate child as it creates threads and this is known to play rather poorly with fork(2). We could move this logic into a designated child at some point in the future. We slow down the spawning to one every 25ms to prevent instant crashes and restarts from consuming all available system time. This approach may want to be revisited in the future.
This commit is contained in:
14
kdc/main.c
14
kdc/main.c
@@ -47,6 +47,11 @@ sig_atomic_t exit_flag = 0;
|
||||
int detach_from_console = -1;
|
||||
int daemon_child = -1;
|
||||
|
||||
static RETSIGTYPE
|
||||
sigchld(int sig)
|
||||
{
|
||||
}
|
||||
|
||||
static RETSIGTYPE
|
||||
sigterm(int sig)
|
||||
{
|
||||
@@ -140,6 +145,9 @@ main(int argc, char **argv)
|
||||
sigaction(SIGXCPU, &sa, NULL);
|
||||
#endif
|
||||
|
||||
sa.sa_handler = sigchld;
|
||||
sigaction(SIGCHLD, &sa, NULL);
|
||||
|
||||
sa.sa_handler = SIG_IGN;
|
||||
#ifdef SIGPIPE
|
||||
sigaction(SIGPIPE, &sa, NULL);
|
||||
@@ -148,21 +156,19 @@ main(int argc, char **argv)
|
||||
#else
|
||||
signal(SIGINT, sigterm);
|
||||
signal(SIGTERM, sigterm);
|
||||
signal(SIGCHLD, sigchld);
|
||||
#ifdef SIGXCPU
|
||||
signal(SIGXCPU, sigterm);
|
||||
#endif
|
||||
#ifdef SIGPIPE
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
bonjour_announce(context, config);
|
||||
#endif
|
||||
pidfile(NULL);
|
||||
|
||||
switch_environment();
|
||||
|
||||
loop(context, config);
|
||||
start_kdc(context, config);
|
||||
krb5_free_context(context);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user