Skip to content

Commit

Permalink
refactor: add session_is_valid check
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanYuYuan committed Dec 4, 2024
1 parent 0255c37 commit 09b45c3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ rmw_create_publisher(
context_impl,
"unable to get rmw_context_impl_s",
return nullptr);
if (!context_impl->session_is_valid()) {
RMW_SET_ERROR_MSG("zenoh session is invalid");
return nullptr;
}

rcutils_allocator_t * allocator = &node->context->options.allocator;
if (!rcutils_allocator_is_valid(allocator)) {
Expand Down Expand Up @@ -917,6 +921,10 @@ rmw_create_subscription(
context_impl,
"unable to get rmw_context_impl_s",
return nullptr);
if (!context_impl->session_is_valid()) {
RMW_SET_ERROR_MSG("zenoh session is invalid");
return nullptr;
}

rcutils_allocator_t * allocator = &node->context->options.allocator;
if (!rcutils_allocator_is_valid(allocator)) {
Expand Down Expand Up @@ -1385,6 +1393,10 @@ rmw_create_client(
context_impl,
"unable to get rmw_context_impl_s",
return nullptr);
if (!context_impl->session_is_valid()) {
RMW_SET_ERROR_MSG("zenoh session is invalid");
return nullptr;
}

// Get the service type support.
const rosidl_service_type_support_t * type_support = find_service_type_support(type_supports);
Expand Down Expand Up @@ -1629,6 +1641,10 @@ rmw_create_service(
context_impl,
"unable to get rmw_context_impl_s",
return nullptr);
if (!context_impl->session_is_valid()) {
RMW_SET_ERROR_MSG("zenoh session is invalid");
return nullptr;
}

// Get the RMW type support.
const rosidl_service_type_support_t * type_support = find_service_type_support(type_supports);
Expand Down

0 comments on commit 09b45c3

Please sign in to comment.