mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix(net): write NetError code at byte 1 too, so std-side recv decodes correctly
Mirror the error code at byte 1 (in addition to byte 4) in respond_with_error. The std-side Xous net backend's send path reads byte 4 (correct vs. the historical [1,1,1,1,code,0,0,0] layout), but the recv paths read byte 1 (which is always 1 under the old layout, so ErrorKind::TimedOut and WouldBlock were unreachable from the recv side). With this change both decoders see the right value; existing byte-4 readers are unaffected; the "buf as u32-LE != 0" error marker still holds because byte 0 stays 1. Companion PR to rust-lang/rust will fix the std side to read byte 4 and match the send path. This kernel-side mirror is the shippable workaround until that lands and works with any Rust-toolchain version.
This commit is contained in:
parent
a79a1f8de5
commit
cfcc12eee3
1 changed files with 7 additions and 3 deletions
|
|
@ -54,15 +54,19 @@ pub(crate) fn respond_with_error(mut env: xous::MessageEnvelope, code: NetError)
|
||||||
body.valid = None;
|
body.valid = None;
|
||||||
let s: &mut [u8] = unsafe { body.buf.as_slice_mut() };
|
let s: &mut [u8] = unsafe { body.buf.as_slice_mut() };
|
||||||
let mut i = s.iter_mut();
|
let mut i = s.iter_mut();
|
||||||
|
let code = code as u8;
|
||||||
|
|
||||||
// Duplicate error to ensure it's seen as an error regardless of byte order/return type
|
// Duplicate error to ensure it's seen as an error regardless of byte order/return type
|
||||||
// This is necessary because errors are encoded as `u8` slices, but "good"
|
// This is necessary because errors are encoded as `u8` slices, but "good"
|
||||||
// responses may be encoded as `u16` or `u32` slices.
|
// responses may be encoded as `u16` or `u32` slices.
|
||||||
|
//
|
||||||
|
// Mirror code at byte 1 (where the std-side recv path reads) in
|
||||||
|
// addition to byte 4 (where the std-side send path reads).
|
||||||
|
*i.next()? = 1;
|
||||||
|
*i.next()? = code;
|
||||||
*i.next()? = 1;
|
*i.next()? = 1;
|
||||||
*i.next()? = 1;
|
*i.next()? = 1;
|
||||||
*i.next()? = 1;
|
*i.next()? = code;
|
||||||
*i.next()? = 1;
|
|
||||||
*i.next()? = code as u8;
|
|
||||||
*i.next()? = 0;
|
*i.next()? = 0;
|
||||||
*i.next()? = 0;
|
*i.next()? = 0;
|
||||||
*i.next()? = 0;
|
*i.next()? = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue