Removing unecessary locks causing dead-locks

This commit is contained in:
Tomusdrw
2016-02-10 14:49:31 +01:00
parent 31bcc541d0
commit 0d121dd51a
5 changed files with 24 additions and 35 deletions

View File

@@ -60,7 +60,7 @@ impl BlockQueueInfo {
/// A queue of blocks. Sits between network or other I/O and the BlockChain.
/// Sorts them ready for blockchain insertion.
pub struct BlockQueue {
panic_handler: SafeStringPanicHandler,
panic_handler: Arc<StringPanicHandler>,
engine: Arc<Box<Engine>>,
more_to_verify: Arc<Condvar>,
verification: Arc<Mutex<Verification>>,
@@ -115,7 +115,7 @@ impl BlockQueue {
let ready_signal = Arc::new(QueueSignal { signalled: AtomicBool::new(false), message_channel: message_channel });
let deleting = Arc::new(AtomicBool::new(false));
let empty = Arc::new(Condvar::new());
let panic_handler = StringPanicHandler::new_thread_safe();
let panic_handler = StringPanicHandler::new_arc();
let mut verifiers: Vec<JoinHandle<()>> = Vec::new();
let thread_count = max(::num_cpus::get(), 3) - 2;
@@ -131,8 +131,7 @@ impl BlockQueue {
thread::Builder::new()
.name(format!("Verifier #{}", i))
.spawn(move || {
let mut panic = panic_handler.lock().unwrap();
panic.catch_panic(move || {
panic_handler.catch_panic(move || {
BlockQueue::verify(verification, engine, more_to_verify, ready_signal, deleting, empty)
}).unwrap()
})

View File

@@ -162,7 +162,7 @@ pub struct Client {
block_queue: RwLock<BlockQueue>,
report: RwLock<ClientReport>,
import_lock: Mutex<()>,
panic_handler: SafeStringPanicHandler,
panic_handler: Arc<StringPanicHandler>,
}
const HISTORY: u64 = 1000;
@@ -211,9 +211,9 @@ impl Client {
}
let block_queue = BlockQueue::new(engine.clone(), message_channel);
let panic_handler = StringPanicHandler::new_thread_safe();
let panic_handler = StringPanicHandler::new_arc();
let panic = panic_handler.clone();
block_queue.on_panic(move |t: &String| panic.lock().unwrap().notify_all(t));
block_queue.on_panic(move |t: &String| panic.notify_all(t));
Ok(Arc::new(Client {
chain: chain,