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>
... | ... |
@@ -168,9 +168,12 @@ be reset by restarts. |
168 | 168 |
|
169 | 169 |
OpenVPN will indicate that it is in a hold state by |
170 | 170 |
sending a real-time notification to the management |
171 |
-client: |
|
171 |
+client, the parameter indicates how long OpenVPN would |
|
172 |
+wait without UI (as influenced by connect-retry exponential |
|
173 |
+backoff). The UI needs to wait for releasing the hold if it |
|
174 |
+wants similar behavior: |
|
172 | 175 |
|
173 |
- >HOLD:Waiting for hold release |
|
176 |
+ >HOLD:Waiting for hold release:10 |
|
174 | 177 |
|
175 | 178 |
Command examples: |
176 | 179 |
|
... | ... |
@@ -1960,16 +1960,17 @@ do_deferred_options (struct context *c, const unsigned int found) |
1960 | 1960 |
} |
1961 | 1961 |
|
1962 | 1962 |
/* |
1963 |
- * Possible hold on initialization |
|
1963 |
+ * Possible hold on initialization, holdtime is the |
|
1964 |
+ * time OpenVPN would wait without management |
|
1964 | 1965 |
*/ |
1965 | 1966 |
static bool |
1966 |
-do_hold (void) |
|
1967 |
+do_hold (int holdtime) |
|
1967 | 1968 |
{ |
1968 | 1969 |
#ifdef ENABLE_MANAGEMENT |
1969 | 1970 |
if (management) |
1970 | 1971 |
{ |
1971 | 1972 |
/* block until management hold is released */ |
1972 |
- if (management_hold (management)) |
|
1973 |
+ if (management_hold (management, holdtime)) |
|
1973 | 1974 |
return true; |
1974 | 1975 |
} |
1975 | 1976 |
#endif |
... | ... |
@@ -2027,8 +2028,10 @@ socket_restart_pause (struct context *c) |
2027 | 2027 |
c->persist.restart_sleep_seconds = 0; |
2028 | 2028 |
|
2029 | 2029 |
/* do managment hold on context restart, i.e. second, third, fourth, etc. initialization */ |
2030 |
- if (do_hold ()) |
|
2030 |
+ if (do_hold (sec)) |
|
2031 |
+ { |
|
2031 | 2032 |
sec = 0; |
2033 |
+ } |
|
2032 | 2034 |
|
2033 | 2035 |
if (sec) |
2034 | 2036 |
{ |
... | ... |
@@ -2046,7 +2049,7 @@ do_startup_pause (struct context *c) |
2046 | 2046 |
if (!c->first_time) |
2047 | 2047 |
socket_restart_pause (c); |
2048 | 2048 |
else |
2049 |
- do_hold (); /* do management hold on first context initialization */ |
|
2049 |
+ do_hold (0); /* do management hold on first context initialization */ |
|
2050 | 2050 |
} |
2051 | 2051 |
|
2052 | 2052 |
/* |
... | ... |
@@ -3431,7 +3434,7 @@ open_management (struct context *c) |
3431 | 3431 |
} |
3432 | 3432 |
|
3433 | 3433 |
/* initial management hold, called early, before first context initialization */ |
3434 |
- do_hold (); |
|
3434 |
+ do_hold (0); |
|
3435 | 3435 |
if (IS_SIG (c)) |
3436 | 3436 |
{ |
3437 | 3437 |
msg (M_WARN, "Signal received from management interface, exiting"); |
... | ... |
@@ -3332,12 +3332,13 @@ management_should_daemonize (struct management *man) |
3332 | 3332 |
* Return true if the caller should not sleep for an additional time interval. |
3333 | 3333 |
*/ |
3334 | 3334 |
bool |
3335 |
-management_hold (struct management *man) |
|
3335 |
+management_hold (struct management *man, int holdtime) |
|
3336 | 3336 |
{ |
3337 | 3337 |
if (management_would_hold (man)) |
3338 | 3338 |
{ |
3339 | 3339 |
volatile int signal_received = 0; |
3340 | 3340 |
const bool standalone_disabled_save = man->persist.standalone_disabled; |
3341 |
+ struct gc_arena gc = gc_new (); |
|
3341 | 3342 |
|
3342 | 3343 |
man->persist.standalone_disabled = false; /* This is so M_CLIENT messages will be correctly passed through msg() */ |
3343 | 3344 |
man->persist.special_state_msg = NULL; |
... | ... |
@@ -3347,7 +3348,9 @@ management_hold (struct management *man) |
3347 | 3347 |
|
3348 | 3348 |
if (!signal_received) |
3349 | 3349 |
{ |
3350 |
- man->persist.special_state_msg = ">HOLD:Waiting for hold release"; |
|
3350 |
+ struct buffer out = alloc_buf_gc (128, &gc); |
|
3351 |
+ buf_printf (&out, ">HOLD:Waiting for hold release:%d", holdtime); |
|
3352 |
+ man->persist.special_state_msg = BSTR (&out); |
|
3351 | 3353 |
msg (M_CLIENT, "%s", man->persist.special_state_msg); |
3352 | 3354 |
|
3353 | 3355 |
/* run command processing event loop until we get our username/password */ |
... | ... |
@@ -3366,6 +3369,7 @@ management_hold (struct management *man) |
3366 | 3366 |
man->persist.special_state_msg = NULL; |
3367 | 3367 |
man->settings.mansig &= ~MANSIG_IGNORE_USR1_HUP; |
3368 | 3368 |
|
3369 |
+ gc_free (&gc); |
|
3369 | 3370 |
return true; |
3370 | 3371 |
} |
3371 | 3372 |
return false; |
... | ... |
@@ -396,7 +396,7 @@ int managment_android_persisttun_action (struct management *man); |
396 | 396 |
|
397 | 397 |
bool management_should_daemonize (struct management *man); |
398 | 398 |
bool management_would_hold (struct management *man); |
399 |
-bool management_hold (struct management *man); |
|
399 |
+bool management_hold (struct management *man, int holdtime); |
|
400 | 400 |
|
401 | 401 |
void management_event_loop_n_seconds (struct management *man, int sec); |
402 | 402 |
|