Skip to content

Commit

Permalink
Always publish inter-process on TRANSIENT_LOCAL publishers (ros2#152)
Browse files Browse the repository at this point in the history
Co-authored-by: Mauro Passerino <[email protected]>
  • Loading branch information
mauropasse and Mauro Passerino authored Aug 21, 2024
1 parent 894640f commit c2acb19
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions rclcpp/include/rclcpp/publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,19 @@ 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 shared_msg =
this->do_intra_process_ros_message_publish_and_return_shared(std::move(msg));
if (buffer_) {
buffer_->add_shared(shared_msg);
}
this->do_inter_process_publish(*shared_msg);
} else {
if (buffer_) {
auto shared_msg =
this->do_intra_process_ros_message_publish_and_return_shared(std::move(msg));
buffer_->add_shared(shared_msg);
} else {
this->do_intra_process_ros_message_publish(std::move(msg));
}
this->do_intra_process_ros_message_publish(std::move(msg));
}
}

Expand Down

0 comments on commit c2acb19

Please sign in to comment.