Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify a zenoh router is available for the session #61

Merged
merged 3 commits into from
Nov 17, 2023

Conversation

francocipollone
Copy link
Collaborator

Summary

Verify that there is a connection between the Zenoh session being initialized at rmw_init method and a Zenoh router.
In case there is no connected router then return with error.

@francocipollone francocipollone force-pushed the francocipollone/check_zenoh_router branch from 89d5d00 to f08031d Compare November 9, 2023 21:52
z_info_routers_zid(session, z_move(router_callback));

rmw_ret_t ret;
if (*(static_cast<int *>(context)) == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to understand how the z_info_routers_zid() API works.

/**
 * Fetches the Zenoh IDs of all connected routers.
 *
 * `callback` will be called once for each ID, is guaranteed to never be called concurrently,
 * and is guaranteed to be dropped before this function exits.
 *
 * Retuns 0 on success, negative values on failure.
 */
ZENOHC_API
int8_t z_info_routers_zid(struct z_session_t session,
                          struct z_owned_closure_zid_t *callback);

If it returns an int8_t, is it a blocking function or will the function execute callbacks asynchronously? If its the former, we could just check if the return value is 0 and if so return RMW_RET_OK? Unless we plan to parse the zids we receive in the callbacks to check if the zid matches that of the zenoh router we run (and not any other zenoh router)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a blocking function or will the function execute callbacks asynchronously?

It is a blocking function.

we could just check if the return value is 0 and if so return RMW_RET_OK?

It "returns 0 in success" but that doesn't convey whether there are or not available routers. It would return 0 even if the zenoh router is missing. This only states whether the execution was correct. (Just realized that we should return error in case there is a failure, adding that...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we plan to parse the zids we receive in the callbacks to check if the zid matches that of the zenoh router we run (and not any other zenoh router)?

For the moment we need the callback to check that at least a router is connected to the session. I added the parsing of the id mainly for logging purposes. We could at some point verify the id to correctly assert that we are connected to the zenoh router we want. However it is a bit early for this I think, for the moment we don't have environments with more than one zenoh router.

rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp Outdated Show resolved Hide resolved
rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp Outdated Show resolved Hide resolved
rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp Outdated Show resolved Hide resolved
rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp Outdated Show resolved Hide resolved
rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp Outdated Show resolved Hide resolved
rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp Outdated Show resolved Hide resolved
rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp Outdated Show resolved Hide resolved
Signed-off-by: Franco Cipollone <[email protected]>
@clalancette clalancette merged commit 9752924 into rolling Nov 17, 2023
5 checks passed
@delete-merged-branch delete-merged-branch bot deleted the francocipollone/check_zenoh_router branch November 17, 2023 14:54
Yadunund pushed a commit that referenced this pull request Jan 12, 2024
* Verify zenoh router presence at rmw_init.

* Fail when an error in z_info_routers_zid is found.

Signed-off-by: Franco Cipollone <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants