Skip to content

Commit fbdf3c4

Browse files
committed
Do suggested renames
Signed-off-by: Bob Weinand <[email protected]>
1 parent fc331eb commit fbdf3c4

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

sidecar/src/watchdog.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,31 @@ impl Watchdog {
4949
let still_alive = Arc::new(AtomicU32::new(0));
5050
let still_alive_thread = still_alive.clone();
5151

52+
const SHUTDOWN: u32 = u32::MAX;
53+
5254
let interval = self.interval.period();
5355
std::thread::spawn(move || {
54-
let mut repeats = false;
56+
let mut maybe_stuck = false;
5557
let mut last = 0;
5658
loop {
5759
std::thread::sleep(interval);
5860
let current = still_alive_thread.load(Ordering::Relaxed);
5961
if last != current {
60-
if current == u32::MAX {
62+
if current == SHUTDOWN {
6163
return;
6264
}
6365
last = current;
64-
repeats = false;
66+
maybe_stuck = false;
6567
} else {
66-
if repeats {
68+
if maybe_stuck {
6769
std::thread::spawn(move || {
6870
error!("Watchdog timeout: Sidecar stuck for at least {} seconds. Sending SIGABRT, possibly dumping core.", interval.as_secs());
6971
});
7072
// wait 1 seconds to give log a chance to flush - then kill the process
7173
std::thread::sleep(Duration::from_secs(1));
7274
unsafe { libc::abort() };
7375
}
74-
repeats = true;
76+
maybe_stuck = true;
7577
}
7678
}
7779
});
@@ -101,7 +103,7 @@ impl Watchdog {
101103

102104
},
103105
_ = self.shutdown_receiver.recv() => {
104-
still_alive.store(u32::MAX, Ordering::Relaxed);
106+
still_alive.store(SHUTDOWN, Ordering::Relaxed);
105107
return
106108
},
107109
}

0 commit comments

Comments
 (0)