Skip to content

Commit

Permalink
Added a fix so that try_read calls close the connection without retur…
Browse files Browse the repository at this point in the history
…ning errors and causing a panic
  • Loading branch information
john-sharratt authored and theduke committed May 2, 2024
1 parent 9d127f9 commit 748b6b5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/virtual-net/src/tcp_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ impl SocketBuffer {
}
State::Dead => {
tracing::trace!("try_read: socket is dead");
return Err(NetworkError::ConnectionReset);
// Note: Returning `ConnectionReset` here may seem logical as other functions return this
// however this code path is not always handled properly. In particular `tokio` inside
// WASIX will panic if it receives this code.
return Ok(0);
}
State::Closed | State::Shutdown => {
tracing::trace!("try_read: socket is closed or shutdown");
Expand Down

0 comments on commit 748b6b5

Please sign in to comment.