Skip to content

Commit

Permalink
Safely shutdown SubscriptionData even if make() fails and cleanup todo
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund committed Oct 4, 2024
1 parent a4d985e commit f8ea0c3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
12 changes: 3 additions & 9 deletions rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,6 @@ SubscriptionData::SubscriptionData()
// Do nothing.
}

///=============================================================================
rmw_qos_profile_t SubscriptionData::adapted_qos_profile() const
{
std::lock_guard<std::mutex> lock(mutex_);
return entity_->topic_info()->qos_;
}


///=============================================================================
std::size_t SubscriptionData::guid() const
{
Expand Down Expand Up @@ -403,7 +395,9 @@ rmw_ret_t SubscriptionData::shutdown()
}

// Unregister this node from the ROS graph.
zc_liveliness_undeclare_token(z_move(token_));
if (zc_liveliness_token_check(&token_)) {
zc_liveliness_undeclare_token(z_move(token_));
}

z_owned_subscriber_t * sub = std::get_if<z_owned_subscriber_t>(&sub_);
if (sub != nullptr) {
Expand Down
4 changes: 0 additions & 4 deletions rmw_zenoh_cpp/src/detail/rmw_subscription_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ class SubscriptionData final
const rosidl_message_type_support_t * type_support,
const rmw_qos_profile_t * qos_profile);

// Get a copy of the actual qos_profile used by this Subscription.
// TODO(Yadunund): Remove since this can be gotten via topic_info().
rmw_qos_profile_t adapted_qos_profile() const;

// Publish a ROS message.
rmw_ret_t publish(
const void * ros_message,
Expand Down
2 changes: 1 addition & 1 deletion rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ rmw_subscription_get_actual_qos(
static_cast<rmw_zenoh_cpp::SubscriptionData *>(subscription->data);
RMW_CHECK_ARGUMENT_FOR_NULL(sub_data, RMW_RET_INVALID_ARGUMENT);

*qos = sub_data->adapted_qos_profile();
*qos = sub_data->topic_info().qos_;
return RMW_RET_OK;
}

Expand Down

0 comments on commit f8ea0c3

Please sign in to comment.