[network-manager-openswan/lr/reliability: 1/2] service: retry the ipsec auto --ready with some timeout
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openswan/lr/reliability: 1/2] service: retry the ipsec auto --ready with some timeout
- Date: Fri, 21 Aug 2015 13:35:16 +0000 (UTC)
commit 925cde81255d5d9487156833e792f706709e0767
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Fri Aug 21 15:26:09 2015 +0200
service: retry the ipsec auto --ready with some timeout
ipsec setup start needs some time to start.
src/nm-openswan-service.c | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/src/nm-openswan-service.c b/src/nm-openswan-service.c
index 2251cf1..a1c044d 100644
--- a/src/nm-openswan-service.c
+++ b/src/nm-openswan-service.c
@@ -88,6 +88,7 @@ typedef struct {
GPid pid;
guint watch_id;
+ guint retries;
ConnectStep connect_step;
NMConnection *connection;
@@ -443,6 +444,19 @@ connect_failed (NMOpenSwanPlugin *self,
nm_vpn_plugin_failure (NM_VPN_PLUGIN (self), reason);
}
+static gboolean
+retry_cb (gpointer user_data)
+{
+ NMOpenSwanPlugin *self = NM_OPENSWAN_PLUGIN (user_data);
+ GError *error = NULL;
+
+ if (!connect_step (self, &error))
+ connect_failed (self, TRUE, error, NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
+ g_clear_error (&error);
+
+ return FALSE;
+}
+
static void
child_watch_cb (GPid pid, gint status, gpointer user_data)
{
@@ -466,17 +480,25 @@ child_watch_cb (GPid pid, gint status, gpointer user_data)
if (WIFEXITED (status)) {
ret = WEXITSTATUS (status);
if (ret)
- g_warning ("Spawn: child %d exited with error code %d", pid, ret);
+ g_message ("Spawn: child %d exited with error code %d", pid, ret);
} else
g_warning ("Spawn: child %d died unexpectedly", pid);
/* Reap child */
waitpid (pid, NULL, WNOHANG);
+ if (ret != 0 && priv->retries) {
+ priv->retries--;
+ g_message ("Spawn: %d more tries...", priv->retries);
+ g_timeout_add (100, retry_cb, self);
+ return;
+ }
+
if (ret == 0) {
/* Success; do the next connect step */
do_stop = TRUE;
priv->connect_step++;
+ priv->retries = 0;
if (!connect_step (self, &error))
ret = 1;
}
@@ -1009,6 +1031,8 @@ connect_step (NMOpenSwanPlugin *self, GError **error)
return TRUE;
case CONNECT_STEP_WAIT_READY:
+ if (!priv->retries)
+ priv->retries = 30;
if (!do_spawn (&priv->pid, NULL, NULL, error, priv->ipsec_path, "auto", "--ready", NULL))
return FALSE;
priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]