mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
send a reply when thread is done exiting
fixed failing tests fix tests handle error instead of just unwrappng it create a channel per thread and update tests with a call to rx.recv().unwrap()
This commit is contained in:
parent
e8e7c6545d
commit
88980dc7a5
6 changed files with 33 additions and 11 deletions
|
@ -817,11 +817,15 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
|||
}
|
||||
|
||||
fn handle_exit(&mut self) {
|
||||
// Channels to recieve signals when threads are done exiting.
|
||||
let (core_sender, core_receiver) = ipc::channel().expect("Failed to create IPC channel!");
|
||||
let (storage_sender, storage_receiver) = ipc::channel().expect("Failed to create IPC channel!");
|
||||
|
||||
for (_id, ref pipeline) in &self.pipelines {
|
||||
pipeline.exit();
|
||||
}
|
||||
self.image_cache_thread.exit();
|
||||
if let Err(e) = self.resource_threads.send(net_traits::CoreResourceMsg::Exit) {
|
||||
if let Err(e) = self.resource_threads.send(net_traits::CoreResourceMsg::Exit(core_sender)) {
|
||||
warn!("Exit resource thread failed ({})", e);
|
||||
}
|
||||
if let Some(ref chan) = self.devtools_chan {
|
||||
|
@ -830,7 +834,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
|||
warn!("Exit devtools failed ({})", e);
|
||||
}
|
||||
}
|
||||
if let Err(e) = self.resource_threads.send(StorageThreadMsg::Exit) {
|
||||
if let Err(e) = self.resource_threads.send(StorageThreadMsg::Exit(storage_sender)) {
|
||||
warn!("Exit storage thread failed ({})", e);
|
||||
}
|
||||
|
||||
|
@ -842,6 +846,15 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
|||
warn!("Exit bluetooth thread failed ({})", e);
|
||||
}
|
||||
self.font_cache_thread.exit();
|
||||
|
||||
// Receive exit signals from threads.
|
||||
if let Err(e) = core_receiver.recv() {
|
||||
warn!("Exit resource thread failed ({})", e);
|
||||
}
|
||||
if let Err(e) = storage_receiver.recv() {
|
||||
warn!("Exit storage thread failed ({})", e);
|
||||
}
|
||||
|
||||
self.compositor_proxy.send(ToCompositorMsg::ShutdownComplete);
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ impl ResourceChannelManager {
|
|||
CoreResourceMsg::Synchronize(sender) => {
|
||||
let _ = sender.send(());
|
||||
}
|
||||
CoreResourceMsg::Exit => {
|
||||
CoreResourceMsg::Exit(sender) => {
|
||||
if let Some(ref config_dir) = opts::get().config_dir {
|
||||
match self.resource_manager.auth_cache.read() {
|
||||
Ok(auth_cache) => write_json_to_file(&*auth_cache, config_dir, "auth_cache.json"),
|
||||
|
@ -225,6 +225,7 @@ impl ResourceChannelManager {
|
|||
Err(_) => warn!("Error writing hsts list to disk"),
|
||||
}
|
||||
}
|
||||
let _ = sender.send(());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,10 +74,11 @@ impl StorageManager {
|
|||
StorageThreadMsg::Clear(sender, url, storage_type) => {
|
||||
self.clear(sender, url, storage_type)
|
||||
}
|
||||
StorageThreadMsg::Exit => {
|
||||
StorageThreadMsg::Exit(sender) => {
|
||||
if let Some(ref config_dir) = opts::get().config_dir {
|
||||
resource_thread::write_json_to_file(&self.local_data, config_dir, "local_data.json");
|
||||
}
|
||||
let _ = sender.send(());
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,8 +340,9 @@ pub enum CoreResourceMsg {
|
|||
Cancel(ResourceId),
|
||||
/// Synchronization message solely for knowing the state of the ResourceChannelManager loop
|
||||
Synchronize(IpcSender<()>),
|
||||
/// Break the load handler loop and exit
|
||||
Exit,
|
||||
/// Break the load handler loop, send a reply when done cleaning up local resources
|
||||
// and exit
|
||||
Exit(IpcSender<()>),
|
||||
}
|
||||
|
||||
/// Initialized but unsent request. Encapsulates everything necessary to instruct
|
||||
|
|
|
@ -35,6 +35,6 @@ pub enum StorageThreadMsg {
|
|||
/// clears the associated storage data by removing all the key/value pairs
|
||||
Clear(IpcSender<bool>, Url, StorageType),
|
||||
|
||||
/// shut down this thread
|
||||
Exit
|
||||
/// send a reply when done cleaning up thread resources and then shut it down
|
||||
Exit(IpcSender<()>)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue