starter: Go back to single threaded mode.
Mixing multiple threads and fork(2) wasn't a very good idea it seems. At least in some environments this caused strange side-effects.
This commit is contained in:
@@ -201,8 +201,8 @@ int starter_start_charon (starter_config_t *cfg, bool no_fork, bool attach_gdb)
|
|||||||
exit(1);
|
exit(1);
|
||||||
default:
|
default:
|
||||||
/* father */
|
/* father */
|
||||||
_charon_pid = pid;
|
_charon_pid = pid;
|
||||||
for (i = 0; i < 500 && _charon_pid; i++)
|
for (i = 0; i < 500 && _charon_pid; i++)
|
||||||
{
|
{
|
||||||
/* wait for charon for a maximum of 500 x 20 ms = 10 s */
|
/* wait for charon for a maximum of 500 x 20 ms = 10 s */
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
|
|||||||
+5
-20
@@ -50,11 +50,6 @@
|
|||||||
#include "cmp.h"
|
#include "cmp.h"
|
||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of threads in the thread pool, if not specified in config.
|
|
||||||
*/
|
|
||||||
#define DEFAULT_THREADS 4
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return codes defined by Linux Standard Base Core Specification 3.1
|
* Return codes defined by Linux Standard Base Core Specification 3.1
|
||||||
* in section 20.2. Init Script Actions
|
* in section 20.2. Init Script Actions
|
||||||
@@ -494,8 +489,7 @@ int main (int argc, char **argv)
|
|||||||
exit(LSB_RC_FAILURE);
|
exit(LSB_RC_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we handle these signals in the main thread, so we don't want any
|
/* we handle these signals only in pselect() */
|
||||||
* of the others to catch them */
|
|
||||||
memset(&action, 0, sizeof(action));
|
memset(&action, 0, sizeof(action));
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaddset(&action.sa_mask, SIGHUP);
|
sigaddset(&action.sa_mask, SIGHUP);
|
||||||
@@ -503,7 +497,6 @@ int main (int argc, char **argv)
|
|||||||
sigaddset(&action.sa_mask, SIGTERM);
|
sigaddset(&action.sa_mask, SIGTERM);
|
||||||
sigaddset(&action.sa_mask, SIGQUIT);
|
sigaddset(&action.sa_mask, SIGQUIT);
|
||||||
sigaddset(&action.sa_mask, SIGALRM);
|
sigaddset(&action.sa_mask, SIGALRM);
|
||||||
sigaddset(&action.sa_mask, SIGCHLD);
|
|
||||||
sigaddset(&action.sa_mask, SIGUSR1);
|
sigaddset(&action.sa_mask, SIGUSR1);
|
||||||
pthread_sigmask(SIG_SETMASK, &action.sa_mask, NULL);
|
pthread_sigmask(SIG_SETMASK, &action.sa_mask, NULL);
|
||||||
|
|
||||||
@@ -515,26 +508,18 @@ int main (int argc, char **argv)
|
|||||||
action.sa_handler = SIG_IGN;
|
action.sa_handler = SIG_IGN;
|
||||||
sigaction(SIGPIPE, &action, NULL);
|
sigaction(SIGPIPE, &action, NULL);
|
||||||
|
|
||||||
/* we need threads to read events from the kernel */
|
/* install main signal handler */
|
||||||
lib->processor->set_threads(lib->processor,
|
|
||||||
lib->settings->get_int(lib->settings, "starter.threads",
|
|
||||||
DEFAULT_THREADS));
|
|
||||||
|
|
||||||
/* install signal handler for main thread */
|
|
||||||
action.sa_handler = signal_handler;
|
action.sa_handler = signal_handler;
|
||||||
sigaction(SIGHUP, &action, NULL);
|
sigaction(SIGHUP, &action, NULL);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
sigaction(SIGQUIT, &action, NULL);
|
sigaction(SIGQUIT, &action, NULL);
|
||||||
sigaction(SIGALRM, &action, NULL);
|
sigaction(SIGALRM, &action, NULL);
|
||||||
sigaction(SIGCHLD, &action, NULL);
|
|
||||||
sigaction(SIGUSR1, &action, NULL);
|
sigaction(SIGUSR1, &action, NULL);
|
||||||
|
/* this is not blocked above as we want to receive it asynchronously */
|
||||||
|
sigaction(SIGCHLD, &action, NULL);
|
||||||
|
|
||||||
/* the only signal we want to receive asynchronously is SIGCHLD */
|
/* empty mask for pselect() call below */
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaddset(&action.sa_mask, SIGCHLD);
|
|
||||||
pthread_sigmask(SIG_UNBLOCK, &action.sa_mask, NULL);
|
|
||||||
/* the rest is unblocked in pselect() below */
|
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
|
|||||||
Reference in New Issue
Block a user