Skip to content

Commit

Permalink
fix(wasi-sockets): avoid shutdown on drop
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Oct 6, 2023
1 parent 1429404 commit 11e5405
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
20 changes: 0 additions & 20 deletions crates/wasi/src/preview2/host/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,26 +470,6 @@ impl<T: WasiView> crate::preview2::host::tcp::tcp::HostTcpSocket for T {
// As in the filesystem implementation, we assume closing a socket
// doesn't block.
let dropped = table.delete_resource(this)?;

// If we might have an `event::poll` waiting on the socket, wake it up.
#[cfg(not(unix))]
{
match dropped.tcp_state {
TcpState::Default
| TcpState::BindStarted
| TcpState::Bound
| TcpState::ListenStarted
| TcpState::ConnectReady => {}

TcpState::Listening | TcpState::Connecting | TcpState::Connected => {
match rustix::net::shutdown(&*dropped.inner, rustix::net::Shutdown::ReadWrite) {
Ok(()) | Err(Errno::NOTCONN) => {}
Err(err) => Err(err).unwrap(),
}
}
}
}

drop(dropped);

Ok(())
Expand Down
19 changes: 0 additions & 19 deletions crates/wasi/src/preview2/host/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,6 @@ impl<T: WasiView> crate::preview2::host::udp::udp::HostUdpSocket for T {
// As in the filesystem implementation, we assume closing a socket
// doesn't block.
let dropped = table.delete_resource(this)?;

// If we might have an `event::poll` waiting on the socket, wake it up.
#[cfg(not(unix))]
{
match dropped.udp_state {
UdpState::Default
| UdpState::BindStarted
| UdpState::Bound
| UdpState::ConnectReady => {}

UdpState::Connecting | UdpState::Connected => {
match rustix::net::shutdown(&*dropped.inner, rustix::net::Shutdown::ReadWrite) {
Ok(()) | Err(Errno::NOTCONN) => {}
Err(err) => Err(err).unwrap(),
}
}
}
}

drop(dropped);

Ok(())
Expand Down

0 comments on commit 11e5405

Please sign in to comment.