handle the expected error from the disconnect call

When disconnecting from a remote server that was destroyed, we
would expect (and get) a ServerNotFound error.
This commit is contained in:
bunnie 2021-10-19 15:01:36 +08:00
parent 2885890ee2
commit 60b0e3df87

View file

@ -227,9 +227,18 @@ fn xmain() -> ! {
let mut cid_to_disconnect: Option<CID> = None;
loop {
let mut msg = xous::receive_message(net_sid).unwrap();
if let Some(_dc_cid) = cid_to_disconnect.take() { // disconnect previous loop iter's connection after d/c OK response was sent
// CHECK WITH XOBS: maybe these connections are auto-closed when the server is destroyed?
// unsafe{xous::disconnect(dc_cid).expect("couldn't disconnect from dropped UDP object")};
if let Some(dc_cid) = cid_to_disconnect.take() { // disconnect previous loop iter's connection after d/c OK response was sent
unsafe{
match xous::disconnect(dc_cid) {
Ok(_) => {},
Err(xous::Error::ServerNotFound) => {
log::trace!("Disconnect returned the expected error code for a remote that has been destroyed.")
},
Err(e) => {
log::error!("Attempt to de-allocate CID to destroyed server met with error: {:?}", e);
},
}
}
}
match FromPrimitive::from_usize(msg.body.id()) {
Some(Opcode::UdpBind) => {