Merge pull request #1219 from ethcore/clippy-bump

Clippy bump & fixing warnings
This commit is contained in:
Arkadiy Paronyan 2016-06-06 11:46:59 +02:00
commit 98d9752097
20 changed files with 84 additions and 71 deletions

31
Cargo.lock generated
View File

@ -3,7 +3,7 @@ name = "parity"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)", "ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)",
"daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
@ -130,11 +130,26 @@ dependencies = [
[[package]] [[package]]
name = "clippy" name = "clippy"
version = "0.0.69" version = "0.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"clippy_lints 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clippy_lints"
version = "0.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -241,7 +256,7 @@ name = "ethcore"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.2.0", "ethash 1.2.0",
@ -265,7 +280,7 @@ dependencies = [
name = "ethcore-dapps" name = "ethcore-dapps"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-rpc 1.2.0", "ethcore-rpc 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
@ -329,7 +344,7 @@ dependencies = [
name = "ethcore-rpc" name = "ethcore-rpc"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.2.0", "ethash 1.2.0",
"ethcore 1.2.0", "ethcore 1.2.0",
"ethcore-devtools 1.2.0", "ethcore-devtools 1.2.0",
@ -352,7 +367,7 @@ dependencies = [
name = "ethcore-signer" name = "ethcore-signer"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-rpc 1.2.0", "ethcore-rpc 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",
@ -370,7 +385,7 @@ dependencies = [
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"bigint 0.1.0", "bigint 0.1.0",
"chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -415,7 +430,7 @@ dependencies = [
name = "ethsync" name = "ethsync"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.2.0", "ethcore 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",

View File

@ -23,7 +23,7 @@ daemonize = "0.2"
num_cpus = "0.2" num_cpus = "0.2"
number_prefix = "0.2" number_prefix = "0.2"
rpassword = "0.2.1" rpassword = "0.2.1"
clippy = { version = "0.0.69", optional = true} clippy = { version = "0.0.71", optional = true}
ethcore = { path = "ethcore" } ethcore = { path = "ethcore" }
ethcore-util = { path = "util" } ethcore-util = { path = "util" }
ethsync = { path = "sync" } ethsync = { path = "sync" }

View File

@ -28,7 +28,7 @@ parity-dapps-wallet = { git = "https://github.com/ethcore/parity-dapps-wallet-rs
parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.3.0", optional = true } parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.3.0", optional = true }
parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.2.0", optional = true } parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.2.0", optional = true }
mime_guess = { version = "1.6.1" } mime_guess = { version = "1.6.1" }
clippy = { version = "0.0.69", optional = true} clippy = { version = "0.0.71", optional = true}
[build-dependencies] [build-dependencies]
serde_codegen = { version = "0.7.0", optional = true } serde_codegen = { version = "0.7.0", optional = true }

View File

@ -22,7 +22,7 @@ ethcore-util = { path = "../util" }
evmjit = { path = "../evmjit", optional = true } evmjit = { path = "../evmjit", optional = true }
ethash = { path = "../ethash" } ethash = { path = "../ethash" }
num_cpus = "0.2" num_cpus = "0.2"
clippy = { version = "0.0.69", optional = true} clippy = { version = "0.0.71", optional = true}
crossbeam = "0.2.9" crossbeam = "0.2.9"
lazy_static = "0.1" lazy_static = "0.1"
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }

View File

@ -17,7 +17,6 @@
///! Rust VM implementation ///! Rust VM implementation
use common::*; use common::*;
use trace::VMTracer;
use super::instructions as instructions; use super::instructions as instructions;
use super::instructions::{Instruction, get_info}; use super::instructions::{Instruction, get_info};
use std::marker::Copy; use std::marker::Copy;

View File

@ -81,14 +81,14 @@ impl<'a> Executive<'a> {
} }
/// Creates `Externalities` from `Executive`. /// Creates `Externalities` from `Executive`.
pub fn as_externalities<'_, T, V>( pub fn as_externalities<'any, T, V>(
&'_ mut self, &'any mut self,
origin_info: OriginInfo, origin_info: OriginInfo,
substate: &'_ mut Substate, substate: &'any mut Substate,
output: OutputPolicy<'_, '_>, output: OutputPolicy<'any, 'any>,
tracer: &'_ mut T, tracer: &'any mut T,
vm_tracer: &'_ mut V vm_tracer: &'any mut V
) -> Externalities<'_, T, V> where T: Tracer, V: VMTracer { ) -> Externalities<'any, T, V> where T: Tracer, V: VMTracer {
Externalities::new(self.state, self.info, self.engine, self.vm_factory, self.depth, origin_info, substate, output, tracer, vm_tracer) Externalities::new(self.state, self.info, self.engine, self.vm_factory, self.depth, origin_info, substate, output, tracer, vm_tracer)
} }

View File

@ -133,10 +133,10 @@ impl VMTracer for ExecutiveVMTracer {
self.data.operations.last_mut().expect("trace_executed is always called after a trace_prepare_execute").executed = Some(ex); self.data.operations.last_mut().expect("trace_executed is always called after a trace_prepare_execute").executed = Some(ex);
} }
fn prepare_subtrace(&self, code: &Bytes) -> Self { fn prepare_subtrace(&self, code: &[u8]) -> Self {
ExecutiveVMTracer { data: VMTrace { ExecutiveVMTracer { data: VMTrace {
parent_step: self.data.operations.len(), parent_step: self.data.operations.len(),
code: code.clone(), code: code.to_vec(),
operations: vec![], operations: vec![],
subs: vec![], subs: vec![],
}} }}

View File

@ -98,7 +98,7 @@ pub trait VMTracer: Send {
fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem_diff: Option<(usize, &[u8])>, _store_diff: Option<(U256, U256)>) {} fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem_diff: Option<(usize, &[u8])>, _store_diff: Option<(U256, U256)>) {}
/// Spawn subtracer which will be used to trace deeper levels of execution. /// Spawn subtracer which will be used to trace deeper levels of execution.
fn prepare_subtrace(&self, code: &Bytes) -> Self where Self: Sized; fn prepare_subtrace(&self, code: &[u8]) -> Self where Self: Sized;
/// Spawn subtracer which will be used to trace deeper levels of execution. /// Spawn subtracer which will be used to trace deeper levels of execution.
fn done_subtrace(&mut self, sub: Self) where Self: Sized; fn done_subtrace(&mut self, sub: Self) where Self: Sized;

View File

@ -75,7 +75,7 @@ impl VMTracer for NoopVMTracer {
fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem_diff: Option<(usize, &[u8])>, _store_diff: Option<(U256, U256)>) {} fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem_diff: Option<(usize, &[u8])>, _store_diff: Option<(U256, U256)>) {}
/// Spawn subtracer which will be used to trace deeper levels of execution. /// Spawn subtracer which will be used to trace deeper levels of execution.
fn prepare_subtrace(&self, _code: &Bytes) -> Self { NoopVMTracer } fn prepare_subtrace(&self, _code: &[u8]) -> Self { NoopVMTracer }
/// Spawn subtracer which will be used to trace deeper levels of execution. /// Spawn subtracer which will be used to trace deeper levels of execution.
fn done_subtrace(&mut self, _sub: Self) {} fn done_subtrace(&mut self, _sub: Self) {}

View File

@ -10,7 +10,7 @@ rustc-serialize = "0.3"
serde = "0.7.0" serde = "0.7.0"
serde_json = "0.7.0" serde_json = "0.7.0"
serde_macros = { version = "0.7.0", optional = true } serde_macros = { version = "0.7.0", optional = true }
clippy = { version = "0.0.69", optional = true} clippy = { version = "0.0.71", optional = true}
[build-dependencies] [build-dependencies]
serde_codegen = { version = "0.7.0", optional = true } serde_codegen = { version = "0.7.0", optional = true }

View File

@ -15,7 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::sync::{RwLock,Arc}; use std::sync::{RwLock,Arc};
use std::ops::*;
use ipc::IpcConfig; use ipc::IpcConfig;
use std::collections::HashMap; use std::collections::HashMap;
use std::mem; use std::mem;

View File

@ -23,7 +23,7 @@ ethcore-devtools = { path = "../devtools" }
rustc-serialize = "0.3" rustc-serialize = "0.3"
transient-hashmap = "0.1" transient-hashmap = "0.1"
serde_macros = { version = "0.7.0", optional = true } serde_macros = { version = "0.7.0", optional = true }
clippy = { version = "0.0.69", optional = true} clippy = { version = "0.0.71", optional = true}
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
[build-dependencies] [build-dependencies]

View File

@ -19,7 +19,7 @@ ethcore-util = { path = "../util" }
ethcore-rpc = { path = "../rpc" } ethcore-rpc = { path = "../rpc" }
parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git" } parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git" }
clippy = { version = "0.0.69", optional = true} clippy = { version = "0.0.71", optional = true}
[features] [features]
dev = ["clippy"] dev = ["clippy"]

View File

@ -10,7 +10,7 @@ authors = ["Ethcore <admin@ethcore.io"]
[dependencies] [dependencies]
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
ethcore = { path = "../ethcore" } ethcore = { path = "../ethcore" }
clippy = { version = "0.0.69", optional = true} clippy = { version = "0.0.71", optional = true}
log = "0.3" log = "0.3"
env_logger = "0.3" env_logger = "0.3"
time = "0.1.34" time = "0.1.34"

View File

@ -918,7 +918,7 @@ impl ChainSync {
let skip: usize = try!(r.val_at(2)); let skip: usize = try!(r.val_at(2));
let reverse: bool = try!(r.val_at(3)); let reverse: bool = try!(r.val_at(3));
let last = io.chain().chain_info().best_block_number; let last = io.chain().chain_info().best_block_number;
let mut number = if try!(r.at(0)).size() == 32 { let number = if try!(r.at(0)).size() == 32 {
// id is a hash // id is a hash
let hash: H256 = try!(r.val_at(0)); let hash: H256 = try!(r.val_at(0));
trace!(target: "sync", "-> GetBlockHeaders (hash: {}, max: {}, skip: {}, reverse:{})", hash, max_headers, skip, reverse); trace!(target: "sync", "-> GetBlockHeaders (hash: {}, max: {}, skip: {}, reverse:{})", hash, max_headers, skip, reverse);
@ -931,11 +931,11 @@ impl ChainSync {
try!(r.val_at(0)) try!(r.val_at(0))
}; };
if reverse { let mut number = if reverse {
number = min(last, number); min(last, number)
} else { } else {
number = max(0, number); max(0, number)
} };
let max_count = min(MAX_HEADERS_TO_SEND, max_headers); let max_count = min(MAX_HEADERS_TO_SEND, max_headers);
let mut count = 0; let mut count = 0;
let mut data = Bytes::new(); let mut data = Bytes::new();
@ -1188,11 +1188,12 @@ impl ChainSync {
let mut sent = 0; let mut sent = 0;
let last_parent = HeaderView::new(&io.chain().block_header(BlockID::Hash(chain_info.best_block_hash.clone())).unwrap()).parent_hash(); let last_parent = HeaderView::new(&io.chain().block_header(BlockID::Hash(chain_info.best_block_hash.clone())).unwrap()).parent_hash();
for (peer_id, peer_number) in lucky_peers { for (peer_id, peer_number) in lucky_peers {
let mut peer_best = self.peers.get(&peer_id).unwrap().latest_hash.clone(); let peer_best = if chain_info.best_block_number - peer_number > MAX_PEER_LAG_PROPAGATION as BlockNumber {
if chain_info.best_block_number - peer_number > MAX_PEER_LAG_PROPAGATION as BlockNumber {
// If we think peer is too far behind just send one latest hash // If we think peer is too far behind just send one latest hash
peer_best = last_parent.clone(); last_parent.clone()
} } else {
self.peers.get(&peer_id).unwrap().latest_hash.clone()
};
sent += match ChainSync::create_new_hashes_rlp(io.chain(), &peer_best, &chain_info.best_block_hash) { sent += match ChainSync::create_new_hashes_rlp(io.chain(), &peer_best, &chain_info.best_block_hash) {
Some(rlp) => { Some(rlp) => {
{ {

View File

@ -162,6 +162,7 @@ impl NetworkProtocolHandler<SyncMessage> for EthSync {
self.sync.write().unwrap().maintain_sync(&mut NetSyncIo::new(io, self.chain.deref())); self.sync.write().unwrap().maintain_sync(&mut NetSyncIo::new(io, self.chain.deref()));
} }
#[cfg_attr(feature="dev", allow(single_match))]
fn message(&self, io: &NetworkContext<SyncMessage>, message: &SyncMessage) { fn message(&self, io: &NetworkContext<SyncMessage>, message: &SyncMessage) {
match *message { match *message {
SyncMessage::NewChainBlocks { ref imported, ref invalid, ref enacted, ref retracted } => { SyncMessage::NewChainBlocks { ref imported, ref invalid, ref enacted, ref retracted } => {

View File

@ -28,7 +28,7 @@ crossbeam = "0.2"
slab = "0.2" slab = "0.2"
sha3 = { path = "sha3" } sha3 = { path = "sha3" }
serde = "0.7.0" serde = "0.7.0"
clippy = { version = "0.0.69", optional = true} clippy = { version = "0.0.71", optional = true}
json-tests = { path = "json-tests" } json-tests = { path = "json-tests" }
igd = "0.4.2" igd = "0.4.2"
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }

View File

@ -501,8 +501,8 @@ macro_rules! impl_hash {
} }
} }
impl<'_> From<&'_ str> for $from { impl<'a> From<&'a str> for $from {
fn from(s: &'_ str) -> $from { fn from(s: &'a str) -> $from {
use std::str::FromStr; use std::str::FromStr;
if s.len() % 2 == 1 { if s.len() % 2 == 1 {
$from::from_str(&("0".to_owned() + &(clean_0x(s).to_owned()))[..]).unwrap_or_else(|_| $from::new()) $from::from_str(&("0".to_owned() + &(clean_0x(s).to_owned()))[..]).unwrap_or_else(|_| $from::new())
@ -524,8 +524,8 @@ impl From<U256> for H256 {
} }
} }
impl<'_> From<&'_ U256> for H256 { impl<'a> From<&'a U256> for H256 {
fn from(value: &'_ U256) -> H256 { fn from(value: &'a U256) -> H256 {
unsafe { unsafe {
let mut ret: H256 = ::std::mem::uninitialized(); let mut ret: H256 = ::std::mem::uninitialized();
value.to_raw_bytes(&mut ret); value.to_raw_bytes(&mut ret);
@ -540,8 +540,8 @@ impl From<H256> for U256 {
} }
} }
impl<'_> From<&'_ H256> for U256 { impl<'a> From<&'a H256> for U256 {
fn from(value: &'_ H256) -> U256 { fn from(value: &'a H256) -> U256 {
U256::from(value.bytes()) U256::from(value.bytes())
} }
} }
@ -566,8 +566,8 @@ impl From<H256> for H64 {
} }
} }
/* /*
impl<'_> From<&'_ H256> for Address { impl<'a> From<&'a H256> for Address {
fn from(value: &'_ H256) -> Address { fn from(value: &'a H256) -> Address {
unsafe { unsafe {
let mut ret: Address = ::std::mem::uninitialized(); let mut ret: Address = ::std::mem::uninitialized();
::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20); ::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20);
@ -586,8 +586,8 @@ impl From<Address> for H256 {
} }
} }
impl<'_> From<&'_ Address> for H256 { impl<'a> From<&'a Address> for H256 {
fn from(value: &'_ Address) -> H256 { fn from(value: &'a Address) -> H256 {
unsafe { unsafe {
let mut ret = H256::new(); let mut ret = H256::new();
::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20); ::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20);

View File

@ -494,10 +494,11 @@ impl Discovery {
} }
pub fn update_registration<Host:Handler>(&self, event_loop: &mut EventLoop<Host>) -> Result<(), NetworkError> { pub fn update_registration<Host:Handler>(&self, event_loop: &mut EventLoop<Host>) -> Result<(), NetworkError> {
let mut registration = EventSet::readable(); let registration = if !self.send_queue.is_empty() {
if !self.send_queue.is_empty() { EventSet::readable() | EventSet::writable()
registration = registration | EventSet::writable(); } else {
} EventSet::readable()
};
event_loop.reregister(&self.udp_socket, Token(self.token), registration, PollOpt::edge()).expect("Error reregistering UDP socket"); event_loop.reregister(&self.udp_socket, Token(self.token), registration, PollOpt::edge()).expect("Error reregistering UDP socket");
Ok(()) Ok(())
} }

View File

@ -712,28 +712,25 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
let mut failure_id = None; let mut failure_id = None;
let mut deregister = false; let mut deregister = false;
let mut expired_session = None; let mut expired_session = None;
match token { if let FIRST_SESSION ... LAST_SESSION = token {
FIRST_SESSION ... LAST_SESSION => { let sessions = self.sessions.write().unwrap();
let sessions = self.sessions.write().unwrap(); if let Some(session) = sessions.get(token).cloned() {
if let Some(session) = sessions.get(token).cloned() { expired_session = Some(session.clone());
expired_session = Some(session.clone()); let mut s = session.lock().unwrap();
let mut s = session.lock().unwrap(); if !s.expired() {
if !s.expired() { if s.is_ready() {
if s.is_ready() { for (p, _) in self.handlers.read().unwrap().iter() {
for (p, _) in self.handlers.read().unwrap().iter() { if s.have_capability(p) {
if s.have_capability(p) { self.num_sessions.fetch_sub(1, AtomicOrdering::SeqCst);
self.num_sessions.fetch_sub(1, AtomicOrdering::SeqCst); to_disconnect.push(p);
to_disconnect.push(p);
}
} }
} }
s.set_expired();
failure_id = s.id().cloned();
} }
deregister = remote || s.done(); s.set_expired();
failure_id = s.id().cloned();
} }
}, deregister = remote || s.done();
_ => {}, }
} }
if let Some(id) = failure_id { if let Some(id) = failure_id {
if remote { if remote {