removed panic handlers (#5895)

This commit is contained in:
Arkadiy Paronyan
2017-06-22 19:00:53 +02:00
committed by GitHub
parent dc548315b8
commit 4d5280e43c
12 changed files with 20 additions and 305 deletions

View File

@@ -141,7 +141,6 @@ pub struct Client {
block_queue: BlockQueue,
report: RwLock<ClientReport>,
import_lock: Mutex<()>,
panic_handler: Arc<PanicHandler>,
verifier: Box<Verifier>,
miner: Arc<Miner>,
sleep_state: Mutex<SleepState>,
@@ -213,8 +212,6 @@ impl Client {
let engine = spec.engine.clone();
let block_queue = BlockQueue::new(config.queue.clone(), engine.clone(), message_channel.clone(), config.verifier_type.verifying_seal());
let panic_handler = PanicHandler::new_in_arc();
panic_handler.forward_from(&block_queue);
let awake = match config.mode { Mode::Dark(..) | Mode::Off => false, _ => true };
@@ -234,7 +231,6 @@ impl Client {
block_queue: block_queue,
report: RwLock::new(Default::default()),
import_lock: Mutex::new(()),
panic_handler: panic_handler,
miner: miner,
io_channel: Mutex::new(message_channel),
notify: RwLock::new(Vec::new()),
@@ -1723,12 +1719,6 @@ impl EngineClient for Client {
}
}
impl MayPanic for Client {
fn on_panic<F>(&self, closure: F) where F: OnPanicListener {
self.panic_handler.on_panic(closure);
}
}
impl ProvingBlockChainClient for Client {
fn prove_storage(&self, key1: H256, key2: H256, id: BlockId) -> Option<(Vec<Bytes>, H256)> {
self.state_at(id)

View File

@@ -56,7 +56,6 @@ pub struct ClientService {
io_service: Arc<IoService<ClientIoMessage>>,
client: Arc<Client>,
snapshot: Arc<SnapshotService>,
panic_handler: Arc<PanicHandler>,
database: Arc<Database>,
_stop_guard: ::devtools::StopGuard,
}
@@ -72,9 +71,7 @@ impl ClientService {
miner: Arc<Miner>,
) -> Result<ClientService, Error>
{
let panic_handler = PanicHandler::new_in_arc();
let io_service = IoService::<ClientIoMessage>::start()?;
panic_handler.forward_from(&io_service);
info!("Configured for {} using {} engine", Colour::White.bold().paint(spec.name.clone()), Colour::Yellow.bold().paint(spec.engine.name()));
@@ -109,7 +106,6 @@ impl ClientService {
};
let snapshot = Arc::new(SnapshotService::new(snapshot_params)?);
panic_handler.forward_from(&*client);
let client_io = Arc::new(ClientIoHandler {
client: client.clone(),
snapshot: snapshot.clone(),
@@ -125,7 +121,6 @@ impl ClientService {
io_service: Arc::new(io_service),
client: client,
snapshot: snapshot,
panic_handler: panic_handler,
database: db,
_stop_guard: stop_guard,
})
@@ -160,12 +155,6 @@ impl ClientService {
pub fn db(&self) -> Arc<KeyValueDB> { self.database.clone() }
}
impl MayPanic for ClientService {
fn on_panic<F>(&self, closure: F) where F: OnPanicListener {
self.panic_handler.on_panic(closure);
}
}
/// IO interface for the Client handler
struct ClientIoHandler {
client: Arc<Client>,

View File

@@ -125,7 +125,6 @@ struct Sizes {
/// A queue of items to be verified. Sits between network or other I/O and the `BlockChain`.
/// Keeps them in the same order as inserted, minus invalid items.
pub struct VerificationQueue<K: Kind> {
panic_handler: Arc<PanicHandler>,
engine: Arc<Engine>,
more_to_verify: Arc<SCondvar>,
verification: Arc<Verification<K>>,
@@ -221,7 +220,6 @@ impl<K: Kind> VerificationQueue<K> {
message_channel: Mutex::new(message_channel),
});
let empty = Arc::new(SCondvar::new());
let panic_handler = PanicHandler::new_in_arc();
let scale_verifiers = config.verifier_settings.scale_verifiers;
let num_cpus = ::num_cpus::get();
@@ -236,7 +234,6 @@ impl<K: Kind> VerificationQueue<K> {
for i in 0..max_verifiers {
debug!(target: "verification", "Adding verification thread #{}", i);
let panic_handler = panic_handler.clone();
let verification = verification.clone();
let engine = engine.clone();
let wait = more_to_verify.clone();
@@ -247,17 +244,15 @@ impl<K: Kind> VerificationQueue<K> {
let handle = thread::Builder::new()
.name(format!("Verifier #{}", i))
.spawn(move || {
panic_handler.catch_panic(move || {
VerificationQueue::verify(
verification,
engine,
wait,
ready,
empty,
state,
i,
)
}).unwrap()
VerificationQueue::verify(
verification,
engine,
wait,
ready,
empty,
state,
i,
)
})
.expect("Failed to create verifier thread.");
verifier_handles.push(handle);
@@ -265,7 +260,6 @@ impl<K: Kind> VerificationQueue<K> {
VerificationQueue {
engine: engine,
panic_handler: panic_handler,
ready_signal: ready_signal,
more_to_verify: more_to_verify,
verification: verification,
@@ -692,12 +686,6 @@ impl<K: Kind> VerificationQueue<K> {
}
}
impl<K: Kind> MayPanic for VerificationQueue<K> {
fn on_panic<F>(&self, closure: F) where F: OnPanicListener {
self.panic_handler.on_panic(closure);
}
}
impl<K: Kind> Drop for VerificationQueue<K> {
fn drop(&mut self) {
trace!(target: "shutdown", "[VerificationQueue] Closing...");