From 5825d64727cfd588ddba8d1ed97e2a017eb68d8f Mon Sep 17 00:00:00 2001 From: Koichi Imai <45482193+Koichi98@users.noreply.github.com> Date: Wed, 5 Feb 2025 20:22:51 +0900 Subject: [PATCH] fix: decrement_borrowed_publisher_num before calling publish_core (#360) * minimum shm Signed-off-by: Koichi Imai * fix for unit test Signed-off-by: Koichi Imai --------- Signed-off-by: Koichi Imai --- src/agnocastlib/include/agnocast_publisher.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/agnocastlib/include/agnocast_publisher.hpp b/src/agnocastlib/include/agnocast_publisher.hpp index 0fdbac8f..79386b47 100644 --- a/src/agnocastlib/include/agnocast_publisher.hpp +++ b/src/agnocastlib/include/agnocast_publisher.hpp @@ -90,6 +90,8 @@ class Publisher exit(EXIT_FAILURE); } + decrement_borrowed_publisher_num(); + const union ioctl_publish_args publish_args = publish_core( topic_name_, id_, static_cast(qos_.depth()), reinterpret_cast(message.get()), opened_mqs_); @@ -100,12 +102,6 @@ class Publisher publish_args.ret_entry_id); #endif - // We need to decrement borrowed_publisher_num before ros2_publish, otherwise the buffers used - // for ROS2 serialization will also use shared memory. Since we don't need to store any - // additional data in shared memory after the agnocast publish operation, here is the ideal - // point to decrement. - decrement_borrowed_publisher_num(); - for (uint32_t i = 0; i < publish_args.ret_released_num; i++) { MessageT * release_ptr = reinterpret_cast(publish_args.ret_released_addrs[i]); delete release_ptr;