mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
xous: handle forwarding of BlockingScalar messages
These are not automatically returned on their own, so handle the return manually. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
fa98b865df
commit
617e075c08
1 changed files with 29 additions and 1 deletions
|
|
@ -57,7 +57,11 @@ impl Envelope {
|
||||||
///
|
///
|
||||||
/// If there is an error, then the original Envelope is returned along with the resulting
|
/// If there is an error, then the original Envelope is returned along with the resulting
|
||||||
/// error.
|
/// error.
|
||||||
pub fn forward(mut self, connection: CID, id: MessageId) -> Result<(), (Envelope, crate::Error)> {
|
pub fn forward(
|
||||||
|
mut self,
|
||||||
|
connection: CID,
|
||||||
|
id: MessageId,
|
||||||
|
) -> Result<(), (Envelope, crate::Error)> {
|
||||||
use core::mem::ManuallyDrop;
|
use core::mem::ManuallyDrop;
|
||||||
|
|
||||||
// Update our ID to match the newly-sent message. Reuse the same message struct.
|
// Update our ID to match the newly-sent message. Reuse the same message struct.
|
||||||
|
|
@ -69,6 +73,7 @@ impl Envelope {
|
||||||
// Unsafe because there are now two things that are pointing at "self.body". However,
|
// Unsafe because there are now two things that are pointing at "self.body". However,
|
||||||
// this is fine since these two pointers are never used at the same time.
|
// this is fine since these two pointers are never used at the same time.
|
||||||
let body = unsafe { core::ptr::read(&manual_self.body) };
|
let body = unsafe { core::ptr::read(&manual_self.body) };
|
||||||
|
let sender = unsafe { core::ptr::read(&manual_self.sender) };
|
||||||
|
|
||||||
// Different messages have different kinds of lifetimes, so they must all be
|
// Different messages have different kinds of lifetimes, so they must all be
|
||||||
// handled differently.
|
// handled differently.
|
||||||
|
|
@ -92,6 +97,29 @@ impl Envelope {
|
||||||
crate::Error::MemoryInUse,
|
crate::Error::MemoryInUse,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
Message::BlockingScalar(_) => {
|
||||||
|
let result = crate::send_message(connection, body);
|
||||||
|
|
||||||
|
// If there's an error, reconstitute ourselves and return.
|
||||||
|
if let Err(e) = result {
|
||||||
|
return Err((ManuallyDrop::into_inner(manual_self), e));
|
||||||
|
} else if let Ok(crate::Result::Scalar1(v)) = result {
|
||||||
|
if let Err(e) = crate::return_scalar(sender, v) {
|
||||||
|
return Err((ManuallyDrop::into_inner(manual_self), e));
|
||||||
|
}
|
||||||
|
return Ok(());
|
||||||
|
} else if let Ok(crate::Result::Scalar2(v1, v2)) = result {
|
||||||
|
if let Err(e) = crate::return_scalar2(sender, v1, v2) {
|
||||||
|
return Err((ManuallyDrop::into_inner(manual_self), e));
|
||||||
|
}
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
return Err((
|
||||||
|
ManuallyDrop::into_inner(manual_self),
|
||||||
|
crate::Error::MemoryInUse,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
let result = crate::send_message(connection, body);
|
let result = crate::send_message(connection, body);
|
||||||
let new_self = ManuallyDrop::into_inner(manual_self);
|
let new_self = ManuallyDrop::into_inner(manual_self);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue