Skip to content

Commit

Permalink
fix: was double hashing hashmap key instead of single hashing (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML authored Mar 1, 2024
1 parent 6001fef commit 37177d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ where
Some(Ok(awaiting_key)) = awaiting_expirations.next() => {
// accept_with_cid didn't recieve an inbound connection within the timeout period
// log it and return a timeout error
if let Some((cid, accept)) = awaiting.remove(&calculate_hash(&awaiting_key)) {
if let Some((cid, accept)) = awaiting.remove(&awaiting_key) {
tracing::debug!(%cid.send, %cid.recv, "accept_with_cid timed out");
let _ = accept
.stream
Expand All @@ -228,7 +228,7 @@ where
Some(Ok(incoming_conns_key)) = incoming_conns_expirations.next() => {
// didn't handle inbound connection within the timeout period
// log it and return a timeout error
if let Some((cid, _)) = incoming_conns.remove(&calculate_hash(&incoming_conns_key)) {
if let Some((cid, _)) = incoming_conns.remove(&incoming_conns_key) {
tracing::debug!(%cid.send, %cid.recv, "inbound connection timed out");
} else {
unreachable!("Error incoming_conns_expirations should always contain valid incoming_conns items")
Expand Down
2 changes: 1 addition & 1 deletion tests/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async fn close_succeeds_if_only_fin_ack_dropped() {
// The stream will already be disconnected by the read_to_eof() call, so we expect a
// NotConnected error here.
assert_eq!(e.kind(), ErrorKind::NotConnected);
},
}
Err(e) => {
panic!("The recv stream did not timeout on close() fast enough, giving up after: {e:?}")
}
Expand Down

0 comments on commit 37177d8

Please sign in to comment.