From 3d75fb16d29520a32449639e620197278e62a274 Mon Sep 17 00:00:00 2001 From: Iker Luengo Date: Fri, 3 Jan 2020 12:39:24 +0100 Subject: [PATCH] Ref. 5750 more initialize data limits on WriterProxyData and ReaderProxyData --- .../rtps/builtin/data/ReaderProxyData.h | 4 ++++ .../rtps/builtin/data/WriterProxyData.h | 4 ++++ src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 18 +++++++++++++----- src/cpp/rtps/builtin/data/WriterProxyData.cpp | 14 ++++++++++++-- .../rtps/builtin/discovery/participant/PDP.cpp | 4 ++-- src/cpp/rtps/reader/StatefulReader.cpp | 4 ++-- .../rtps/builtin/data/ReaderProxyData.h | 9 +++++++++ .../rtps/builtin/data/WriterProxyData.h | 8 ++++++++ test/unittest/rtps/reader/WriterProxyTests.cpp | 7 ++++--- 9 files changed, 58 insertions(+), 14 deletions(-) diff --git a/include/fastrtps/rtps/builtin/data/ReaderProxyData.h b/include/fastrtps/rtps/builtin/data/ReaderProxyData.h index a4183b4f175..5cced2fb2c9 100644 --- a/include/fastrtps/rtps/builtin/data/ReaderProxyData.h +++ b/include/fastrtps/rtps/builtin/data/ReaderProxyData.h @@ -51,6 +51,10 @@ class ReaderProxyData { public: + RTPS_DllAPI ReaderProxyData( + const size_t max_unicast_locators, + const size_t max_multicast_locators); + RTPS_DllAPI ReaderProxyData( const size_t max_unicast_locators, const size_t max_multicast_locators, diff --git a/include/fastrtps/rtps/builtin/data/WriterProxyData.h b/include/fastrtps/rtps/builtin/data/WriterProxyData.h index 12d539f5065..10fb5981172 100644 --- a/include/fastrtps/rtps/builtin/data/WriterProxyData.h +++ b/include/fastrtps/rtps/builtin/data/WriterProxyData.h @@ -50,6 +50,10 @@ class WriterProxyData { public: + RTPS_DllAPI WriterProxyData( + const size_t max_unicast_locators, + const size_t max_multicast_locators); + RTPS_DllAPI WriterProxyData( const size_t max_unicast_locators, const size_t max_multicast_locators, diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index cfef7d86410..d695c9cf490 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -37,8 +37,7 @@ namespace rtps { ReaderProxyData::ReaderProxyData ( const size_t max_unicast_locators, - const size_t max_multicast_locators, - const VariableLengthDataLimits& data_limits) + const size_t max_multicast_locators) : m_expectsInlineQos(false) #if HAVE_SECURITY , security_attributes_(0UL) @@ -52,9 +51,15 @@ ReaderProxyData::ReaderProxyData ( , m_type_id(nullptr) , m_type(nullptr) { - { - m_qos.m_userData.max_size(data_limits.max_user_data); - } +} + +ReaderProxyData::ReaderProxyData ( + const size_t max_unicast_locators, + const size_t max_multicast_locators, + const VariableLengthDataLimits& data_limits) + : ReaderProxyData(max_unicast_locators, max_multicast_locators) +{ + m_qos.m_userData.max_size(data_limits.max_user_data); } ReaderProxyData::~ReaderProxyData() @@ -829,7 +834,10 @@ void ReaderProxyData::clear() m_userDefinedId = 0; m_isAlive = true; m_topicKind = NO_KEY; + //clear user data but keep max size on qos + size_t max_user_data = m_qos.m_userData.max_size(); m_qos = ReaderQos(); + m_qos.m_userData.max_size(max_user_data); m_topicDiscoveryKind = NO_CHECK; if (m_type_id) { diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index 9a4b0f59ab2..d129425d6cd 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -40,8 +40,7 @@ namespace rtps { WriterProxyData::WriterProxyData( const size_t max_unicast_locators, - const size_t max_multicast_locators, - const VariableLengthDataLimits& data_limits) + const size_t max_multicast_locators) #if HAVE_SECURITY : security_attributes_(0) , plugin_security_attributes_(0) @@ -55,6 +54,14 @@ WriterProxyData::WriterProxyData( , m_topicDiscoveryKind(NO_CHECK) , m_type_id(nullptr) , m_type(nullptr) +{ +} + +WriterProxyData::WriterProxyData( + const size_t max_unicast_locators, + const size_t max_multicast_locators, + const VariableLengthDataLimits& data_limits) + : WriterProxyData(max_unicast_locators, max_multicast_locators) { m_qos.m_userData.max_size(data_limits.max_user_data); } @@ -832,7 +839,10 @@ void WriterProxyData::clear() m_typeName = ""; m_topicName = ""; m_userDefinedId = 0; + //clear user data but keep max size on qos + size_t max_user_data = m_qos.m_userData.max_size(); m_qos = WriterQos(); + m_qos.m_userData.max_size(max_user_data); m_typeMaxSerialized = 0; m_topicKind = NO_KEY; persistence_guid_ = c_Guid_Unknown; diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 6b89501b6c8..025af29a11b 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -100,12 +100,12 @@ PDP::PDP ( for (size_t i = 0; i < allocation.total_readers().initial; ++i) { - reader_proxies_pool_.push_back(new ReaderProxyData(max_unicast_locators, max_multicast_locators)); + reader_proxies_pool_.push_back(new ReaderProxyData(max_unicast_locators, max_multicast_locators, allocation.data_limits)); } for (size_t i = 0; i < allocation.total_writers().initial; ++i) { - writer_proxies_pool_.push_back(new WriterProxyData(max_unicast_locators, max_multicast_locators)); + writer_proxies_pool_.push_back(new WriterProxyData(max_unicast_locators, max_multicast_locators, allocation.data_limits)); } } diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 6091c3bf136..42e1d4a6ce3 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -83,7 +83,7 @@ StatefulReader::StatefulReader( const RTPSParticipantAttributes& part_att = pimpl->getRTPSParticipantAttributes(); for (size_t n = 0; n < att.matched_writers_allocation.initial; ++n) { - matched_writers_pool_.push_back(new WriterProxy(this, part_att.allocation.locators, proxy_changes_config_)); + matched_writers_pool_.push_back(new WriterProxy(this, part_att.allocation.locators, part_att.allocation.data_limits, proxy_changes_config_)); } } @@ -126,7 +126,7 @@ bool StatefulReader::matched_writer_add( if (matched_writers_.size() + matched_writers_pool_.size() < max_readers) { const RTPSParticipantAttributes& part_att = mp_RTPSParticipant->getRTPSParticipantAttributes(); - wp = new WriterProxy(this, part_att.allocation.locators, proxy_changes_config_); + wp = new WriterProxy(this, part_att.allocation.locators, part_att.allocation.data_limits, proxy_changes_config_); } else { diff --git a/test/mock/rtps/ReaderProxyData/fastrtps/rtps/builtin/data/ReaderProxyData.h b/test/mock/rtps/ReaderProxyData/fastrtps/rtps/builtin/data/ReaderProxyData.h index 4a5d0dbde82..d01b7490999 100644 --- a/test/mock/rtps/ReaderProxyData/fastrtps/rtps/builtin/data/ReaderProxyData.h +++ b/test/mock/rtps/ReaderProxyData/fastrtps/rtps/builtin/data/ReaderProxyData.h @@ -22,6 +22,8 @@ #include #include #include +#include "fastrtps/rtps/attributes/RTPSParticipantAllocationAttributes.hpp" + #if HAVE_SECURITY #include @@ -43,6 +45,13 @@ class ReaderProxyData : remote_locators_(max_unicast_locators, max_multicast_locators) { } + ReaderProxyData( + size_t max_unicast_locators, + size_t max_multicast_locators, + const VariableLengthDataLimits& data_limits) + : remote_locators_(max_unicast_locators, max_multicast_locators) + { m_qos.m_userData.max_size(data_limits.max_user_data); } + const GUID_t& guid() const { return m_guid; } GUID_t& guid() { return m_guid; } diff --git a/test/mock/rtps/WriterProxyData/fastrtps/rtps/builtin/data/WriterProxyData.h b/test/mock/rtps/WriterProxyData/fastrtps/rtps/builtin/data/WriterProxyData.h index 197bc301ea2..fa2e2ba3099 100644 --- a/test/mock/rtps/WriterProxyData/fastrtps/rtps/builtin/data/WriterProxyData.h +++ b/test/mock/rtps/WriterProxyData/fastrtps/rtps/builtin/data/WriterProxyData.h @@ -22,6 +22,7 @@ #include #include #include +#include "fastrtps/rtps/attributes/RTPSParticipantAllocationAttributes.hpp" #if HAVE_SECURITY #include @@ -43,6 +44,13 @@ class WriterProxyData : remote_locators_(max_unicast_locators, max_multicast_locators) { } + WriterProxyData( + size_t max_unicast_locators, + size_t max_multicast_locators, + const VariableLengthDataLimits& data_limits) + : remote_locators_(max_unicast_locators, max_multicast_locators) + { m_qos.m_userData.max_size(data_limits.max_user_data); } + const GUID_t& guid() const { return m_guid; } GUID_t& guid() { return m_guid; } diff --git a/test/unittest/rtps/reader/WriterProxyTests.cpp b/test/unittest/rtps/reader/WriterProxyTests.cpp index 6fb1236dfd6..f5b0c5203ae 100644 --- a/test/unittest/rtps/reader/WriterProxyTests.cpp +++ b/test/unittest/rtps/reader/WriterProxyTests.cpp @@ -103,7 +103,7 @@ TEST(WriterProxyTests, MissingChangesUpdate) StatefulReader readerMock; // avoid annoying uninteresting call warnings // Testing the Timed events are properly configured - WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), ResourceLimitedContainerConfig()); + WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), VariableLengthDataLimits(), ResourceLimitedContainerConfig()); EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initialAcknackDelay)).Times(1u); EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeatResponseDelay)).Times(1u); EXPECT_CALL(*wproxy.initial_acknack_, restart_timer()).Times(1u); @@ -270,7 +270,7 @@ TEST(WriterProxyTests, LostChangesUpdate) { WriterProxyData wattr(4u, 1u); StatefulReader readerMock; - WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), ResourceLimitedContainerConfig()); + WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), VariableLengthDataLimits(), ResourceLimitedContainerConfig()); EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initialAcknackDelay)).Times(1u); EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeatResponseDelay)).Times(1u); EXPECT_CALL(*wproxy.initial_acknack_, restart_timer()).Times(1u); @@ -379,6 +379,7 @@ TEST(WriterProxyTests, ReceivedChangeSet) StatefulReader readerMock; WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), + VariableLengthDataLimits(), ResourceLimitedContainerConfig()); /// Tests that initial acknack timed event is updated with new interval @@ -550,7 +551,7 @@ TEST(WriterProxyTests, IrrelevantChangeSet) { WriterProxyData wattr(4u, 1u); StatefulReader readerMock; - WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), ResourceLimitedContainerConfig()); + WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), VariableLengthDataLimits(), ResourceLimitedContainerConfig()); EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initialAcknackDelay)).Times(1u); EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeatResponseDelay)).Times(1u); EXPECT_CALL(*wproxy.initial_acknack_, restart_timer()).Times(1u);