Fixed overflow panic in handshake_panic (#2495)

This commit is contained in:
Arkadiy Paronyan 2016-10-07 10:34:06 +02:00 committed by GitHub
parent 5f0ed9ddce
commit 533af43313

View File

@ -591,7 +591,8 @@ impl Host {
} }
fn handshake_count(&self) -> usize { fn handshake_count(&self) -> usize {
self.sessions.read().count() - self.session_count() // session_count < total_count is possible because of the data race.
self.sessions.read().count().saturating_sub(self.session_count())
} }
fn keep_alive(&self, io: &IoContext<NetworkIoMessage>) { fn keep_alive(&self, io: &IoContext<NetworkIoMessage>) {