You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tokio::io::ReadAsync::read_exactwill propagate an std::io::ErrorKind::Interrupted error back to the caller, rather than retrying like its counterpartstd::io::Read::read_exact.
I speculate that this is because Interrupted does not commonly come up from non-blocking I/O implementations the way it does for blocking.This is technically working as documented, but I don't think it's working as intended, since implementations of AsyncRead could reasonably assume it is acceptable to return Interrupted if there were a use case for it, and client code is unlikely to handle it since doing so in the std case is unnecessary, and arguably core functionality of read_exact, principle of least surprise, etc.
I think the same goes for the return type. If it succeeds, it always returns Ok(me.buf.capacity()). In that case, it's better to return io::Result<()> like its counterpart.
Version
1.34.0
Platform
Linux alder 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux
Description
tokio::io::ReadAsync::read_exact
will propagate anstd::io::ErrorKind::Interrupted
error back to the caller, rather than retrying like its counterpartstd::io::Read::read_exact
.I speculate that this is because
Interrupted
does not commonly come up from non-blocking I/O implementations the way it does for blocking.This is technically working as documented, but I don't think it's working as intended, since implementations ofAsyncRead
could reasonably assume it is acceptable to returnInterrupted
if there were a use case for it, and client code is unlikely to handle it since doing so in the std case is unnecessary, and arguably core functionality ofread_exact
, principle of least surprise, etc.https://gist.github.com/calmofthestorm/0c95c6f23ed9014238c0d722ee7d97c2 shows how a simple
[Async]Read
implementation that spuriously returnsInterrupted
works with std read_exact but not the Tokio equivalent.The text was updated successfully, but these errors were encountered: