PanicSentinel: send SIGTERM only once

This commit is contained in:
Joakim Frostegård 2022-04-06 01:52:06 +02:00
parent b61b136b0c
commit 10997596fa

View file

@ -55,8 +55,9 @@ pub struct PanicSentinel(Arc<AtomicBool>);
impl Drop for PanicSentinel { impl Drop for PanicSentinel {
fn drop(&mut self) { fn drop(&mut self) {
self.0.store(true, Ordering::SeqCst); let already_triggered = self.0.fetch_or(true, Ordering::SeqCst);
if !already_triggered {
if unsafe { libc::raise(15) } == -1 { if unsafe { libc::raise(15) } == -1 {
panic!( panic!(
"Could not raise SIGTERM: {:#}", "Could not raise SIGTERM: {:#}",
@ -64,6 +65,7 @@ impl Drop for PanicSentinel {
) )
} }
} }
}
} }
/// Extract response peers /// Extract response peers