Cleaner binary shutdown system (#8284)
* Cleaner shutdown system when executing * Simplify set_exit_handler for Client * Minor change * Fix submodule
This commit is contained in:
@@ -220,7 +220,7 @@ pub struct Client {
|
||||
registrar_address: Option<Address>,
|
||||
|
||||
/// A closure to call when we want to restart the client
|
||||
exit_handler: Mutex<Option<Box<Fn(bool, Option<String>) + 'static + Send>>>,
|
||||
exit_handler: Mutex<Option<Box<Fn(String) + 'static + Send>>>,
|
||||
|
||||
importer: Importer,
|
||||
}
|
||||
@@ -825,8 +825,11 @@ impl Client {
|
||||
self.notify.write().push(Arc::downgrade(&target));
|
||||
}
|
||||
|
||||
/// Set a closure to call when we want to restart the client
|
||||
pub fn set_exit_handler<F>(&self, f: F) where F: Fn(bool, Option<String>) + 'static + Send {
|
||||
/// Set a closure to call when the client wants to be restarted.
|
||||
///
|
||||
/// The parameter passed to the callback is the name of the new chain spec to use after
|
||||
/// the restart.
|
||||
pub fn set_exit_handler<F>(&self, f: F) where F: Fn(String) + 'static + Send {
|
||||
*self.exit_handler.lock() = Some(Box::new(f));
|
||||
}
|
||||
|
||||
@@ -1625,7 +1628,7 @@ impl BlockChainClient for Client {
|
||||
return;
|
||||
}
|
||||
if let Some(ref h) = *self.exit_handler.lock() {
|
||||
(*h)(true, Some(new_spec_name));
|
||||
(*h)(new_spec_name);
|
||||
} else {
|
||||
warn!("Not hypervised; cannot change chain.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user