summaryrefslogtreecommitdiff
path: root/src/starter/invokepluto.c
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2009-04-01 20:56:41 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2009-04-01 20:56:41 +0000
commitf46b6f36ae2a46f92f69b096a58d6ff96726a9ed (patch)
tree370b1aa2e1f2f4b5c3dd8ee9a4749c9c6e79575f /src/starter/invokepluto.c
parent188bacbfe68aa6cbbaaa6cbd26b334f634f23871 (diff)
downloadvyos-strongswan-f46b6f36ae2a46f92f69b096a58d6ff96726a9ed.tar.gz
vyos-strongswan-f46b6f36ae2a46f92f69b096a58d6ff96726a9ed.zip
- New upstream release to hopefully compile on sid.
Diffstat (limited to 'src/starter/invokepluto.c')
-rw-r--r--src/starter/invokepluto.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/starter/invokepluto.c b/src/starter/invokepluto.c
index e18d6e38d..edc587124 100644
--- a/src/starter/invokepluto.c
+++ b/src/starter/invokepluto.c
@@ -11,7 +11,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * RCSID $Id: invokepluto.c 4632 2008-11-11 18:37:19Z martin $
+ * RCSID $Id: invokepluto.c 5050 2009-03-27 16:14:59Z andreas $
*/
#include <sys/types.h>
@@ -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