Skip to content

Commit

Permalink
xous-names: implement non-blocking TryConnect call
Browse files Browse the repository at this point in the history
This call can be used by clients to try connecting to a service. If the
service is not available, this will fail to connect.

Signed-off-by: Sean Cross <[email protected]>
  • Loading branch information
xobs committed Nov 7, 2022
1 parent 3ca57bc commit 3ca323f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions services/xous-names/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ enum ConnectError {

/// The message was not a mutable memory message
InvalidMessageType = 4,

/// The server does not currently exist, and a blocking request was made
ServerNotFound = 5,
}

#[derive(PartialEq)]
Expand Down Expand Up @@ -464,7 +467,7 @@ fn main() -> ! {
xous::return_scalar(msg.sender, 0).unwrap();
}
}),
Some(api::Opcode::BlockingConnect) => {
Some(api::Opcode::BlockingConnect) | Some(api::Opcode::TryConnect) => {
if !msg.body.is_blocking() {
continue;
}
Expand All @@ -479,9 +482,13 @@ fn main() -> ! {
respond_connect_success(msg, cid, disc)
}
Ok(ConnectSuccess::Wait) => {
// Push waiting connections here, which will prevent it from getting
// dropped and responded to.
waiting_connections.push(msg);
if msg.body.id() == api::Opcode::TryConnect as usize {
respond_connect_error(msg, ConnectError::ServerNotFound);
} else {
// Push waiting connections here, which will prevent it from getting
// dropped and responded to.
waiting_connections.push(msg);
}
}
}
}
Expand Down

0 comments on commit 3ca323f

Please sign in to comment.