aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2009-03-27 16:14:59 +0000
committerAndreas Steffen <andreas.steffen@strongswan.org>2009-03-27 16:14:59 +0000
commit0ad1a8daeafd5543dfe7448ef07827fff7153b07 (patch)
tree212ad4af1a7a5266d3c4185346b85e45fd60adc3
parent9d1bd182434052e4aae05f6936596e33a439e052 (diff)
downloadstrongswan-0ad1a8daeafd5543dfe7448ef07827fff7153b07.tar.bz2
strongswan-0ad1a8daeafd5543dfe7448ef07827fff7153b07.tar.xz
modelled invokepluto start and stop timing scheme after invokecharon
-rw-r--r--src/starter/invokecharon.c2
-rw-r--r--src/starter/invokepluto.c42
2 files changed, 32 insertions, 12 deletions
diff --git a/src/starter/invokecharon.c b/src/starter/invokecharon.c
index 95ef0bc92..1cce4e41d 100644
--- a/src/starter/invokecharon.c
+++ b/src/starter/invokecharon.c
@@ -216,7 +216,7 @@ starter_start_charon (starter_config_t *cfg, bool no_fork)
{
kill(pid, SIGKILL);
}
- usleep(20000);
+ usleep(20000); /* sleep for 20 ms */
}
}
else
diff --git a/src/starter/invokepluto.c b/src/starter/invokepluto.c
index 99daf681b..6fdf46ffd 100644
--- a/src/starter/invokepluto.c
+++ b/src/starter/invokepluto.c
@@ -62,33 +62,49 @@ starter_pluto_sigchild(pid_t pid)
int
starter_stop_pluto (void)
{
- pid_t pid;
int i;
+ pid_t pid = _pluto_pid;
- pid = _pluto_pid;
if (pid)
{
_stop_requested = 1;
+
if (starter_whack_shutdown() == 0)
{
- for (i = 0; i < 20; i++)
+ for (i = 0; i < 400; i++)
{
- usleep(20000);
+ usleep(20000); /* sleep for 20 ms */
if (_pluto_pid == 0)
+ {
+ plog("pluto stopped after %d ms", 20*(i+1));
return 0;
+ }
}
}
/* be more and more aggressive */
for (i = 0; i < 20 && (pid = _pluto_pid) != 0; i++)
{
+
if (i < 10)
+ {
kill(pid, SIGTERM);
+ }
+ if (i == 10)
+ {
+ kill(pid, SIGKILL);
+ plog("starter_stop_pluto(): pluto does not respond, sending KILL");
+ }
else
+ {
kill(pid, SIGKILL);
- usleep(20000);
+ }
+ usleep(100000); /* sleep for 100 ms */
}
if (_pluto_pid == 0)
+ {
+ plog("pluto stopped after %d ms", 8000 + 100*i);
return 0;
+ }
plog("starter_stop_pluto(): can't stop pluto !!!");
return -1;
}
@@ -248,17 +264,17 @@ starter_start_pluto (starter_config_t *cfg, bool no_fork)
default:
/* father */
_pluto_pid = pid;
- for (i = 0; i < 50 && _pluto_pid; i++)
+ for (i = 0; i < 500 && _pluto_pid; i++)
{
- /* wait for pluto */
+ /* wait for pluto for a maximum of 500 x 20 ms = 10 s */
usleep(20000);
if (stat(PLUTO_CTL_FILE, &stb) == 0)
{
- DBG(DBG_CONTROL,
- DBG_log("pluto (%d) started", _pluto_pid)
- )
+ plog("pluto (%d) started after %d ms", _pluto_pid, 20*(i+1));
if (cfg->setup.postpluto)
+ {
ignore_result(system(cfg->setup.postpluto));
+ }
return 0;
}
}
@@ -269,10 +285,14 @@ starter_start_pluto (starter_config_t *cfg, bool no_fork)
for (i = 0; i < 20 && (pid = _pluto_pid) != 0; i++)
{
if (i < 10)
+ {
kill(pid, SIGTERM);
+ }
else
+ {
kill(pid, SIGKILL);
- usleep(20000);
+ }
+ usleep(20000); /* sleep for 20 ms */
}
}
else