File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments