Commit d1ef71c
authored
Rollup merge of rust-lang#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](betrusted-io/xous-core#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.3 files changed
Lines changed: 15 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
134 | 135 | | |
135 | | - | |
| 136 | + | |
136 | 137 | | |
137 | | - | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
220 | | - | |
| 223 | + | |
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
150 | 151 | | |
151 | | - | |
| 152 | + | |
152 | 153 | | |
153 | | - | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| |||
0 commit comments