Skip to content

Commit

Permalink
fixes for rmw callbacks in qos_event class (ros2#2102)
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
  • Loading branch information
alsora authored and Alberto Soragna committed Apr 29, 2023
1 parent 1675ac5 commit b422afb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 3 additions & 2 deletions rclcpp/include/rclcpp/qos_event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ class QOSEventHandlerBase : public Waitable
void
set_on_new_event_callback(rcl_event_callback_t callback, const void * user_data);

rcl_event_t event_handle_;
size_t wait_set_event_index_;
std::recursive_mutex callback_mutex_;
std::function<void(size_t)> on_new_event_callback_{nullptr};

rcl_event_t event_handle_;
size_t wait_set_event_index_;
};

template<typename EventCallbackT, typename ParentHandleT>
Expand Down
4 changes: 1 addition & 3 deletions rclcpp/src/rclcpp/qos_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ QOSEventHandlerBase::~QOSEventHandlerBase()
// This clearing is not needed for other rclcpp entities like pub/subs, since
// they do own the underlying rmw entities, which are destroyed
// on their rclcpp destructors, thus no risk of dangling pointers.
if (on_new_event_callback_) {
clear_on_ready_callback();
}
clear_on_ready_callback();

if (rcl_event_fini(&event_handle_) != RCL_RET_OK) {
RCUTILS_LOG_ERROR_NAMED(
Expand Down

0 comments on commit b422afb

Please sign in to comment.