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.
cherry-picked from commit f25a0217e35f53c3110ebb226e1d1f3528152cb5
with (c->sig->source == SIG_SOURCE_HARD) changed to c->sig->hard
Trac: #777
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480470535-6287-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13310.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
... | ... |
@@ -362,7 +362,8 @@ process_sigterm (struct context *c) |
362 | 362 |
|
363 | 363 |
/** |
364 | 364 |
* If a restart signal is received during exit-notification, reset the |
365 |
- * signal and return true. |
|
365 |
+ * signal and return true. If its a soft restart signal from the event loop |
|
366 |
+ * which implies the loop cannot continue, remap to SIGTERM to exit promptly. |
|
366 | 367 |
*/ |
367 | 368 |
static bool |
368 | 369 |
ignore_restart_signals (struct context *c) |
... | ... |
@@ -372,10 +373,20 @@ ignore_restart_signals (struct context *c) |
372 | 372 |
if ( (c->sig->signal_received == SIGUSR1 || c->sig->signal_received == SIGHUP) && |
373 | 373 |
event_timeout_defined(&c->c2.explicit_exit_notification_interval) ) |
374 | 374 |
{ |
375 |
- msg (M_INFO, "Ignoring %s received during exit notification", |
|
376 |
- signal_name(c->sig->signal_received, true)); |
|
377 |
- signal_reset (c->sig); |
|
378 |
- ret = true; |
|
375 |
+ if (c->sig->hard) |
|
376 |
+ { |
|
377 |
+ msg (M_INFO, "Ignoring %s received during exit notification", |
|
378 |
+ signal_name(c->sig->signal_received, true)); |
|
379 |
+ signal_reset (c->sig); |
|
380 |
+ ret = true; |
|
381 |
+ } |
|
382 |
+ else |
|
383 |
+ { |
|
384 |
+ msg (M_INFO, "Converting soft %s received during exit notification to SIGTERM", |
|
385 |
+ signal_name(c->sig->signal_received, true)); |
|
386 |
+ register_signal(c, SIGTERM, "exit-with-notification"); |
|
387 |
+ ret = false; |
|
388 |
+ } |
|
379 | 389 |
} |
380 | 390 |
#endif |
381 | 391 |
return ret; |