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 <sean@xobs.io>
This commit is contained in:
Sean Cross 2022-06-09 17:48:20 +08:00
parent ceef2b0bd6
commit f4f5418190

View file

@ -124,21 +124,19 @@ impl Envelope {
)); ));
} }
_ => { Message::Borrow(_) | Message::MutableBorrow(_) | Message::Scalar(_) => {
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);
match result {
if let Ok(crate::Result::Ok) = result {
// `new_self` will have its Drop() called // `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 there's an error, reconstitute ourselves and return.
if let Err(e) = result { Err(e) => Err((new_self, e)),
return 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),
}
} }
} }
} }