diff options
author | Daniil Baturin <daniil@vyos.io> | 2021-08-02 03:26:42 -0500 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2021-08-02 03:26:42 -0500 |
commit | 50a1392564611951142b8a2ca7d2af0dc4cb5cc7 (patch) | |
tree | 0432964f270defd46bfef59062cf208bde13d165 /src/conf_mode/ipsec-settings.py | |
parent | 503bdbd444d993ddee0687e7ef5a51f3ad738b25 (diff) | |
download | vyos-1x-50a1392564611951142b8a2ca7d2af0dc4cb5cc7.tar.gz vyos-1x-50a1392564611951142b8a2ca7d2af0dc4cb5cc7.zip |
T3697: explicitly wait for the charon process to respond to strokes
Diffstat (limited to 'src/conf_mode/ipsec-settings.py')
-rwxr-xr-x | src/conf_mode/ipsec-settings.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/conf_mode/ipsec-settings.py b/src/conf_mode/ipsec-settings.py index cbe4ba376..7ba2284d8 100755 --- a/src/conf_mode/ipsec-settings.py +++ b/src/conf_mode/ipsec-settings.py @@ -224,12 +224,18 @@ def restart_ipsec(): # so we can't assume it's running and have to check and wait if needed. # First, wait for charon to get started by the old ipsec.pl script. - wait_for_file_write_complete(charon_pidfile, timeout=120) - - # Now actually restart the daemon - wait_for_file_write_complete(charon_pidfile, - pre_hook=(lambda: call('ipsec restart >&/dev/null')), - timeout=120) + from time import sleep, time + from os import system + now = time() + while True: + if (time() - now) > 60: + raise OSError("Timeout waiting for the IPsec process to become responsive") + # There's no oficial "no-op" stroke, + # so we use memusage to check if charon is alive and responsive + res = system("ipsec stroke memusage >&/dev/null") + if res == 0: + break + sleep(5) # Force configuration load call('swanctl -q >&/dev/null') |