Skip to content

Commit 3ca323f

Browse files
committed
xous-names: implement non-blocking TryConnect call
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]>
1 parent 3ca57bc commit 3ca323f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

services/xous-names/src/main.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ enum ConnectError {
2626

2727
/// The message was not a mutable memory message
2828
InvalidMessageType = 4,
29+
30+
/// The server does not currently exist, and a blocking request was made
31+
ServerNotFound = 5,
2932
}
3033

3134
#[derive(PartialEq)]
@@ -464,7 +467,7 @@ fn main() -> ! {
464467
xous::return_scalar(msg.sender, 0).unwrap();
465468
}
466469
}),
467-
Some(api::Opcode::BlockingConnect) => {
470+
Some(api::Opcode::BlockingConnect) | Some(api::Opcode::TryConnect) => {
468471
if !msg.body.is_blocking() {
469472
continue;
470473
}
@@ -479,9 +482,13 @@ fn main() -> ! {
479482
respond_connect_success(msg, cid, disc)
480483
}
481484
Ok(ConnectSuccess::Wait) => {
482-
// Push waiting connections here, which will prevent it from getting
483-
// dropped and responded to.
484-
waiting_connections.push(msg);
485+
if msg.body.id() == api::Opcode::TryConnect as usize {
486+
respond_connect_error(msg, ConnectError::ServerNotFound);
487+
} else {
488+
// Push waiting connections here, which will prevent it from getting
489+
// dropped and responded to.
490+
waiting_connections.push(msg);
491+
}
485492
}
486493
}
487494
}

0 commit comments

Comments
 (0)