Skip to content

Commit

Permalink
Humble backport and new fixes (#154)
Browse files Browse the repository at this point in the history
* Always publish inter-process on TRANSIENT_LOCAL pubs (#152)

* Backport upstream Action fixes

 - ros2#2531

* Fix actions feedback race

 - ros2#2451

* Fix data race in Actions: Part 3

---------

Co-authored-by: Mauro Passerino <[email protected]>
  • Loading branch information
mauropasse and Mauro Passerino authored Aug 23, 2024
1 parent c2acb19 commit eaeda0f
Show file tree
Hide file tree
Showing 4 changed files with 576 additions and 251 deletions.
7 changes: 5 additions & 2 deletions rclcpp/include/rclcpp/experimental/intra_process_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,14 @@ class IntraProcessManager
auto server = get_matching_intra_process_action_server<ActionT>(ipc_action_client_id);

if (server) {
{
std::unique_lock<std::shared_timed_mutex> lock(mutex_);
clients_uuid_to_id_[goal_id] = ipc_action_client_id;
}

server->store_ipc_action_goal_request(
ipc_action_client_id, std::move(goal_request));

std::unique_lock<std::shared_timed_mutex> lock(mutex_);
clients_uuid_to_id_[goal_id] = ipc_action_client_id;
return true;
}
return false;
Expand Down
11 changes: 5 additions & 6 deletions rclcpp/include/rclcpp/publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ class Publisher : public PublisherBase
bool inter_process_publish_needed =
get_subscription_count() > get_intra_process_subscription_count();

if (inter_process_publish_needed) {
// If the publisher is configured with transient local durability, we must publish
// inter-process. This ensures that the RMW stores the messages for late joiner subscriptions.
// This has the consequence of subscriptions experiencing the double-delivery issue
// mentioned in https://github.com/ros2/rclcpp/issues/1750
if (inter_process_publish_needed || buffer_) {
auto ros_msg_ptr = std::make_shared<ROSMessageType>();
// TODO(clalancette): This is unnecessarily doing an additional conversion
// that may have already been done in do_intra_process_publish_and_return_shared().
Expand All @@ -363,11 +367,6 @@ class Publisher : public PublisherBase
buffer_->add_shared(ros_msg_ptr);
}
} else {
if (buffer_) {
auto ros_msg_ptr = std::make_shared<ROSMessageType>();
rclcpp::TypeAdapter<MessageT>::convert_to_ros_message(*msg, *ros_msg_ptr);
buffer_->add_shared(ros_msg_ptr);
}
this->do_intra_process_publish(std::move(msg));
}
}
Expand Down
Loading

0 comments on commit eaeda0f

Please sign in to comment.