Repository navigation
wasi-sockets: Sync up UDP implementation & tests with TCP - #7423
Conversation
alexcrichton
left a comment
There was a problem hiding this comment.
Thanks!
Sort of a side-question as it's not directly related to this PR itself, where's all this error-handling code coming from? This seems extensive enough that the tests probably aren't exercising all the various cases here and I'm curious if you're porting from another library for example or something like that.
| /// Bind a socket on a specified port. | ||
| fn test_udp_bind_specific_port(net: &Network, ip: IpAddress) { | ||
| const PORT: u16 = 54321; | ||
|
|
||
| let bind_addr = IpSocketAddress::new(ip, PORT); | ||
|
|
||
| let sock = UdpSocket::new(ip.family()).unwrap(); | ||
| sock.blocking_bind(net, bind_addr).unwrap(); | ||
|
|
||
| let bound_addr = sock.local_address().unwrap(); | ||
|
|
||
| assert_eq!(bind_addr.ip(), bound_addr.ip()); | ||
| assert_eq!(bind_addr.port(), bound_addr.port()); | ||
| } |
There was a problem hiding this comment.
Can this fail if the port is already bound? We've had issues with tests running concurrently in the past and I think the TCP test has a case where it handles failure to bind here.
There was a problem hiding this comment.
Ah right. Hadn't noticed the TCP test changed recently. Yes, this UDP test needs the same update.
There was a problem hiding this comment.
I've updated the test with the same workaround that's in the TCP test.
Not any single place but a combination of: "official" documentations, stack overflow, OS source code, trial-and-error, ..
Are you referring to the error mappings in |
|
Ah ok makes sense. It's not really anything in particular I'm worried about or looking at, but it's lots of little things like:
I'm not worried about any of these, mostly curious instead how they all came into existence and if you hit issues locally or if you're copying. Either way is fine, and what you say makes sense, so sounds good to me! |
|
This is a standard POSIX error code for the bind syscall:
From the docs
From the docs
CI discovered that for me. This is actively tested by: wasmtime/crates/test-programs/src/bin/preview2_tcp_sockopts.rs Lines 46 to 49 in f63350e
From the docs. This is actively tested by: wasmtime/crates/test-programs/src/bin/preview2_tcp_sockopts.rs Lines 75 to 79 in f63350e |
|
Thanks for the explanations! When you get a chance it might be goood to have some of that commentary in the code as well. |
…liance#7423) * Refactor & move utilities. So that UDP can use them too. * Minor tweak in error code while connecting * Refactor: move portability workarounds out of the TCP implementation. * Sync up UDP implementation and tests based on the existing TCP implementation & tests. * Make test less flaky in CI.
* Update wasm-tools dependencies (#7488) Pull in bytecodealliance/wasm-tools#1277 to switch the defaults for some WIT behaviors: * Semicolons are now required by default in WIT files * Wasm-encoded WIT packages now use the "new" format by default. WIT files without semicolons can still be parsed with `WIT_REQUIRE_SEMICOLONS=0`. The "old" format for wasm-encoded WIT packages can be emitted via `WIT_COMPONENT_ENCODING_V2=0`. Note that for wasm-encoded WIT packages both the old and the new format can be decoded irregardless of env vars. * wasi-sockets: Sync up UDP implementation & tests with TCP (#7423) * Refactor & move utilities. So that UDP can use them too. * Minor tweak in error code while connecting * Refactor: move portability workarounds out of the TCP implementation. * Sync up UDP implementation and tests based on the existing TCP implementation & tests. * Make test less flaky in CI. * wasi-sockets: Simplify ip name lookup interface (#7483) * Refactor ip_name_lookup test * Update ip-name-lookup::resolve-addresses - Remove the non-essential parameters - Lift the restriction against parsing IP addresses. Implementations would still have to parse IP addresses to decide whether or not to return an error * Deduplicate to_canonical * Add release notes for 15.0.0 (#7487) --------- Co-authored-by: Dave Bakker <[email protected]>
No major functional changes: