Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fixed overflow panic in handshake_panic
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Oct 6, 2016
1 parent ecf098e commit ce0b4fe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion util/network/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,10 @@ impl Host {
}

fn handshake_count(&self) -> usize {
self.sessions.read().count() - self.session_count()
let total_count = self.sessions.read().count();
let session_count = self.session_count();
// session_count < total_count is possible because of the data race.
return if total_count >= session_count { total_count - session_count } else { 0 };
}

fn keep_alive(&self, io: &IoContext<NetworkIoMessage>) {
Expand Down

0 comments on commit ce0b4fe

Please sign in to comment.