mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
Merge pull request #274 from betrusted-io/xous-names-tryconnect
Add TryConnect call to xous-names
This commit is contained in:
commit
28f42baa44
2 changed files with 39 additions and 4 deletions
|
|
@ -52,6 +52,34 @@ pub enum Opcode {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
BlockingConnect = 6,
|
BlockingConnect = 6,
|
||||||
|
|
||||||
|
/// Connect to a Server, returning the connection ID or an authentication request if
|
||||||
|
/// it exists, and returning ServerNotFound if it does not exist.
|
||||||
|
///
|
||||||
|
/// # Message Types
|
||||||
|
///
|
||||||
|
/// * MutableLend
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// The memory being pointed to should be a &str, and the length of the string should
|
||||||
|
/// be specified in the `valid` field.
|
||||||
|
///
|
||||||
|
/// # Return Values
|
||||||
|
///
|
||||||
|
/// Memory is overwritten to contain a return value. This return value can be defined
|
||||||
|
/// as the following enum:
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// #[repr(C)]
|
||||||
|
/// #[non_exhaustive]
|
||||||
|
/// enum ConnectResult {
|
||||||
|
/// Success(xous::CID /* connection ID */, [u32; 4] /* Disconnection token */),
|
||||||
|
/// Error(u32 /* error code */),
|
||||||
|
/// Unhandled, /* Catchall for future Results */
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
TryConnect = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ enum ConnectError {
|
||||||
|
|
||||||
/// The message was not a mutable memory message
|
/// The message was not a mutable memory message
|
||||||
InvalidMessageType = 4,
|
InvalidMessageType = 4,
|
||||||
|
|
||||||
|
/// The server does not currently exist, and a blocking request was made
|
||||||
|
ServerNotFound = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
|
|
@ -464,7 +467,7 @@ fn main() -> ! {
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Some(api::Opcode::BlockingConnect) => {
|
Some(api::Opcode::BlockingConnect) | Some(api::Opcode::TryConnect) => {
|
||||||
if !msg.body.is_blocking() {
|
if !msg.body.is_blocking() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -479,9 +482,13 @@ fn main() -> ! {
|
||||||
respond_connect_success(msg, cid, disc)
|
respond_connect_success(msg, cid, disc)
|
||||||
}
|
}
|
||||||
Ok(ConnectSuccess::Wait) => {
|
Ok(ConnectSuccess::Wait) => {
|
||||||
// Push waiting connections here, which will prevent it from getting
|
if msg.body.id() == api::Opcode::TryConnect as usize {
|
||||||
// dropped and responded to.
|
respond_connect_error(msg, ConnectError::ServerNotFound);
|
||||||
waiting_connections.push(msg);
|
} else {
|
||||||
|
// Push waiting connections here, which will prevent it from getting
|
||||||
|
// dropped and responded to.
|
||||||
|
waiting_connections.push(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue