diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_subscriber_info.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_subscriber_info.hpp index e46bf9e81..fa97cccf2 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_subscriber_info.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_subscriber_info.hpp @@ -142,7 +142,7 @@ class SubListener : public EventListenerInterface, public eprosima::fastrtps::Su } void - data_taken(eprosima::fastrtps::Subscriber * sub) + updateDataCount(eprosima::fastrtps::Subscriber * sub) { // Make sure to call into Fast-RTPS before taking the lock to avoid an // ABBA deadlock between internalMutex_ and mutexes inside of Fast-RTPS. diff --git a/rmw_fastrtps_shared_cpp/src/rmw_take.cpp b/rmw_fastrtps_shared_cpp/src/rmw_take.cpp index 1bd93273b..3c5c42696 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_take.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_take.cpp @@ -75,7 +75,7 @@ _take( data.data = ros_message; data.impl = info->type_support_impl_; if (info->subscriber_->takeNextData(&data, &sinfo)) { - info->listener_->data_taken(info->subscriber_); + info->listener_->updateDataCount(info->subscriber_); if (eprosima::fastrtps::rtps::ALIVE == sinfo.sampleKind) { if (message_info) { @@ -83,6 +83,8 @@ _take( } *taken = true; } + } else { + info->listener_->updateDataCount(info->subscriber_); } return RMW_RET_OK; @@ -267,7 +269,7 @@ _take_serialized_message( data.data = &buffer; data.impl = nullptr; // not used when is_cdr_buffer is true if (info->subscriber_->takeNextData(&data, &sinfo)) { - info->listener_->data_taken(info->subscriber_); + info->listener_->updateDataCount(info->subscriber_); if (eprosima::fastrtps::rtps::ALIVE == sinfo.sampleKind) { auto buffer_size = static_cast(buffer.getBufferSize()); @@ -285,6 +287,8 @@ _take_serialized_message( } *taken = true; } + } else { + info->listener_->updateDataCount(info->subscriber_); } return RMW_RET_OK;