Skip to content

Commit

Permalink
Ref. 5750 more initialize data limits on WriterProxyData and ReaderPr…
Browse files Browse the repository at this point in the history
…oxyData
  • Loading branch information
IkerLuengo committed Feb 6, 2020
1 parent ce38603 commit 3d75fb1
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 14 deletions.
4 changes: 4 additions & 0 deletions include/fastrtps/rtps/builtin/data/ReaderProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions include/fastrtps/rtps/builtin/data/WriterProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 13 additions & 5 deletions src/cpp/rtps/builtin/data/ReaderProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
{
Expand Down
14 changes: 12 additions & 2 deletions src/cpp/rtps/builtin/data/WriterProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/rtps/builtin/discovery/participant/PDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/rtps/reader/StatefulReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_));
}
}

Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <fastrtps/rtps/common/Guid.h>
#include <fastrtps/rtps/common/RemoteLocators.hpp>
#include <fastrtps/qos/ReaderQos.h>
#include "fastrtps/rtps/attributes/RTPSParticipantAllocationAttributes.hpp"


#if HAVE_SECURITY
#include <fastrtps/rtps/security/accesscontrol/EndpointSecurityAttributes.h>
Expand All @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <fastrtps/rtps/common/Guid.h>
#include <fastrtps/rtps/common/RemoteLocators.hpp>
#include <fastrtps/qos/WriterQos.h>
#include "fastrtps/rtps/attributes/RTPSParticipantAllocationAttributes.hpp"

#if HAVE_SECURITY
#include <fastrtps/rtps/security/accesscontrol/EndpointSecurityAttributes.h>
Expand All @@ -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; }
Expand Down
7 changes: 4 additions & 3 deletions test/unittest/rtps/reader/WriterProxyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3d75fb1

Please sign in to comment.