From f4f54181901c38d4eebbcfd2beabb4f99fbda63e Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 9 Jun 2022 17:48:20 +0800 Subject: [PATCH] xous: envelope: handle MemoryReturned in forward() Previously, we only handled messages that were forwarded. With this patch, we also handle memory messages that were returned. This fixes #165 Signed-off-by: Sean Cross --- xous-rs/src/definitions/messages/envelope.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/xous-rs/src/definitions/messages/envelope.rs b/xous-rs/src/definitions/messages/envelope.rs index 07c75283b..70a7cc503 100644 --- a/xous-rs/src/definitions/messages/envelope.rs +++ b/xous-rs/src/definitions/messages/envelope.rs @@ -124,21 +124,19 @@ impl Envelope { )); } - _ => { + Message::Borrow(_) | Message::MutableBorrow(_) | Message::Scalar(_) => { let result = crate::send_message(connection, body); let new_self = ManuallyDrop::into_inner(manual_self); - - if let Ok(crate::Result::Ok) = result { + match result { // `new_self` will have its Drop() called - return Ok(()); - } + Ok(crate::Result::Ok) | Ok(crate::Result::MemoryReturned(_, _)) => Ok(()), - // If there's an error, reconstitute ourselves and return. - if let Err(e) = result { - return Err((new_self, e)); - } + // If there's an error, reconstitute ourselves and return. + Err(e) => Err((new_self, e)), - return Err((new_self, crate::Error::MemoryInUse)); + // Any other value is a bug in the kernel + o => panic!("unrecognized return from send_message: {:?}", o), + } } } }