From 69f1f310b6f337ae37a70c3d93e77abc5ff76571 Mon Sep 17 00:00:00 2001 From: arkpar Date: Sat, 16 Jan 2016 13:29:51 +0100 Subject: [PATCH] Minor timers fix --- src/network/host.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/network/host.rs b/src/network/host.rs index 8b1038c8a..99e8b5e7c 100644 --- a/src/network/host.rs +++ b/src/network/host.rs @@ -600,14 +600,12 @@ impl IoHandler> for Host where Messa FIRST_CONNECTION ... LAST_CONNECTION => self.connection_timeout(token, io), NODETABLE_DISCOVERY => {}, NODETABLE_MAINTAIN => {}, - _ => { - let protocol = *self.timers.get_mut(&token).expect("Unknown user timer token"); - match self.handlers.get_mut(protocol) { - None => { warn!(target: "net", "No handler found for protocol: {:?}", protocol) }, - Some(h) => { - h.timeout(&mut NetworkContext::new(io, protocol, Some(token), &mut self.connections, &mut self.timers), token); - } - } + _ => match self.timers.get_mut(&token).map(|p| *p) { + Some(protocol) => match self.handlers.get_mut(protocol) { + None => { warn!(target: "net", "No handler found for protocol: {:?}", protocol) }, + Some(h) => { h.timeout(&mut NetworkContext::new(io, protocol, Some(token), &mut self.connections, &mut self.timers), token); } + }, + None => {} // time not registerd through us } } }