fix: connection close should stay outside the poll loop (#2308)

This commit is contained in:
Gary Yu 2019-01-07 14:44:07 +08:00 committed by GitHub
parent e79123fd5c
commit 0b73e87f8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -291,11 +291,11 @@ fn poll<H>(
.map(|a| a.to_string()) .map(|a| a.to_string())
.unwrap_or("?".to_owned()) .unwrap_or("?".to_owned())
); );
let _ = conn.shutdown(Shutdown::Both);
break; break;
} }
thread::sleep(sleep_time); thread::sleep(sleep_time);
} }
let _ = conn.shutdown(Shutdown::Both);
}); });
} }

View file

@ -526,7 +526,9 @@ impl TrackingAdapter {
if known.len() > MAX_TRACK_SIZE { if known.len() > MAX_TRACK_SIZE {
known.truncate(MAX_TRACK_SIZE); known.truncate(MAX_TRACK_SIZE);
} }
known.insert(0, hash); if !known.contains(&hash) {
known.insert(0, hash);
}
} }
} }