|
|
|
// Failing with `EWOULDBLOCK` is how we differentiate between a closed channel and no |
|
// data to read right now. |
|
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => 0, |
|
|
Returning 0 for std::io::ErrorKind::WouldBlock causes downstream to interpret it as a closed stream, see:
bytecodealliance/wstd#25 (comment).
https://github.com/yoshuawuyts/wstd/blob/5ce367add5e7bcb569b6487453cb9ba94468dc99/src/io/copy.rs#L12
This is also found in:
|
|
|
// The input stream should immediately signal StreamError::Closed. |
|
// Notably, it should _not_ return an empty list (the wasi-io equivalent of EWOULDBLOCK) |
|
// See: https://github.com/bytecodealliance/wasmtime/pull/8968 |
|
assert!(matches!(client.input.read(10), Err(StreamError::Closed))); |
|
|
Given that the wit files already include many would-block errors, would it make sense to extend stream-error to include a would-block?
wasmtime/crates/wasi/src/tcp.rs
Lines 719 to 723 in 6767488
Returning
0forstd::io::ErrorKind::WouldBlockcauses downstream to interpret it as a closed stream, see:bytecodealliance/wstd#25 (comment).
https://github.com/yoshuawuyts/wstd/blob/5ce367add5e7bcb569b6487453cb9ba94468dc99/src/io/copy.rs#L12
This is also found in:
wasmtime/crates/test-programs/src/bin/preview2_tcp_streams.rs
Lines 17 to 22 in 6767488
Given that thewitfiles already include manywould-blockerrors, would it make sense to extendstream-errorto include awould-block?