File tree Expand file tree Collapse file tree 2 files changed +26
-18
lines changed
components/background_hang_monitor Expand file tree Collapse file tree 2 files changed +26
-18
lines changed Original file line number Diff line number Diff line change @@ -33,17 +33,19 @@ impl HangMonitorRegister {
3333 monitoring_enabled : bool ,
3434 ) -> Box < dyn BackgroundHangMonitorRegister > {
3535 let ( sender, port) = unbounded ( ) ;
36- let _ = thread:: Builder :: new ( ) . spawn ( move || {
37- let mut monitor = BackgroundHangMonitorWorker :: new (
38- constellation_chan,
39- control_port,
40- port,
41- monitoring_enabled,
42- ) ;
43- while monitor. run ( ) {
44- // Monitoring until all senders have been dropped...
45- }
46- } ) ;
36+ let _ = thread:: Builder :: new ( )
37+ . spawn ( move || {
38+ let mut monitor = BackgroundHangMonitorWorker :: new (
39+ constellation_chan,
40+ control_port,
41+ port,
42+ monitoring_enabled,
43+ ) ;
44+ while monitor. run ( ) {
45+ // Monitoring until all senders have been dropped...
46+ }
47+ } )
48+ . expect ( "Couldn't start BHM worker." ) ;
4749 Box :: new ( HangMonitorRegister {
4850 sender,
4951 monitoring_enabled,
Original file line number Diff line number Diff line change @@ -197,12 +197,18 @@ fn test_hang_monitoring_exit_signal() {
197197 ) ;
198198
199199 let ( exit_sender, exit_receiver) = ipc:: channel ( ) . expect ( "Failed to create IPC channel!" ) ;
200- // Send the exit message.
201- let _ = control_sender. send ( BackgroundHangMonitorControlMsg :: Exit ( exit_sender) ) ;
202-
203- // Assert we receive a confirmation back.
204- assert ! ( exit_receiver. recv( ) . is_ok( ) ) ;
205200
206- // Assert we get the exit signal.
207- while !closing. load ( Ordering :: SeqCst ) { }
201+ // Send the exit message.
202+ if control_sender
203+ . send ( BackgroundHangMonitorControlMsg :: Exit ( exit_sender) )
204+ . is_ok ( )
205+ {
206+ // Assert we receive a confirmation back.
207+ assert ! ( exit_receiver. recv( ) . is_ok( ) ) ;
208+
209+ // Assert we get the exit signal.
210+ while !closing. load ( Ordering :: SeqCst ) {
211+ thread:: sleep ( Duration :: from_millis ( 10 ) ) ;
212+ }
213+ }
208214}
You can’t perform that action at this time.
0 commit comments