From decfc3cb5036b38f3359fb3494c2218bab38b078 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Sat, 2 Oct 2021 10:46:10 +0800 Subject: [PATCH] fix QoS depth settings for clients/service ignored Signed-off-by: Chen Lihui --- .../include/rmw_fastrtps_shared_cpp/custom_client_info.hpp | 7 +++++++ .../rmw_fastrtps_shared_cpp/custom_service_info.hpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_client_info.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_client_info.hpp index dad3c01e3..492a454f1 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_client_info.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_client_info.hpp @@ -33,6 +33,7 @@ #include "fastdds/dds/subscriber/DataReader.hpp" #include "fastdds/dds/subscriber/DataReaderListener.hpp" #include "fastdds/dds/subscriber/SampleInfo.hpp" +#include "fastdds/dds/subscriber/qos/DataReaderQos.hpp" #include "fastdds/dds/topic/TypeSupport.hpp" #include "fastdds/rtps/common/Guid.h" @@ -104,6 +105,12 @@ class ClientListener : public eprosima::fastdds::dds::DataReaderListener response.sample_identity_.writer_guid() == info_->writer_guid_) { std::lock_guard lock(internalMutex_); + const eprosima::fastrtps::HistoryQosPolicy & history = reader->get_qos().history(); + if (eprosima::fastrtps::KEEP_LAST_HISTORY_QOS == history.kind) { + while (list.size() >= static_cast(history.depth)) { + list.pop_front(); + } + } if (conditionMutex_ != nullptr) { std::unique_lock clock(*conditionMutex_); diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_service_info.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_service_info.hpp index f66cbdf60..a4e68abe8 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_service_info.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_service_info.hpp @@ -31,6 +31,7 @@ #include "fastdds/dds/subscriber/DataReader.hpp" #include "fastdds/dds/subscriber/DataReaderListener.hpp" #include "fastdds/dds/subscriber/SampleInfo.hpp" +#include "fastdds/dds/subscriber/qos/DataReaderQos.hpp" #include "fastdds/dds/topic/TypeSupport.hpp" #include "fastdds/rtps/common/Guid.h" @@ -225,6 +226,12 @@ class ServiceListener : public eprosima::fastdds::dds::DataReaderListener info_->pub_listener_->endpoint_add_reader_and_writer(reader_guid, writer_guid); std::lock_guard lock(internalMutex_); + const eprosima::fastrtps::HistoryQosPolicy & history = reader->get_qos().history(); + if (eprosima::fastrtps::KEEP_LAST_HISTORY_QOS == history.kind) { + while (list.size() >= static_cast(history.depth)) { + list.pop_front(); + } + } if (conditionMutex_ != nullptr) { std::unique_lock clock(*conditionMutex_);