-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasi: implement sock_accept
and enable networking
#93158
Conversation
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
4ab7b43
to
a0ce15c
Compare
This comment has been minimized.
This comment has been minimized.
a0ce15c
to
62b4e72
Compare
sock_accept
and enable networkingsock_accept
and enable networking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me after the fix in decode_error_kind.
Feel free to ping anyone who would have a useful opinion about the TcpListener::accept return value. Probably any value is better than unsupported()
though.
|
||
impl TcpListenerExt for net::TcpListener { | ||
fn sock_accept(&self, flags: u16) -> io::Result<u32> { | ||
self.as_inner().as_inner().as_inner().sock_accept(flags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.as_inner().as_inner().as_inner()
😱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe
e if e == wasi::ERRNO_INVAL.raw().into() => InvalidInput, | ||
e if e == wasi::ERRNO_TIMEDOUT.raw().into() => TimedOut, | ||
e if e == wasi::ERRNO_EXIST.raw().into() => AlreadyExists, | ||
e if e == wasi::ERRNO_AGAIN.raw().into() => WouldBlock, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 66 has this already.
e if e == wasi::ERRNO_AGAIN.raw().into() => WouldBlock, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
To make use of `sock_accept()`, update the wasi crate to `0.11.0`. Signed-off-by: Harald Hoyer <[email protected]>
With the addition of `sock_accept()` to snapshot1, simple networking via a passed `TcpListener` is possible. This patch implements the basics to make a simple server work. Signed-off-by: Harald Hoyer <[email protected]>
62b4e72
to
d2a1369
Compare
@dtolnay fixed and rebased |
@bors r+ |
📌 Commit d2a1369 has been approved by |
wasi: implement `sock_accept` and enable networking With the addition of `sock_accept()` to snapshot1, simple networking via a passed `TcpListener` is possible. This PR implements the basics to make a simple server work. See also: * [wasmtime tracking issue](bytecodealliance/wasmtime#3730) * [wasmtime PR](bytecodealliance/wasmtime#3711) TODO: * [ ] Discussion of `SocketAddr` return value for `::accept()` ```rust Ok(( TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }), // WASI has no concept of SocketAddr yet // return an unspecified IPv4Addr SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0), )) ```
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#92611 (Add links to the reference and rust by example for asm! docs and lints) - rust-lang#93158 (wasi: implement `sock_accept` and enable networking) - rust-lang#93239 (Add os::unix::net::SocketAddr::from_path) - rust-lang#93261 (Some unwinding related cg_ssa cleanups) - rust-lang#93295 (Avoid double panics when using `TempDir` in tests) - rust-lang#93353 (Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>) - rust-lang#93356 (Edit docs introduction for `std::cmp::PartialOrd`) - rust-lang#93375 (fix typo `documenation`) - rust-lang#93399 (rustbuild: Fix compiletest warning when building outside of root.) - rust-lang#93404 (Fix a typo from rust-lang#92899) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
With * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Signed-off-by: Harald Hoyer <[email protected]>
With * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Signed-off-by: Harald Hoyer <[email protected]>
With * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Signed-off-by: Harald Hoyer <[email protected]>
With * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Signed-off-by: Harald Hoyer <[email protected]>
With * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Signed-off-by: Harald Hoyer <[email protected]>
Based on tokio-rs#1395 And with * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Co-authored-by: Thomas de Zeeuw <[email protected]> Signed-off-by: Harald Hoyer <[email protected]>
Based on tokio-rs#1395 And with * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Co-authored-by: Thomas de Zeeuw <[email protected]> Signed-off-by: Harald Hoyer <[email protected]>
Based on #1395 And with * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Co-authored-by: Thomas de Zeeuw <[email protected]> Signed-off-by: Harald Hoyer <[email protected]>
Based on tokio-rs#1395 And with * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Co-authored-by: Thomas de Zeeuw <[email protected]> Signed-off-by: Harald Hoyer <[email protected]>
Based on tokio-rs#1395 And with * bytecodealliance/wasmtime#3711 * rust-lang/rust#93158 merged, mio can have limited support for networking for the `wasm32-wasi` target. Co-authored-by: Thomas de Zeeuw <[email protected]> Signed-off-by: Harald Hoyer <[email protected]>
With the addition of
sock_accept()
to snapshot1, simple networking via a passedTcpListener
is possible. This PR implements the basics to make a simple server work.See also:
TODO:
SocketAddr
return value for::accept()