From 47a876cef61312e793ebef7891064e65d8b1207d Mon Sep 17 00:00:00 2001 From: Yadunund Date: Sat, 28 Sep 2024 07:33:12 +0800 Subject: [PATCH] Create PublisherData within NodeData Signed-off-by: Yadunund --- rmw_zenoh_cpp/src/detail/rmw_node_data.cpp | 7 +++++++ rmw_zenoh_cpp/src/rmw_event.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/rmw_zenoh_cpp/src/detail/rmw_node_data.cpp b/rmw_zenoh_cpp/src/detail/rmw_node_data.cpp index 04d05483..9c100098 100644 --- a/rmw_zenoh_cpp/src/detail/rmw_node_data.cpp +++ b/rmw_zenoh_cpp/src/detail/rmw_node_data.cpp @@ -127,6 +127,13 @@ bool NodeData::create_pub_data( const rmw_qos_profile_t * qos_profile) { std::lock_guard lock_guard(mutex_); + if (is_shutdown_) { + RMW_ZENOH_LOG_ERROR_NAMED( + "rmw_zenoh_cpp", + "Unable to create PublisherData as the NodeData has been shutdown."); + return false; + } + if (pubs_.count(publisher) > 0) { RMW_ZENOH_LOG_ERROR_NAMED( "rmw_zenoh_cpp", diff --git a/rmw_zenoh_cpp/src/rmw_event.cpp b/rmw_zenoh_cpp/src/rmw_event.cpp index 75f03939..b0b4e5c8 100644 --- a/rmw_zenoh_cpp/src/rmw_event.cpp +++ b/rmw_zenoh_cpp/src/rmw_event.cpp @@ -63,8 +63,8 @@ rmw_publisher_event_init( } rmw_event->implementation_identifier = publisher->implementation_identifier; - // TODO(Yadunund): This is still subject to race conditions. Should we - // set data to context_impl which is assumed to outlast all entities? + // TODO(Yadunund): This assumes that publishers outlive their events + // which is the behavior in rcl/rclcpp. rmw_event->data = pub_data->events_mgr().get(); rmw_event->event_type = event_type;