Map restart signals from event loop to SIGTERM during exit-notification wait
PATCH 1/1 Map restart signals from event loop to SIGTERM during exit-notification wait
Commit 63b3e000c9.. fixed SIGTERM getting lost during exit notification by ignoring any restart signals triggered during this interval. However, as reported in Trac 777, this could result in repeated triggering of restart signals when the event loop cannot continue without restart due to IO errors or timeout.
Avoid by converting soft SIGUSR1 and SIGHUP signals received during exit-notify wait period to SIGTERM.
--- src/openvpn/sig.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
src/openvpn/sig.c +16 -5
@@ -378,7 +378,8 @@ process_sigterm (struct context *c)/** * If a restart signal is received during exit-notification, reset the -* signal and return true. +* signal and return true.If its a soft restart signal from the event loop +* which implies the loop cannot continue, remap to SIGTERM to exit promptly. */ static bool ignore_restart_signals (struct context *c)
@@ -388,10 +389,20 @@ ignore_restart_signals (struct context *c)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; +if (c->sig->source ==SIG_SOURCE_HARD ) + { +msg (M_INFO ,"Ignoring %s received during exit notification" , +signal_name (c->sig->signal_received, true)); +signal_reset (c->sig); + ret = true; + } +else + { +msg (M_INFO ,"Converting soft %s received during exit notification to SIGTERM" , +signal_name (c->sig->signal_received, true)); +register_signal (c,SIGTERM ,"exit-with-notification" ); + ret = false; + } }#endif return ret;
Signature · 1 line
2.1.4
ACK, thanks a lot.
I could reproduce the effect as well -- set "--explicit-exit-notify 5", try to connect to a non-responsive server (unused IP address, ...), and ~2 seconds before the 60 second timeout, press ctrl-c. Flooding of SIGUSR1 messages, no way to stop it (except "kill -9"), quite an annoyance.
With your patch, this changes to
Tue Nov 29 08:55:19 2016 UDPv4 link remote: [AF_INET]199.102.77.82:51189
^C
Tue Nov 29 08:56:17 2016 event_wait : Interrupted system call (code=4)
Tue Nov 29 08:56:17 2016 SIGTERM received, sending exit notification to peer
Tue Nov 29 08:56:19 2016 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity) Tue Nov 29 08:56:19 2016 TLS Error: TLS handshake failed
Tue Nov 29 08:56:19 2016 Converting soft SIGUSR1 received during exit notification to SIGTERM
Tue Nov 29 08:56:19 2016 SIGTERM[soft,exit-with-notification] received, process exiting
.. which fixes the issue for good.
"Real signals" are still ignored (kill -USR1 from another window):
Tue Nov 29 08:58:19 2016 event_wait : Interrupted system call (code=4) Tue Nov 29 08:58:19 2016 Ignoring SIGUSR1 received during exit notification
(or pressing ctrl-c a second time while it's waiting for the exit notification to proceed)
(Also, the explanation and the code change make sense :-) )
I've added a blank to the comment line ("true.If" -> "true. If").
Your patch has been applied to the master branch.
commit f25a0217e35f53c3110ebb226e1d1f3528152cb5
Author: Selva Nair Date: Mon Nov 28 21:27:04 2016 -0500
Map restart signals from event loop to SIGTERM during exit-notification wait
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg13284.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Quoted 11 lines · Gert Doering
.. which fixes the issue for good.
"Real signals" are still ignored (kill -USR1 from another window):
Tue Nov 29 08:58:19 2016
event_wait: Interrupted system call (code=4) Tue Nov 29 08:58:19 2016 Ignoring SIGUSR1 received during exit notification(or pressing ctrl-c a second time while it's waiting for the exit notification
to proceed)
Just to be sure, I think the second ctrl-C or SIGTERM during exit-notify wait should cause a prompt exit without waiting for exit-notify to complete. That was the original behaviour and is supposed to be unchanged...
Selva
Hi,
Quoted 3 lines · Selva Nair
Just to be sure, I think the second ctrl-C or SIGTERM during exit-notify wait should cause a prompt exit without waiting for exit-notify to complete. That was the original behaviour and is supposed to be unchanged...
It does :-)
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...