From 0b73e87f8c8b4866873bd88c41b4a6ef84566387 Mon Sep 17 00:00:00 2001 From: Gary Yu Date: Mon, 7 Jan 2019 14:44:07 +0800 Subject: [PATCH] fix: connection close should stay outside the poll loop (#2308) --- p2p/src/conn.rs | 2 +- p2p/src/peer.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/p2p/src/conn.rs b/p2p/src/conn.rs index bce6edd9d..d1d5d8062 100644 --- a/p2p/src/conn.rs +++ b/p2p/src/conn.rs @@ -291,11 +291,11 @@ fn poll( .map(|a| a.to_string()) .unwrap_or("?".to_owned()) ); - let _ = conn.shutdown(Shutdown::Both); break; } thread::sleep(sleep_time); } + let _ = conn.shutdown(Shutdown::Both); }); } diff --git a/p2p/src/peer.rs b/p2p/src/peer.rs index 91f93f986..4cfd7867e 100644 --- a/p2p/src/peer.rs +++ b/p2p/src/peer.rs @@ -526,7 +526,9 @@ impl TrackingAdapter { if known.len() > MAX_TRACK_SIZE { known.truncate(MAX_TRACK_SIZE); } - known.insert(0, hash); + if !known.contains(&hash) { + known.insert(0, hash); + } } }