[Openswan dev] [PATCH] Fix race condition between pluto start and whack
Mattias Walstrom
lazzer at vmlinux.org
Wed Apr 6 04:27:23 EDT 2011
Fix race condition between pluto start and whack, which can result in pluto becoming a zombie that never returns.
When sending any whack message during the time pluto starts, whack will just hang for a long time.
And if pluto should die during this hang, it will become a Zombie. This patch makes sure that we do not open the ctl socket until we actually can receive messages (all pluto initialization is done).
Signed-off-by: Mattias Walström <lazzer at vmlinux.org>
--
plutomain.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/programs/pluto/plutomain.c b/programs/pluto/plutomain.c
index 1597dc4..0d19d2c 100644
--- a/programs/pluto/plutomain.c
+++ b/programs/pluto/plutomain.c
@@ -725,21 +725,6 @@ main(int argc, char **argv)
#endif
#endif
- /** create control socket.
- * We must create it before the parent process returns so that
- * there will be no race condition in using it. The easiest
- * place to do this is before the daemon fork.
- */
- {
- err_t ugh = init_ctl_socket();
-
- if (ugh != NULL)
- {
- fprintf(stderr, "pluto: %s", ugh);
- exit_pluto(1);
- }
- }
-
#ifdef IPSECPOLICY
/* create info socket. */
{
@@ -1051,6 +1036,17 @@ main(int argc, char **argv)
load_authcerts_from_nss("CA cert", AUTH_CA);
#endif
+ /* create control socket. */
+ {
+ err_t ugh = init_ctl_socket();
+
+ if (ugh != NULL)
+ {
+ fprintf(stderr, "pluto: %s", ugh);
+ exit_pluto(1);
+ }
+ }
+
daily_log_event();
call_server();
return -1; /* Shouldn't ever reach this */
More information about the Dev
mailing list