From 748b6b5142b33af6bffdf8b48bdc2a28d85bebad Mon Sep 17 00:00:00 2001 From: Johnathan Sharratt Date: Wed, 1 May 2024 08:06:47 +1000 Subject: [PATCH] Added a fix so that try_read calls close the connection without returning errors and causing a panic --- lib/virtual-net/src/tcp_pair.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/virtual-net/src/tcp_pair.rs b/lib/virtual-net/src/tcp_pair.rs index 61d622c613e..ee73b2989e2 100644 --- a/lib/virtual-net/src/tcp_pair.rs +++ b/lib/virtual-net/src/tcp_pair.rs @@ -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");