diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-06-07 12:02:14 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-06-08 14:12:07 +0200 |
commit | 4a10eda1a0b3f867b893c8ad5a19b2ee490d262d (patch) | |
tree | c46511d78ad188b815fe140d8ed34e3de6791241 /src | |
parent | 05ca56558c48d9997f562ede1d68fe928cfefd39 (diff) | |
download | strongswan-4a10eda1a0b3f867b893c8ad5a19b2ee490d262d.tar.bz2 strongswan-4a10eda1a0b3f867b893c8ad5a19b2ee490d262d.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/starter/invokecharon.c | 4 | ||||
-rw-r--r-- | src/starter/starter.c | 25 |
2 files changed, 7 insertions, 22 deletions
diff --git a/src/starter/invokecharon.c b/src/starter/invokecharon.c index ead55e9cc..ed4672ad9 100644 --- a/src/starter/invokecharon.c +++ b/src/starter/invokecharon.c @@ -201,8 +201,8 @@ int starter_start_charon (starter_config_t *cfg, bool no_fork, bool attach_gdb) exit(1); default: /* father */ - _charon_pid = pid; - for (i = 0; i < 500 && _charon_pid; i++) + _charon_pid = pid; + for (i = 0; i < 500 && _charon_pid; i++) { /* wait for charon for a maximum of 500 x 20 ms = 10 s */ usleep(20000); diff --git a/src/starter/starter.c b/src/starter/starter.c index 5322d271e..f62d55c7a 100644 --- a/src/starter/starter.c +++ b/src/starter/starter.c @@ -51,11 +51,6 @@ #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 * in section 20.2. Init Script Actions */ @@ -494,8 +489,7 @@ int main (int argc, char **argv) exit(LSB_RC_FAILURE); } - /* we handle these signals in the main thread, so we don't want any - * of the others to catch them */ + /* we handle these signals only in pselect() */ memset(&action, 0, sizeof(action)); sigemptyset(&action.sa_mask); sigaddset(&action.sa_mask, SIGHUP); @@ -503,7 +497,6 @@ int main (int argc, char **argv) sigaddset(&action.sa_mask, SIGTERM); sigaddset(&action.sa_mask, SIGQUIT); sigaddset(&action.sa_mask, SIGALRM); - sigaddset(&action.sa_mask, SIGCHLD); sigaddset(&action.sa_mask, SIGUSR1); pthread_sigmask(SIG_SETMASK, &action.sa_mask, NULL); @@ -515,26 +508,18 @@ int main (int argc, char **argv) action.sa_handler = SIG_IGN; sigaction(SIGPIPE, &action, NULL); - /* we need threads to read events from the kernel */ - lib->processor->set_threads(lib->processor, - lib->settings->get_int(lib->settings, "starter.threads", - DEFAULT_THREADS)); - - /* install signal handler for main thread */ + /* install main signal handler */ action.sa_handler = signal_handler; sigaction(SIGHUP, &action, NULL); sigaction(SIGINT, &action, NULL); sigaction(SIGTERM, &action, NULL); sigaction(SIGQUIT, &action, NULL); sigaction(SIGALRM, &action, NULL); - sigaction(SIGCHLD, &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 */ - sigemptyset(&action.sa_mask); - sigaddset(&action.sa_mask, SIGCHLD); - pthread_sigmask(SIG_UNBLOCK, &action.sa_mask, NULL); - /* the rest is unblocked in pselect() below */ + /* empty mask for pselect() call below */ sigemptyset(&action.sa_mask); for (;;) |