diff --git a/util/src/network/connection.rs b/util/src/network/connection.rs index ade06b469..f4c4c2a8d 100644 --- a/util/src/network/connection.rs +++ b/util/src/network/connection.rs @@ -436,7 +436,7 @@ impl EncryptedConnection { /// Readable IO handler. Tracker receive status and returns decoded packet if avaialable. pub fn readable(&mut self, io: &IoContext) -> Result, UtilError> where Message: Send + Clone{ - io.clear_timer(self.connection.token).unwrap(); + try!(io.clear_timer(self.connection.token)); if let EncryptedConnectionState::Header = self.read_state { if let Some(data) = try!(self.connection.readable()) { try!(self.read_header(&data)); diff --git a/util/src/network/host.rs b/util/src/network/host.rs index e5853b8db..abace1983 100644 --- a/util/src/network/host.rs +++ b/util/src/network/host.rs @@ -683,6 +683,7 @@ impl Host where Message: Send + Sync + Clone { Some(_) => packet_data.push((protocol, packet_id, data)), } }, + Ok(SessionData::Continue) => (), Ok(SessionData::None) => break, } } diff --git a/util/src/network/session.rs b/util/src/network/session.rs index d5fd33813..c19dfbcf8 100644 --- a/util/src/network/session.rs +++ b/util/src/network/session.rs @@ -68,6 +68,8 @@ pub enum SessionData { /// Zero based packet ID packet_id: u8, }, + /// Session has more data to be read + Continue, } /// Shared session information @@ -329,16 +331,19 @@ impl Session { PACKET_DISCONNECT => { let rlp = UntrustedRlp::new(&packet.data[1..]); let reason: u8 = try!(rlp.val_at(0)); + if self.had_hello { + debug!("Disconnected: {}: {:?}", self.token(), DisconnectReason::from_u8(reason)); + } Err(From::from(NetworkError::Disconnect(DisconnectReason::from_u8(reason)))) } PACKET_PING => { try!(self.send_pong(io)); - Ok(SessionData::None) + Ok(SessionData::Continue) }, PACKET_PONG => { self.pong_time_ns = Some(time::precise_time_ns()); self.info.ping_ms = Some((self.pong_time_ns.unwrap() - self.ping_time_ns) / 1000_000); - Ok(SessionData::None) + Ok(SessionData::Continue) }, PACKET_GET_PEERS => Ok(SessionData::None), //TODO; PACKET_PEERS => Ok(SessionData::None), @@ -348,7 +353,7 @@ impl Session { i += 1; if i == self.info.capabilities.len() { debug!(target: "network", "Unknown packet: {:?}", packet_id); - return Ok(SessionData::None) + return Ok(SessionData::Continue) } } @@ -359,7 +364,7 @@ impl Session { }, _ => { debug!(target: "network", "Unknown packet: {:?}", packet_id); - Ok(SessionData::None) + Ok(SessionData::Continue) } } }