diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index 6fd78c337de..9b4ff02fd3d 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -204,7 +204,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) { diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index cc063ded78f..3feaa35d7c1 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -3008,9 +3008,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_); diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 7cf9d76db90..fb56d76a483 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -918,6 +918,28 @@ TEST(ParticipantTests, SimpleParticipantRemoteServerListConfiguration) EXPECT_EQ(ReturnCode_t::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.