Rollup merge of #156414 - tunnell:pr-xous-net-recv-byte-offset, r=nia-e
std/sys/net/xous: read NetError code from byte 4 in recv/accept paths
The Xous std backend's TCP **send** path reads the `NetError`
code from `send_request.raw[4]` (correct — that's where the
xous-core kernel's `respond_with_error` writes it). But the TCP
recv, UDP recv, and TcpListener accept paths all read from
`raw[1]` instead. The kernel's historical layout is
`[1, 1, 1, 1, code, 0, 0, 0]`, so byte 1 is always `1` and
`ErrorKind::TimedOut` / `ErrorKind::WouldBlock` are unreachable
from the recv side — every error falls through to the catch-all
`ErrorKind::Other("recv_slice failure")`.
This patch moves the recv-path checks to `raw[4]`, matching the
send path and the kernel's existing encoding. Three files,
identical one-byte change in each (+15 / -10 total). No new
behavior; an existing inconsistency between the send and recv
sides of the same backend is removed.
**Why this matters in practice:** any application using
`set_read_timeout()` to interleave reads and writes on a Xous
`TcpStream` (e.g. a tungstenite-based WebSocket pump) currently
can't distinguish "no data this poll" from real transport
failure. Concretely, a Signal client using a 5s read timeout saw
every WebSocket torn down within 5s of opening, because the
timeout was indistinguishable from a fatal error.
**Coordination with the kernel side:** a complementary kernel-
side change has been filed on the xous-core repo —
[betrusted-io/xous-core#877](https://github.com/betrusted-io/xous-core/pull/877)
— which mirrors the code at byte 1 in addition to byte 4 so
applications work immediately on stock Rust toolchains while
this PR cycles. After both land, the two sides agree at byte 4
and byte 1 stays mirrored only for backwards-compat with older
Rust. Either change alone fixes the user-visible symptom; both
together remove the wire-format ambiguity.
**Tests:** Tier-3 target std backends generally don't have CI
coverage in this repo, so I haven't added any. Happy to add an
in-process test that constructs a fake net-server response and
asserts the `ErrorKind` mapping if maintainers prefer.
Full disclosure: I used an AI agent to debug this problem and eventually track it here.
Website | Getting started | Learn | Documentation | Contributing
This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.
Performance: Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrated with other languages.
Reliability: Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.
Productivity: Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool (Cargo), auto-formatter (rustfmt), linter (Clippy) and editor support (rust-analyzer).
Read “Installation” from The Book.
If you really want to install from source (though this is not recommended), see INSTALL.md.
See https://www.rust-lang.org/community for a list of chat platforms and forums.
See CONTRIBUTING.md.
For a detailed explanation of the compiler's architecture and how to begin contributing, see the rustc-dev-guide.
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.
The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the “Rust Trademarks”).
If you want to use these names or brands, please read the Rust language trademark policy.
Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.