Skip to content

Commit

Permalink
[HOTFIX] Resolve race condition in exit signal
Browse files Browse the repository at this point in the history
- Swaps to SIGCHLD for termination
- Switch to Ordering::SeqCst
  • Loading branch information
zellio committed Nov 17, 2023
1 parent 67118f6 commit f926037
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bimini-core/src/proc/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -215,7 +215,7 @@ 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)?;
Expand Down

0 comments on commit f926037

Please sign in to comment.