diff options
author | Arne Schwabe | 2016-10-12 12:47:07 +0200 |
---|---|---|
committer | David Sommerseth | 2016-10-13 17:19:48 +0200 |
commit | 396d30c264e6cb6b9f57c3e566f3b71879999662 (patch) | |
tree | 94ebfdda7fb93920e7c001c9719a056cccc81a56 /src | |
parent | 88c4b9d6ad1d346931d9090b247e9e3d2d86bce7 (diff) | |
download | openvpn-396d30c264e6cb6b9f57c3e566f3b71879999662.zip openvpn-396d30c264e6cb6b9f57c3e566f3b71879999662.tar.gz |
Change the hold command to communicate the time that OpenVPN would wait to the UI.
Before the connect-retry change to do exponential backup this was not
necessary since the time was fixed. With the exponential backoff the
UI needs either to implement its own exponential backoff mechanism
or needs a way of knowing the value of OpenVPN internal mechansim.
Patch V2: Fixed typos noticed by Selva
[DS: Fixed a couple of whitespace errors in management_hold() at commit time]
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1476269227-13290-1-git-send-email-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12675.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/openvpn/init.c | 15 | ||||
-rw-r--r-- | src/openvpn/manage.c | 8 | ||||
-rw-r--r-- | src/openvpn/manage.h | 2 |
3 files changed, 16 insertions, 9 deletions
diff --git a/src/openvpn/init.c b/src/openvpn/init.c index af5d491..cc8e945 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1960,16 +1960,17 @@ do_deferred_options (struct context *c, const unsigned int found) } /* - * Possible hold on initialization + * Possible hold on initialization, holdtime is the + * time OpenVPN would wait without management */ static bool -do_hold (void) +do_hold (int holdtime) { #ifdef ENABLE_MANAGEMENT if (management) { /* block until management hold is released */ - if (management_hold (management)) + if (management_hold (management, holdtime)) return true; } #endif @@ -2027,8 +2028,10 @@ socket_restart_pause (struct context *c) c->persist.restart_sleep_seconds = 0; /* do managment hold on context restart, i.e. second, third, fourth, etc. initialization */ - if (do_hold ()) + if (do_hold (sec)) + { sec = 0; + } if (sec) { @@ -2046,7 +2049,7 @@ do_startup_pause (struct context *c) if (!c->first_time) socket_restart_pause (c); else - do_hold (); /* do management hold on first context initialization */ + do_hold (0); /* do management hold on first context initialization */ } /* @@ -3431,7 +3434,7 @@ open_management (struct context *c) } /* initial management hold, called early, before first context initialization */ - do_hold (); + do_hold (0); if (IS_SIG (c)) { msg (M_WARN, "Signal received from management interface, exiting"); diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index dcb1bc1..26a2f7e 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -3332,12 +3332,13 @@ management_should_daemonize (struct management *man) * Return true if the caller should not sleep for an additional time interval. */ bool -management_hold (struct management *man) +management_hold (struct management *man, int holdtime) { if (management_would_hold (man)) { volatile int signal_received = 0; const bool standalone_disabled_save = man->persist.standalone_disabled; + struct gc_arena gc = gc_new (); man->persist.standalone_disabled = false; /* This is so M_CLIENT messages will be correctly passed through msg() */ man->persist.special_state_msg = NULL; @@ -3347,7 +3348,9 @@ management_hold (struct management *man) if (!signal_received) { - man->persist.special_state_msg = ">HOLD:Waiting for hold release"; + struct buffer out = alloc_buf_gc (128, &gc); + buf_printf (&out, ">HOLD:Waiting for hold release:%d", holdtime); + man->persist.special_state_msg = BSTR (&out); msg (M_CLIENT, "%s", man->persist.special_state_msg); /* run command processing event loop until we get our username/password */ @@ -3366,6 +3369,7 @@ management_hold (struct management *man) man->persist.special_state_msg = NULL; man->settings.mansig &= ~MANSIG_IGNORE_USR1_HUP; + gc_free (&gc); return true; } return false; diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 988600f..50db38c 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -396,7 +396,7 @@ int managment_android_persisttun_action (struct management *man); bool management_should_daemonize (struct management *man); bool management_would_hold (struct management *man); -bool management_hold (struct management *man); +bool management_hold (struct management *man, int holdtime); void management_event_loop_n_seconds (struct management *man, int sec); |