From efb4c58c121e9240750b159d9649c520029da158 Mon Sep 17 00:00:00 2001 From: Zachary Elliott Date: Fri, 17 Nov 2023 09:13:59 -0500 Subject: [PATCH] [HOTFIX] Resolve race condition in exit signal - Switch to Ordering::SeqCst --- bimini-core/src/proc/controller.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bimini-core/src/proc/controller.rs b/bimini-core/src/proc/controller.rs index 7c2944b..d11b055 100644 --- a/bimini-core/src/proc/controller.rs +++ b/bimini-core/src/proc/controller.rs @@ -74,9 +74,9 @@ impl Controller { None, )?; - while sf_runlock.load(Ordering::Relaxed) { + while sf_runlock.load(Ordering::SeqCst) { match signal_config.parent_signals().wait() { - Ok(signal) if sf_runlock.load(Ordering::Relaxed) => { + Ok(signal) if sf_runlock.load(Ordering::SeqCst) => { tracing::info!("Passing signal to child: {signal}"); signal::kill(child_pid, signal).map_err(|eno| { @@ -115,7 +115,7 @@ impl Controller { )); } - self.sf_runlock.store(true, Ordering::Release); + self.sf_runlock.store(true, Ordering::SeqCst); let runlock_clone = Arc::clone(&self.sf_runlock); let signal_config = self.signal_config.clone(); @@ -215,10 +215,10 @@ impl Controller { tracing::trace!("Received child status code: {rc}. Cleaning up"); if let Some(signal_forwarder) = self.signal_forwarder { tracing::trace!("Releasing signal_forwarding loop runlock"); - self.sf_runlock.store(false, Ordering::Release); + self.sf_runlock.swap(false, Ordering::SeqCst); tracing::trace!("Sending final SIGTERM to signal_forwarding thread"); - signal::kill(unistd::Pid::from_raw(0), signal::SIGCHLD)?; + signal::kill(unistd::Pid::from_raw(0), signal::SIGTERM)?; tracing::trace!("Joining signal_forwarding thread"); signal_forwarder.join()??;