Skip to content

Commit

Permalink
Allow accept() to return transient errors.
Browse files Browse the repository at this point in the history
The original provision was added to align with preview3 streams that may only fail once. However, after discussing with Dan Gohman, we came to the conclusion that a stream of result<> could do the trick fine too.

Fixes: WebAssembly/wasi-sockets#22
  • Loading branch information
badeend committed Sep 21, 2023
1 parent a620fd0 commit 17c8b8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/wasi/src/preview2/host/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl<T: SystemError> From<T> for network::Error {
Errno::TIMEDOUT => ErrorCode::Timeout,
Errno::CONNREFUSED => ErrorCode::ConnectionRefused,
Errno::CONNRESET => ErrorCode::ConnectionReset,
// Errno::CONNABORTED => ErrorCode::Todo, // FIXME
Errno::CONNABORTED => ErrorCode::ConnectionAborted,
// Errno::INVAL => ErrorCode::Todo, // FIXME
Errno::HOSTUNREACH => ErrorCode::RemoteUnreachable,
Errno::HOSTDOWN => ErrorCode::RemoteUnreachable,
Expand Down
3 changes: 3 additions & 0 deletions crates/wasi/wit/deps/sockets/network.wit
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ interface network {

/// The connection was reset.
connection-reset,

/// A connection was aborted.
connection-aborted,


// ### UDP SOCKET ERRORS ###
Expand Down
4 changes: 2 additions & 2 deletions crates/wasi/wit/deps/sockets/tcp.wit
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ interface tcp {
/// # Typical errors
/// - `not-listening`: Socket is not in the Listener state. (EINVAL)
/// - `would-block`: No pending connections at the moment. (EWOULDBLOCK, EAGAIN)
///
/// Host implementations must skip over transient errors returned by the native accept syscall.
/// - `connection-aborted`: An incoming connection was pending, but was terminated by the client before this listener could accept it. (ECONNABORTED)
/// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE)
///
/// # References
/// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html>
Expand Down

0 comments on commit 17c8b8e

Please sign in to comment.