From 63b3e000c9141f4ca03a374354da26334257bc18 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Tue, 7 Jun 2016 00:44:20 -0400 Subject: [PATCH] Ignore SIGUSR1/SIGHUP during exit notification This allows exit notification to complete and finally trigger SIGTERM. The current practice of allowing a restart in this state clears the exit notification timer data and thus loses the SIGTERM. Trac #687 Signed-off-by: Selva Nair Acked-by: Gert Doering Message-Id: <1465274660-11009-2-git-send-email-selva.nair@gmail.com> URL: http://article.gmane.org/gmane.network.openvpn.devel/11814 Signed-off-by: Gert Doering --- src/openvpn/sig.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/openvpn/sig.c b/src/openvpn/sig.c index f903fc0ef..718b78600 100644 --- a/src/openvpn/sig.c +++ b/src/openvpn/sig.c @@ -376,12 +376,35 @@ process_sigterm (struct context *c) return ret; } +/** + * If a restart signal is received during exit-notification, reset the + * signal and return true. + */ +static bool +ignore_restart_signals (struct context *c) +{ + bool ret = false; +#ifdef ENABLE_OCC + if ( (c->sig->signal_received == SIGUSR1 || c->sig->signal_received == SIGHUP) && + event_timeout_defined(&c->c2.explicit_exit_notification_interval) ) + { + msg (M_INFO, "Ignoring %s received during exit notification", + signal_name(c->sig->signal_received, true)); + signal_reset (c->sig); + ret = true; + } +#endif + return ret; +} + bool process_signal (struct context *c) { bool ret = true; - if (c->sig->signal_received == SIGTERM || c->sig->signal_received == SIGINT) + if (ignore_restart_signals (c)) + ret = false; + else if (c->sig->signal_received == SIGTERM || c->sig->signal_received == SIGINT) { ret = process_sigterm (c); } -- 2.47.2