Skip to content

Commit

Permalink
fix: decrement_borrowed_publisher_num before calling publish_core (#360)
Browse files Browse the repository at this point in the history
* minimum shm

Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>

* fix for unit test

Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>

---------

Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
  • Loading branch information
Koichi98 authored Feb 5, 2025
1 parent a701d43 commit 5825d64
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/agnocastlib/include/agnocast_publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(qos_.depth()),
reinterpret_cast<uint64_t>(message.get()), opened_mqs_);
Expand All @@ -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<MessageT *>(publish_args.ret_released_addrs[i]);
delete release_ptr;
Expand Down

0 comments on commit 5825d64

Please sign in to comment.