From fca019fbe949d5d5a5499c22fea3720d7ee23149 Mon Sep 17 00:00:00 2001 From: Bart Wensley Date: Wed, 27 May 2020 13:50:03 -0500 Subject: [PATCH] Allow VIM to shutdown when all FDs are used When the VIM attempts to shut down because it runs out of FDs, the shutdown code attempts to create a file, before it activates a SIGALRM timer that triggers fail safe shutdown. When all FDs have been consumed, the shutdown code hangs while creating the file and never shuts down. This is fixed by changing the shutdown code to first start the failsafe SIGALRM timer. That way the process is guaranteed to be terminated even if it hangs while attempting to create the file. Change-Id: I7184fe1333d2641227c193f7c8e2e7b1bebcfed8 Partial-Bug: 1862049 Signed-off-by: Bart Wensley --- nfv/centos/build_srpm.data | 2 +- nfv/nfv-vim/nfv_vim/vim.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nfv/centos/build_srpm.data b/nfv/centos/build_srpm.data index a80e9d02..e953e000 100755 --- a/nfv/centos/build_srpm.data +++ b/nfv/centos/build_srpm.data @@ -1 +1 @@ -TIS_PATCH_VER=78 +TIS_PATCH_VER=79 diff --git a/nfv/nfv-vim/nfv_vim/vim.py b/nfv/nfv-vim/nfv_vim/vim.py index b8dbc36a..923698f3 100755 --- a/nfv/nfv-vim/nfv_vim/vim.py +++ b/nfv/nfv-vim/nfv_vim/vim.py @@ -217,9 +217,12 @@ def process_main(): sys.exit(200) finally: - open(PROCESS_NOT_RUNNING_FILE, 'w').close() # Allow up to 10 seconds for the process to shut down. If the # process_finalize hangs, we will do a hard exit. signal.signal(signal.SIGALRM, _force_exit) signal.alarm(10) + # Touching this file after the SIGALRM timer is started. This is to + # ensure that in cases where we are terminating due to FD exhaustion + # we still shut down even if the open hangs. + open(PROCESS_NOT_RUNNING_FILE, 'w').close() process_finalize()