Skip to content

Commit abcbe91

Browse files
committed
fix a duration underflow
1 parent 2401f15 commit abcbe91

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 0.3.2
2+
- Fix a `Duration` underflow panic in `enet::connected`
3+
14
# 0.3.1
25
- Add missing `enet::connected::Host::now` function
36

src/connected.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ impl<C: Connection> Host<C> {
873873
for peer in &mut self.peers {
874874
let mut disconnect = false;
875875
if let PeerState::AwaitingPeer { since, timeout, .. } = &mut peer.state {
876-
if *since < now - *timeout {
876+
if *since + *timeout < now {
877877
peer.state = PeerState::Disconnected {
878878
last_peer_ptr: None,
879879
};
@@ -887,7 +887,7 @@ impl<C: Connection> Host<C> {
887887
..
888888
} = &mut peer.state
889889
{
890-
if *last_send < now - Duration::from_secs(2) {
890+
if *last_send + Duration::from_secs(2) < now {
891891
peer.state = PeerState::Disconnected {
892892
last_peer_ptr: last_peer_ptr.take(),
893893
};

0 commit comments

Comments
 (0)