Skip to content

Commit c2acb19

Browse files
mauropasseMauro Passerino
andauthored
Always publish inter-process on TRANSIENT_LOCAL publishers (ros2#152)
Co-authored-by: Mauro Passerino <[email protected]>
1 parent 894640f commit c2acb19

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

rclcpp/include/rclcpp/publisher.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,21 +275,19 @@ class Publisher : public PublisherBase
275275
bool inter_process_publish_needed =
276276
get_subscription_count() > get_intra_process_subscription_count();
277277

278-
if (inter_process_publish_needed) {
278+
// If the publisher is configured with transient local durability, we must publish
279+
// inter-process. This ensures that the RMW stores the messages for late joiner subscriptions.
280+
// This has the consequence of subscriptions experiencing the double-delivery issue
281+
// mentioned in https://github.com/ros2/rclcpp/issues/1750
282+
if (inter_process_publish_needed || buffer_) {
279283
auto shared_msg =
280284
this->do_intra_process_ros_message_publish_and_return_shared(std::move(msg));
281285
if (buffer_) {
282286
buffer_->add_shared(shared_msg);
283287
}
284288
this->do_inter_process_publish(*shared_msg);
285289
} else {
286-
if (buffer_) {
287-
auto shared_msg =
288-
this->do_intra_process_ros_message_publish_and_return_shared(std::move(msg));
289-
buffer_->add_shared(shared_msg);
290-
} else {
291-
this->do_intra_process_ros_message_publish(std::move(msg));
292-
}
290+
this->do_intra_process_ros_message_publish(std::move(msg));
293291
}
294292
}
295293

0 commit comments

Comments
 (0)