From 051d23d60d4898d331d046861035165bf2e6cd23 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Mon, 17 Jul 2017 22:53:30 +0200 Subject: [PATCH] Fix event handler dispatching --- src/client/mod.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 05e82e91e41..93e09ce38db 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -39,7 +39,7 @@ use self::dispatch::dispatch; use std::sync::{self, Arc}; use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; use parking_lot::Mutex; -use tokio_core::reactor::{Core, Handle}; +use tokio_core::reactor::Core; use futures; use std::time::Duration; use std::mem; @@ -681,9 +681,8 @@ impl Client { } }}; - let handle = core.handle(); futures.push(futures::future::lazy(move || { - monitor_shard(monitor_info, handle); + monitor_shard(monitor_info); futures::future::ok::<(), ()>(()) })); }, @@ -776,8 +775,8 @@ fn boot_shard(info: &BootInfo) -> Result { Err(Error::Client(ClientError::ShardBootFailure)) } -fn monitor_shard(mut info: MonitorInfo, handle: Handle) { - handle_shard(&mut info, &handle); +fn monitor_shard(mut info: MonitorInfo) { + handle_shard(&mut info); let mut handle_still = HANDLE_STILL.load(Ordering::Relaxed); @@ -804,7 +803,7 @@ fn monitor_shard(mut info: MonitorInfo, handle: Ha } if boot_successful { - handle_shard(&mut info, &handle); + handle_shard(&mut info); } else { break; } @@ -826,7 +825,10 @@ fn monitor_shard(mut info: MonitorInfo, handle: Ha } } -fn handle_shard(info: &mut MonitorInfo, handle: &Handle) { +fn handle_shard(info: &mut MonitorInfo) { + let mut core = Core::new().unwrap(); + let handle = core.handle(); + // This is currently all ducktape. Redo this. while HANDLE_STILL.load(Ordering::Relaxed) { { @@ -908,6 +910,8 @@ fn handle_shard(info: &mut MonitorInfo, handle: &H &info.event_handler, &handle); }} + + core.turn(None); } }