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.
Trac #777
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480386424-30876-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13284.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
... | ... |
@@ -378,7 +378,8 @@ process_sigterm (struct context *c) |
378 | 378 |
|
379 | 379 |
/** |
380 | 380 |
* If a restart signal is received during exit-notification, reset the |
381 |
- * signal and return true. |
|
381 |
+ * signal and return true. If its a soft restart signal from the event loop |
|
382 |
+ * which implies the loop cannot continue, remap to SIGTERM to exit promptly. |
|
382 | 383 |
*/ |
383 | 384 |
static bool |
384 | 385 |
ignore_restart_signals (struct context *c) |
... | ... |
@@ -388,10 +389,20 @@ ignore_restart_signals (struct context *c) |
388 | 388 |
if ( (c->sig->signal_received == SIGUSR1 || c->sig->signal_received == SIGHUP) && |
389 | 389 |
event_timeout_defined(&c->c2.explicit_exit_notification_interval) ) |
390 | 390 |
{ |
391 |
- msg (M_INFO, "Ignoring %s received during exit notification", |
|
392 |
- signal_name(c->sig->signal_received, true)); |
|
393 |
- signal_reset (c->sig); |
|
394 |
- ret = true; |
|
391 |
+ if (c->sig->source == SIG_SOURCE_HARD) |
|
392 |
+ { |
|
393 |
+ msg (M_INFO, "Ignoring %s received during exit notification", |
|
394 |
+ signal_name(c->sig->signal_received, true)); |
|
395 |
+ signal_reset (c->sig); |
|
396 |
+ ret = true; |
|
397 |
+ } |
|
398 |
+ else |
|
399 |
+ { |
|
400 |
+ msg (M_INFO, "Converting soft %s received during exit notification to SIGTERM", |
|
401 |
+ signal_name(c->sig->signal_received, true)); |
|
402 |
+ register_signal(c, SIGTERM, "exit-with-notification"); |
|
403 |
+ ret = false; |
|
404 |
+ } |
|
395 | 405 |
} |
396 | 406 |
#endif |
397 | 407 |
return ret; |