Skip to content

Commit

Permalink
Improve PDPClients initialization (#5459)
Browse files Browse the repository at this point in the history
* Refs #21433: Add Test

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #21433: Avoid using multicast metatraffic for CLIENTS & SUPER_CLIENTS

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #21433: Typo

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

---------

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
(cherry picked from commit 451847c)
  • Loading branch information
cferreiragonz authored and mergify[bot] committed Dec 18, 2024
1 parent b0e1c69 commit f826362
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ ParticipantProxyData* PDPClient::createParticipantProxyData(
ParticipantProxyData* pdata = add_participant_proxy_data(participant_data.m_guid, is_server, &participant_data);
if (pdata != nullptr)
{
// Clients only assert its server lifeliness, other clients liveliness is provided
// Clients only assert its server liveliness, other clients liveliness is provided
// through server's PDP discovery data
if (is_server)
{
Expand Down
10 changes: 7 additions & 3 deletions src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2728,9 +2728,13 @@ void RTPSParticipantImpl::get_default_metatraffic_locators(
{
uint32_t metatraffic_multicast_port = att.port.getMulticastPort(domain_id_);

m_network_Factory.getDefaultMetatrafficMulticastLocators(att.builtin.metatrafficMulticastLocatorList,
metatraffic_multicast_port);
m_network_Factory.NormalizeLocators(att.builtin.metatrafficMulticastLocatorList);
if (m_att.builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::CLIENT &&
m_att.builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::SUPER_CLIENT)
{
m_network_Factory.getDefaultMetatrafficMulticastLocators(att.builtin.metatrafficMulticastLocatorList,
metatraffic_multicast_port);
m_network_Factory.NormalizeLocators(att.builtin.metatrafficMulticastLocatorList);
}

m_network_Factory.getDefaultMetatrafficUnicastLocators(att.builtin.metatrafficUnicastLocatorList,
metatraffic_unicast_port_);
Expand Down
22 changes: 22 additions & 0 deletions test/unittest/dds/participant/ParticipantTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,28 @@ TEST(ParticipantTests, SimpleParticipantRemoteServerListConfiguration)
EXPECT_EQ(RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant));
}

/**
* Test that checks a CLIENT participant is not initialized with builtin metatrafficMulticastLocators.
*/
TEST(ParticipantTests, NoBuiltinMetatrafficMulticastForClients)
{
DomainParticipantQos qos;
qos.wire_protocol().builtin.discovery_config.discoveryProtocol = fastdds::rtps::DiscoveryProtocol::CLIENT;
DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant(
(uint32_t)GET_PID() % 230, qos);
ASSERT_NE(nullptr, participant);

fastdds::rtps::RTPSParticipantAttributes attributes;
get_rtps_attributes(participant, attributes);
EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::CLIENT);
EXPECT_EQ(attributes.builtin.metatrafficMulticastLocatorList.size(), 0);

DomainParticipantQos result_qos = participant->get_qos();
EXPECT_EQ(RETCODE_OK, participant->set_qos(result_qos));

EXPECT_EQ(RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant));
}


/**
* Test that a SIMPLE participant is transformed into a CLIENT if the variable ROS_SUPER_CLIENT is false and into a SUPERCLIENT if it's true.
Expand Down

0 comments on commit f826362

Please sign in to comment.