From e482d8ecfc0dd5f0b63e6821aa9165e42c0446c9 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Thu, 6 Nov 2025 16:38:15 +0100 Subject: [PATCH 01/26] Refs #23923: Take mutex in getter and env file callback Signed-off-by: Juan Lopez Fernandez --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index f75fce58048..cd936ac5679 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -2872,7 +2872,11 @@ DurabilityKind_t RTPSParticipantImpl::get_persistence_durability_red_line( void RTPSParticipantImpl::environment_file_has_changed() { - RTPSParticipantAttributes patt = m_att; + RTPSParticipantAttributes patt; + { + std::lock_guard _(mutex_); + patt = m_att; + } // Only if it is a server/backup or a client override if (DiscoveryProtocol::SERVER == m_att.builtin.discovery_config.discoveryProtocol || DiscoveryProtocol::BACKUP == m_att.builtin.discovery_config.discoveryProtocol || @@ -3427,6 +3431,7 @@ dds::utils::TypePropagation RTPSParticipantImpl::type_propagation() const const RTPSParticipantAttributes& RTPSParticipantImpl::get_attributes() const { + std::lock_guard _(mutex_); return m_att; } From a9529de2d1bf5171316a0df9033028c76fffb78e Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Fri, 7 Nov 2025 12:08:32 +0100 Subject: [PATCH 02/26] Refs #23923: Only update mutable attributes Signed-off-by: Juan Lopez Fernandez --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 13 ++++++++++++- src/cpp/rtps/participant/RTPSParticipantImpl.hpp | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index cd936ac5679..47475e91fa6 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1671,7 +1671,7 @@ void RTPSParticipantImpl::update_attributes( // Update the attributes data member { std::lock_guard _(mutex_); - m_att = temp_atts; + update_mutable_attributes(temp_atts); } if (update_pdp) @@ -1681,6 +1681,17 @@ void RTPSParticipantImpl::update_attributes( } } +void RTPSParticipantImpl::update_mutable_attributes( + const RTPSParticipantAttributes& patt) +{ + // NTS + m_att.userData = patt.userData; + m_att.builtin.metatrafficUnicastLocatorList = patt.builtin.metatrafficUnicastLocatorList; + m_att.defaultUnicastLocatorList = patt.defaultUnicastLocatorList; + m_att.default_external_unicast_locators = patt.default_external_unicast_locators; + m_att.builtin.discovery_config.m_DiscoveryServers = patt.builtin.discovery_config.m_DiscoveryServers; +} + bool RTPSParticipantImpl::update_writer( RTPSWriter* rtps_writer, const fastdds::dds::WriterQos& wqos) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index c813ab0f17f..2c6fbec7e8a 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -1053,6 +1053,9 @@ class RTPSParticipantImpl void update_attributes( const RTPSParticipantAttributes& patt); + void update_mutable_attributes( + const RTPSParticipantAttributes& patt); + /** * Update local writer QoS * @param rtps_writer Writer to update. From 2f0beb84030b5748379a78976a878602416bea05 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Fri, 7 Nov 2025 12:09:21 +0100 Subject: [PATCH 03/26] Refs #23923: Copy attributes in getter Signed-off-by: Juan Lopez Fernandez --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 2 +- src/cpp/rtps/participant/RTPSParticipantImpl.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 47475e91fa6..94ad7fa40c0 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -3440,7 +3440,7 @@ dds::utils::TypePropagation RTPSParticipantImpl::type_propagation() const return dds::utils::to_type_propagation(m_att.properties); } -const RTPSParticipantAttributes& RTPSParticipantImpl::get_attributes() const +RTPSParticipantAttributes RTPSParticipantImpl::get_attributes() const { std::lock_guard _(mutex_); return m_att; diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index 2c6fbec7e8a..d4e538b1c86 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -893,7 +893,7 @@ class RTPSParticipantImpl public: - const RTPSParticipantAttributes& get_attributes() const; + RTPSParticipantAttributes get_attributes() const; /** * Create a Writer in this RTPSParticipant. From 4443cc93b3fd040536bfe12a5a4898c6a7747293 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Tue, 11 Nov 2025 09:30:24 +0100 Subject: [PATCH 04/26] Refs #23923: Undo copy attributes Signed-off-by: Juan Lopez Fernandez --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 2 +- src/cpp/rtps/participant/RTPSParticipantImpl.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 94ad7fa40c0..47475e91fa6 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -3440,7 +3440,7 @@ dds::utils::TypePropagation RTPSParticipantImpl::type_propagation() const return dds::utils::to_type_propagation(m_att.properties); } -RTPSParticipantAttributes RTPSParticipantImpl::get_attributes() const +const RTPSParticipantAttributes& RTPSParticipantImpl::get_attributes() const { std::lock_guard _(mutex_); return m_att; diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index d4e538b1c86..2c6fbec7e8a 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -893,7 +893,7 @@ class RTPSParticipantImpl public: - RTPSParticipantAttributes get_attributes() const; + const RTPSParticipantAttributes& get_attributes() const; /** * Create a Writer in this RTPSParticipant. From a6415e61d4e329ca1e3072b898f143b493ec103b Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Wed, 12 Nov 2025 12:32:26 +0100 Subject: [PATCH 05/26] Refs #23923: Avoid calling get_attributes in SecurityManager constructor Signed-off-by: Juan Lopez Fernandez --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 2 +- src/cpp/rtps/security/SecurityManager.cpp | 15 ++++++++------- src/cpp/rtps/security/SecurityManager.h | 1 + test/unittest/rtps/security/SecurityTests.hpp | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 47475e91fa6..125c5d3c630 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -291,7 +291,7 @@ RTPSParticipantImpl::RTPSParticipantImpl( , internal_metatraffic_locators_(false) , internal_default_locators_(false) #if HAVE_SECURITY - , m_security_manager(this, *this) + , m_security_manager(this, PParam, *this) #endif // if HAVE_SECURITY , mp_participantListener(plisten) , mp_userParticipant(par) diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 1b2da629632..70cb4163440 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -88,6 +88,7 @@ static CacheChange_t* create_change_for_message( SecurityManager::SecurityManager( RTPSParticipantImpl* participant, + const RTPSParticipantAttributes& pattr, ISecurityPluginFactory& plugin_factory) : participant_stateless_message_listener_(*this) , participant_volatile_message_secure_listener_(*this) @@ -97,14 +98,14 @@ SecurityManager::SecurityManager( , auth_last_sequence_number_(1) , crypto_last_sequence_number_(1) , temp_reader_proxies_({ - participant->get_attributes().allocation.locators.max_unicast_locators, - participant->get_attributes().allocation.locators.max_multicast_locators, - participant->get_attributes().allocation.data_limits, - participant->get_attributes().allocation.content_filter}) + pattr.allocation.locators.max_unicast_locators, + pattr.allocation.locators.max_multicast_locators, + pattr.allocation.data_limits, + pattr.allocation.content_filter}) , temp_writer_proxies_({ - participant->get_attributes().allocation.locators.max_unicast_locators, - participant->get_attributes().allocation.locators.max_multicast_locators, - participant->get_attributes().allocation.data_limits}) + pattr.allocation.locators.max_unicast_locators, + pattr.allocation.locators.max_multicast_locators, + pattr.allocation.data_limits}) { assert(participant != nullptr); } diff --git a/src/cpp/rtps/security/SecurityManager.h b/src/cpp/rtps/security/SecurityManager.h index 4978a5cfebb..1d8395ebc4c 100644 --- a/src/cpp/rtps/security/SecurityManager.h +++ b/src/cpp/rtps/security/SecurityManager.h @@ -82,6 +82,7 @@ class SecurityManager : private WriterListener */ SecurityManager( RTPSParticipantImpl* participant, + const RTPSParticipantAttributes& pattr, ISecurityPluginFactory& plugin_factory); // @brief Destructor diff --git a/test/unittest/rtps/security/SecurityTests.hpp b/test/unittest/rtps/security/SecurityTests.hpp index 7985f3e0fe4..5b94e09953a 100644 --- a/test/unittest/rtps/security/SecurityTests.hpp +++ b/test/unittest/rtps/security/SecurityTests.hpp @@ -157,7 +157,7 @@ class SecurityTest : public ::testing::Test , stateless_reader_(nullptr) , volatile_writer_(nullptr) , volatile_reader_(nullptr) - , manager_(&participant_, plugin_factory_) + , manager_(&participant_, g_security_default_values_.pattr, plugin_factory_) , participant_data_(c_default_RTPSParticipantAllocationAttributes) , default_cdr_message(RTPSMESSAGE_DEFAULT_SIZE) { From e1c7e04f103e68aac967ec2d1ebc225097f3fb19 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Wed, 12 Nov 2025 13:18:33 +0100 Subject: [PATCH 06/26] Refs #23923: Copy attributes Signed-off-by: Juan Lopez Fernandez --- include/fastdds/rtps/participant/RTPSParticipant.hpp | 2 +- src/cpp/rtps/builtin/BuiltinProtocols.cpp | 2 +- src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp | 2 +- src/cpp/rtps/builtin/discovery/participant/PDP.cpp | 6 +++--- .../rtps/builtin/discovery/participant/PDPListener.cpp | 2 +- src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp | 2 +- .../builtin/discovery/participant/PDPServerListener.cpp | 2 +- src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp | 4 ++-- src/cpp/rtps/builtin/liveliness/WLP.cpp | 4 ++-- src/cpp/rtps/participant/RTPSParticipant.cpp | 2 +- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 2 +- src/cpp/rtps/participant/RTPSParticipantImpl.hpp | 2 +- src/cpp/rtps/reader/BaseReader.cpp | 2 +- src/cpp/rtps/reader/StatefulReader.cpp | 4 ++-- src/cpp/rtps/security/SecurityManager.cpp | 8 ++++---- src/cpp/rtps/writer/BaseWriter.cpp | 2 +- src/cpp/rtps/writer/StatefulWriter.cpp | 4 ++-- src/cpp/rtps/writer/StatelessWriter.cpp | 4 ++-- 18 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index d2da077d3ce..90bfbb3c169 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -236,7 +236,7 @@ class FASTDDS_EXPORTED_API RTPSParticipant * Get a reference of the current state of the RTPSParticipantParameters. * @return RTPSParticipantAttributes reference. */ - const RTPSParticipantAttributes& get_attributes() const; + RTPSParticipantAttributes get_attributes() const; /** * Retrieves the maximum message size. diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index dace9dd81ad..0b2b1a43b99 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -86,7 +86,7 @@ bool BuiltinProtocols::initBuiltinProtocols( filter_server_remote_locators(p_part->network_factory()); - const RTPSParticipantAllocationAttributes& allocation = p_part->get_attributes().allocation; + RTPSParticipantAllocationAttributes allocation = p_part->get_attributes().allocation; // PDP switch (m_att.discovery_config.discoveryProtocol) diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp index 443f1478772..46912214e0d 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp @@ -137,7 +137,7 @@ bool EDPStatic::initEDP( } // Check there is a Participant's property changing the exchange format. - auto& properties = mp_RTPSParticipant->get_attributes().properties.properties(); + auto properties = mp_RTPSParticipant->get_attributes().properties.properties(); for (auto& property : properties) { if (0 == property.name().compare(exchange_format_property_name)) diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 6b965f7e38f..930f065d931 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -1588,7 +1588,7 @@ static void set_builtin_endpoint_locators( const PDP* pdp, const BuiltinProtocols* builtin) { - const RTPSParticipantAttributes& pattr = pdp->getRTPSParticipant()->get_attributes(); + RTPSParticipantAttributes pattr = pdp->getRTPSParticipant()->get_attributes(); auto part_data = pdp->getLocalParticipantProxyData(); if (nullptr == part_data) @@ -1622,7 +1622,7 @@ ReaderAttributes PDP::create_builtin_reader_attributes() { ReaderAttributes attributes; - const RTPSParticipantAttributes& pattr = getRTPSParticipant()->get_attributes(); + RTPSParticipantAttributes pattr = getRTPSParticipant()->get_attributes(); set_builtin_matched_allocation(attributes.matched_writers_allocation, pattr); // Builtin endpoints are always reliable, transient local, keyed topics @@ -1646,7 +1646,7 @@ WriterAttributes PDP::create_builtin_writer_attributes() { WriterAttributes attributes; - const RTPSParticipantAttributes& pattr = getRTPSParticipant()->get_attributes(); + RTPSParticipantAttributes pattr = getRTPSParticipant()->get_attributes(); set_builtin_matched_allocation(attributes.matched_readers_allocation, pattr); // Builtin endpoints are always reliable, transient local, keyed topics diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index 01080ebdbd9..844b6b419af 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -123,7 +123,7 @@ void PDPListener::on_new_cache_change_added( } // Filter locators - const auto& pattr = parent_pdp_->getRTPSParticipant()->get_attributes(); + auto pattr = parent_pdp_->getRTPSParticipant()->get_attributes(); fastdds::rtps::network::external_locators::filter_remote_locators(temp_participant_data_, pattr.builtin.metatraffic_external_unicast_locators, pattr.default_external_unicast_locators, pattr.ignore_non_matching_locators); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index 383c096b0da..2dbabdb4d2b 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -119,7 +119,7 @@ bool PDPServer::init( getRTPSParticipant()->enableReader(edp->publications_reader_.first); // Initialize server dedicated thread. - const RTPSParticipantAttributes& part_attr = getRTPSParticipant()->get_attributes(); + RTPSParticipantAttributes part_attr = getRTPSParticipant()->get_attributes(); uint32_t id_for_thread = static_cast(part_attr.participantID); const fastdds::rtps::ThreadSettings& thr_config = part_attr.discovery_server_thread; resource_event_thread_.init_thread(thr_config, "dds.ds_ev.%u", id_for_thread); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp index d8d885e10d2..14edb150371 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp @@ -155,7 +155,7 @@ void PDPServerListener::on_new_cache_change_added( EPROSIMA_LOG_INFO(RTPS_PDP_LISTENER, "Participant type " << participant_type_str); bool is_client = ret.second; - const auto& pattr = pdp_server()->getRTPSParticipant()->get_attributes(); + auto pattr = pdp_server()->getRTPSParticipant()->get_attributes(); fastdds::rtps::network::external_locators::filter_remote_locators(participant_data, pattr.builtin.metatraffic_external_unicast_locators, pattr.default_external_unicast_locators, pattr.ignore_non_matching_locators); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp index 9f7b96104ab..89ae97142e9 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp @@ -348,7 +348,7 @@ bool PDPSimple::createPDPEndpoints() bool PDPSimple::create_dcps_participant_endpoints() { - const RTPSParticipantAttributes& pattr = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes pattr = mp_RTPSParticipant->get_attributes(); const RTPSParticipantAllocationAttributes& allocation = pattr.allocation; const BuiltinAttributes& builtin_att = mp_builtin->m_att; auto endpoints = dynamic_cast(builtin_endpoints_.get()); @@ -478,7 +478,7 @@ bool PDPSimple::create_dcps_participant_endpoints() #if HAVE_SECURITY bool PDPSimple::create_dcps_participant_secure_endpoints() { - const RTPSParticipantAttributes& pattr = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes pattr = mp_RTPSParticipant->get_attributes(); const RTPSParticipantAllocationAttributes& allocation = pattr.allocation; const BuiltinAttributes& builtin_att = mp_builtin->m_att; auto endpoints = dynamic_cast(builtin_endpoints_.get()); diff --git a/src/cpp/rtps/builtin/liveliness/WLP.cpp b/src/cpp/rtps/builtin/liveliness/WLP.cpp index f420cb8a9c5..c19e59ccc92 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -236,7 +236,7 @@ bool WLP::initWL( bool WLP::createEndpoints() { - const RTPSParticipantAttributes& pattr = mp_participant->get_attributes(); + RTPSParticipantAttributes pattr = mp_participant->get_attributes(); const ResourceLimitedContainerConfig& participants_allocation = pattr.allocation.participants; // Built-in writer history @@ -320,7 +320,7 @@ bool WLP::createEndpoints() bool WLP::createSecureEndpoints() { - const RTPSParticipantAttributes& pattr = mp_participant->get_attributes(); + RTPSParticipantAttributes pattr = mp_participant->get_attributes(); const ResourceLimitedContainerConfig& participants_allocation = pattr.allocation.participants; //CREATE WRITER diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index 561c0b77e34..de1ccf40104 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -135,7 +135,7 @@ std::vector RTPSParticipant::getParticipantNames() const return mp_impl->getParticipantNames(); } -const RTPSParticipantAttributes& RTPSParticipant::get_attributes() const +RTPSParticipantAttributes RTPSParticipant::get_attributes() const { return mp_impl->get_attributes(); } diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 125c5d3c630..0405fca57d3 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -3440,7 +3440,7 @@ dds::utils::TypePropagation RTPSParticipantImpl::type_propagation() const return dds::utils::to_type_propagation(m_att.properties); } -const RTPSParticipantAttributes& RTPSParticipantImpl::get_attributes() const +RTPSParticipantAttributes RTPSParticipantImpl::get_attributes() const { std::lock_guard _(mutex_); return m_att; diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index 2c6fbec7e8a..d4e538b1c86 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -893,7 +893,7 @@ class RTPSParticipantImpl public: - const RTPSParticipantAttributes& get_attributes() const; + RTPSParticipantAttributes get_attributes() const; /** * Create a Writer in this RTPSParticipant. diff --git a/src/cpp/rtps/reader/BaseReader.cpp b/src/cpp/rtps/reader/BaseReader.cpp index f3d8029c59d..aeef35f6aff 100644 --- a/src/cpp/rtps/reader/BaseReader.cpp +++ b/src/cpp/rtps/reader/BaseReader.cpp @@ -133,7 +133,7 @@ BaseReader::~BaseReader() bool BaseReader::matched_writer_add( const PublicationBuiltinTopicData& info) { - const auto& alloc = mp_RTPSParticipant->get_attributes().allocation; + auto alloc = mp_RTPSParticipant->get_attributes().allocation; WriterProxyData wdata(alloc.data_limits, info); return matched_writer_add_edp(wdata); diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 34265c2a0ca..4cec0e65a5a 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -190,7 +190,7 @@ void StatefulReader::init( RTPSParticipantImpl* pimpl, const ReaderAttributes& att) { - const RTPSParticipantAttributes& part_att = pimpl->get_attributes(); + RTPSParticipantAttributes part_att = pimpl->get_attributes(); 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_)); @@ -264,7 +264,7 @@ bool StatefulReader::matched_writer_add_edp( size_t max_readers = matched_writers_pool_.max_size(); if (getMatchedWritersSize() + matched_writers_pool_.size() < max_readers) { - const RTPSParticipantAttributes& part_att = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes part_att = mp_RTPSParticipant->get_attributes(); wp = new WriterProxy(this, part_att.allocation.locators, proxy_changes_config_); } else diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 70cb4163440..cacb9df17f5 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -1124,7 +1124,7 @@ bool SecurityManager::create_participant_stateless_message_writer() participant_stateless_message_writer_hattr_, participant_stateless_message_pool_); - const RTPSParticipantAttributes& pattr = participant_->get_attributes(); + RTPSParticipantAttributes pattr = participant_->get_attributes(); WriterAttributes watt; watt.endpoint.external_unicast_locators = pattr.builtin.metatraffic_external_unicast_locators; @@ -1173,7 +1173,7 @@ bool SecurityManager::create_participant_stateless_message_reader() { participant_stateless_message_reader_history_ = new ReaderHistory(participant_stateless_message_reader_hattr_); - const RTPSParticipantAttributes& pattr = participant_->get_attributes(); + RTPSParticipantAttributes pattr = participant_->get_attributes(); ReaderAttributes ratt; ratt.endpoint.topicKind = NO_KEY; @@ -1272,7 +1272,7 @@ bool SecurityManager::create_participant_volatile_message_secure_writer() participant_volatile_message_secure_writer_history_ = new WriterHistory(participant_volatile_message_secure_hattr_, participant_volatile_message_secure_pool_); - const RTPSParticipantAttributes& pattr = participant_->get_attributes(); + RTPSParticipantAttributes pattr = participant_->get_attributes(); WriterAttributes watt; watt.endpoint.endpointKind = WRITER; @@ -1325,7 +1325,7 @@ bool SecurityManager::create_participant_volatile_message_secure_reader() participant_volatile_message_secure_reader_history_ = new ReaderHistory(participant_volatile_message_secure_hattr_); - const RTPSParticipantAttributes& pattr = participant_->get_attributes(); + RTPSParticipantAttributes pattr = participant_->get_attributes(); ReaderAttributes ratt; ratt.endpoint.topicKind = NO_KEY; diff --git a/src/cpp/rtps/writer/BaseWriter.cpp b/src/cpp/rtps/writer/BaseWriter.cpp index b1ec8c1b2b9..9212fe30c7e 100644 --- a/src/cpp/rtps/writer/BaseWriter.cpp +++ b/src/cpp/rtps/writer/BaseWriter.cpp @@ -117,7 +117,7 @@ BaseWriter::~BaseWriter() bool BaseWriter::matched_reader_add( const SubscriptionBuiltinTopicData& rqos) { - const auto& alloc = mp_RTPSParticipant->get_attributes().allocation; + auto alloc = mp_RTPSParticipant->get_attributes().allocation; ReaderProxyData rdata(alloc.data_limits, rqos); return matched_reader_add_edp(rdata); diff --git a/src/cpp/rtps/writer/StatefulWriter.cpp b/src/cpp/rtps/writer/StatefulWriter.cpp index 84b292e2ffb..0ede85b7f5b 100644 --- a/src/cpp/rtps/writer/StatefulWriter.cpp +++ b/src/cpp/rtps/writer/StatefulWriter.cpp @@ -210,7 +210,7 @@ void StatefulWriter::init( RTPSParticipantImpl* pimpl, const WriterAttributes& att) { - const RTPSParticipantAttributes& part_att = pimpl->get_attributes(); + RTPSParticipantAttributes part_att = pimpl->get_attributes(); auto push_mode = PropertyPolicyHelper::find_property(att.endpoint.properties, "fastdds.push_mode"); push_mode_ = !((nullptr != push_mode) && ("false" == *push_mode)); @@ -1038,7 +1038,7 @@ bool StatefulWriter::matched_reader_add_edp( size_t max_readers = matched_readers_pool_.max_size(); if (get_matched_readers_size() + matched_readers_pool_.size() < max_readers) { - const RTPSParticipantAttributes& part_att = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes part_att = mp_RTPSParticipant->get_attributes(); rp = new ReaderProxy(times_, part_att.allocation.locators, this, stateful_writer_listener_); } else diff --git a/src/cpp/rtps/writer/StatelessWriter.cpp b/src/cpp/rtps/writer/StatelessWriter.cpp index c86014c09e6..10e736b0dc6 100644 --- a/src/cpp/rtps/writer/StatelessWriter.cpp +++ b/src/cpp/rtps/writer/StatelessWriter.cpp @@ -170,7 +170,7 @@ void StatelessWriter::init( { get_builtin_guid(); - const RemoteLocatorsAllocationAttributes& loc_alloc = + RemoteLocatorsAllocationAttributes loc_alloc = participant->get_attributes().allocation.locators; for (size_t i = 0; i < attributes.matched_readers_allocation.initial; ++i) @@ -511,7 +511,7 @@ bool StatelessWriter::matched_reader_add_edp( size_t max_readers = matched_readers_pool_.max_size(); if (get_matched_readers_size() + matched_readers_pool_.size() < max_readers) { - const RemoteLocatorsAllocationAttributes& loc_alloc = + RemoteLocatorsAllocationAttributes loc_alloc = mp_RTPSParticipant->get_attributes().allocation.locators; new_reader.reset(new ReaderLocator( From 758e2293cd06e82590db5b84cf9cc5f1a3e316ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Thu, 16 Apr 2026 11:51:14 +0200 Subject: [PATCH 07/26] Refs #23923: Protect missing cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../rtps/participant/RTPSParticipantImpl.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 0405fca57d3..65c69165cc8 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -2889,8 +2889,8 @@ void RTPSParticipantImpl::environment_file_has_changed() patt = m_att; } // Only if it is a server/backup or a client override - if (DiscoveryProtocol::SERVER == m_att.builtin.discovery_config.discoveryProtocol || - DiscoveryProtocol::BACKUP == m_att.builtin.discovery_config.discoveryProtocol || + if (DiscoveryProtocol::SERVER == patt.builtin.discovery_config.discoveryProtocol || + DiscoveryProtocol::BACKUP == patt.builtin.discovery_config.discoveryProtocol || client_override_) { if (load_environment_server_info(patt.builtin.discovery_config.m_DiscoveryServers)) @@ -2911,8 +2911,8 @@ void RTPSParticipantImpl::get_default_metatraffic_locators( { uint32_t metatraffic_multicast_port = att.port.getMulticastPort(domain_id_); - if (m_att.builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::CLIENT && - m_att.builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::SUPER_CLIENT) + if (att.builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::CLIENT && + att.builtin.discovery_config.discoveryProtocol != DiscoveryProtocol::SUPER_CLIENT) { m_network_Factory.getDefaultMetatrafficMulticastLocators(att.builtin.metatrafficMulticastLocatorList, metatraffic_multicast_port); @@ -3421,12 +3421,16 @@ void RTPSParticipantImpl::update_removed_participant( { if (!remote_participant_locators.empty()) { - std::lock_guard guard(m_send_resources_mutex_); - LocatorList_t initial_peers_and_ds = m_att.builtin.discovery_config.m_DiscoveryServers; - for (const Locator_t& locator : m_att.builtin.initialPeersList) + LocatorList_t initial_peers_and_ds; { - initial_peers_and_ds.push_back(locator); + std::lock_guard _(mutex_); + initial_peers_and_ds = m_att.builtin.discovery_config.m_DiscoveryServers; + for (const Locator_t& locator : m_att.builtin.initialPeersList) + { + initial_peers_and_ds.push_back(locator); + } } + std::lock_guard guard(m_send_resources_mutex_); m_network_Factory.remove_participant_associated_send_resources( send_resource_list_, remote_participant_locators, From 36e62dc86b0c14d62e65d30d12d39ef28fcdd8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Thu, 16 Apr 2026 12:39:54 +0200 Subject: [PATCH 08/26] Refs #23923: Create new method to avoid API break MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../rtps/participant/RTPSParticipant.hpp | 2 +- .../type_lookup_service/TypeLookupManager.cpp | 2 +- .../TypeLookupReplyListener.cpp | 2 +- .../TypeLookupRequestListener.cpp | 2 +- src/cpp/rtps/builtin/BuiltinProtocols.cpp | 2 +- .../builtin/discovery/endpoint/EDPSimple.cpp | 2 +- .../builtin/discovery/endpoint/EDPStatic.cpp | 2 +- .../builtin/discovery/participant/PDP.cpp | 18 ++++++++--------- .../discovery/participant/PDPClient.cpp | 2 +- .../discovery/participant/PDPListener.cpp | 4 ++-- .../discovery/participant/PDPServer.cpp | 6 +++--- .../participant/PDPServerListener.cpp | 2 +- .../discovery/participant/PDPSimple.cpp | 8 ++++---- .../participant/simple/PDPStatelessWriter.cpp | 2 +- src/cpp/rtps/builtin/liveliness/WLP.cpp | 20 +++++++++---------- .../flowcontrol/FlowControllerFactory.cpp | 2 +- .../rtps/flowcontrol/FlowControllerImpl.hpp | 2 +- src/cpp/rtps/participant/RTPSParticipant.cpp | 2 +- .../rtps/participant/RTPSParticipantImpl.cpp | 7 ++++++- .../rtps/participant/RTPSParticipantImpl.hpp | 4 +++- src/cpp/rtps/reader/BaseReader.cpp | 2 +- src/cpp/rtps/reader/StatefulReader.cpp | 4 ++-- src/cpp/rtps/security/SecurityManager.cpp | 10 +++++----- src/cpp/rtps/writer/BaseWriter.cpp | 2 +- src/cpp/rtps/writer/StatefulWriter.cpp | 4 ++-- src/cpp/rtps/writer/StatelessWriter.cpp | 4 ++-- 26 files changed, 63 insertions(+), 56 deletions(-) diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 90bfbb3c169..d2da077d3ce 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -236,7 +236,7 @@ class FASTDDS_EXPORTED_API RTPSParticipant * Get a reference of the current state of the RTPSParticipantParameters. * @return RTPSParticipantAttributes reference. */ - RTPSParticipantAttributes get_attributes() const; + const RTPSParticipantAttributes& get_attributes() const; /** * Retrieves the maximum message size. diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 141bce87193..f16f881bfe6 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -127,7 +127,7 @@ bool TypeLookupManager::init( { participant_ = protocols->mp_participantImpl; builtin_protocols_ = protocols; - auto locators_allocations = participant_->get_attributes().allocation.locators; + auto locators_allocations = participant_->copy_attributes().allocation.locators; local_instance_name_ = get_instance_name(participant_->getGuid()); diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 30afadab5dd..20e66899d7d 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -59,7 +59,7 @@ void TypeLookupReplyListener::start_reply_processor_thread() }; // Create and start the processing thread replies_processor_thread = eprosima::create_thread(thread_func, - typelookup_manager_->participant_->get_attributes().typelookup_service_thread, + typelookup_manager_->participant_->copy_attributes().typelookup_service_thread, "dds.tls.replies.%u"); } } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index 7254f396f31..b0ca3fca658 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -112,7 +112,7 @@ void TypeLookupRequestListener::start_request_processor_thread() }; // Create and start the processing thread request_processor_thread = eprosima::create_thread(thread_func, - typelookup_manager_->participant_->get_attributes().typelookup_service_thread, + typelookup_manager_->participant_->copy_attributes().typelookup_service_thread, "dds.tls.requests.%u"); } } diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index 0b2b1a43b99..935fc92480b 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -86,7 +86,7 @@ bool BuiltinProtocols::initBuiltinProtocols( filter_server_remote_locators(p_part->network_factory()); - RTPSParticipantAllocationAttributes allocation = p_part->get_attributes().allocation; + RTPSParticipantAllocationAttributes allocation = p_part->copy_attributes().allocation; // PDP switch (m_att.discovery_config.discoveryProtocol) diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index e87f8b8de3b..0d7dfc1498b 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -755,7 +755,7 @@ void EDPSimple::assignRemoteEndpoints( const NetworkFactory& network = mp_RTPSParticipant->network_factory(); uint32_t endp = pdata.m_available_builtin_endpoints; uint32_t auxendp; - bool use_multicast_locators = !mp_PDP->getRTPSParticipant()->get_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = !mp_PDP->getRTPSParticipant()->copy_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); auto temp_reader_proxy_data = get_temporary_reader_proxies_pool().get(); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp index 46912214e0d..7dd6ee9c661 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp @@ -137,7 +137,7 @@ bool EDPStatic::initEDP( } // Check there is a Participant's property changing the exchange format. - auto properties = mp_RTPSParticipant->get_attributes().properties.properties(); + auto properties = mp_RTPSParticipant->copy_attributes().properties.properties(); for (auto& property : properties) { if (0 == property.name().compare(exchange_format_property_name)) diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 930f065d931..b24a69b6287 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -179,7 +179,7 @@ ParticipantProxyData* PDP::add_participant_proxy_data( { // Pool is empty but limit has not been reached, so we create a new entry. ++participant_proxies_number_; - ret_val = new ParticipantProxyData(mp_RTPSParticipant->get_attributes().allocation); + ret_val = new ParticipantProxyData(mp_RTPSParticipant->copy_attributes().allocation); if (participant_guid != mp_RTPSParticipant->getGuid()) { ret_val->lease_duration_event = new TimedEvent(mp_RTPSParticipant->getEventResource(), @@ -306,7 +306,7 @@ std::string PDP::check_participant_type( void PDP::initializeParticipantProxyData( ParticipantProxyData* participant_data) { - RTPSParticipantAttributes attributes = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes attributes = mp_RTPSParticipant->copy_attributes(); bool announce_locators = !mp_RTPSParticipant->is_intraprocess_only(); from_guid_prefix_to_topic_key(participant_data->guid.guidPrefix, participant_data->key.value); @@ -487,7 +487,7 @@ bool PDP::initPDP( { EPROSIMA_LOG_INFO(RTPS_PDP, "Beginning"); mp_RTPSParticipant = part; - m_discovery = mp_RTPSParticipant->get_attributes().builtin; + m_discovery = mp_RTPSParticipant->copy_attributes().builtin; initial_announcements_ = m_discovery.discovery_config.initial_announcements; //CREATE ENDPOINTS if (!createPDPEndpoints()) @@ -967,7 +967,7 @@ ReaderProxyData* PDP::addReaderProxyData( // Pool is empty but limit has not been reached, so we create a new entry. ++reader_proxies_number_; - auto allocations = mp_RTPSParticipant->get_attributes().allocation; + auto allocations = mp_RTPSParticipant->copy_attributes().allocation; ret_val = new ReaderProxyData( allocations.locators.max_unicast_locators, @@ -1055,7 +1055,7 @@ WriterProxyData* PDP::addWriterProxyData( // Pool is empty but limit has not been reached, so we create a new entry. ++writer_proxies_number_; - auto allocations = mp_RTPSParticipant->get_attributes().allocation; + auto allocations = mp_RTPSParticipant->copy_attributes().allocation; ret_val = new WriterProxyData( allocations.locators.max_unicast_locators, @@ -1518,7 +1518,7 @@ void PDP::resend_ininitial_announcements() void PDP::set_external_participant_properties_( ParticipantProxyData* participant_data) { - auto part_attributes = mp_RTPSParticipant->get_attributes(); + auto part_attributes = mp_RTPSParticipant->copy_attributes(); // For each property add it if it should be sent (it is propagated) for (auto const& property : part_attributes.properties.properties()) @@ -1588,7 +1588,7 @@ static void set_builtin_endpoint_locators( const PDP* pdp, const BuiltinProtocols* builtin) { - RTPSParticipantAttributes pattr = pdp->getRTPSParticipant()->get_attributes(); + RTPSParticipantAttributes pattr = pdp->getRTPSParticipant()->copy_attributes(); auto part_data = pdp->getLocalParticipantProxyData(); if (nullptr == part_data) @@ -1622,7 +1622,7 @@ ReaderAttributes PDP::create_builtin_reader_attributes() { ReaderAttributes attributes; - RTPSParticipantAttributes pattr = getRTPSParticipant()->get_attributes(); + RTPSParticipantAttributes pattr = getRTPSParticipant()->copy_attributes(); set_builtin_matched_allocation(attributes.matched_writers_allocation, pattr); // Builtin endpoints are always reliable, transient local, keyed topics @@ -1646,7 +1646,7 @@ WriterAttributes PDP::create_builtin_writer_attributes() { WriterAttributes attributes; - RTPSParticipantAttributes pattr = getRTPSParticipant()->get_attributes(); + RTPSParticipantAttributes pattr = getRTPSParticipant()->copy_attributes(); set_builtin_matched_allocation(attributes.matched_readers_allocation, pattr); // Builtin endpoints are always reliable, transient local, keyed topics diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index d673077c11d..e569381220a 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -104,7 +104,7 @@ void PDPClient::initializeParticipantProxyData( { PDP::initializeParticipantProxyData(participant_data); // TODO: Remember that the PDP version USES security - auto discovery_config = getRTPSParticipant()->get_attributes().builtin.discovery_config; + auto discovery_config = getRTPSParticipant()->copy_attributes().builtin.discovery_config; if ((DiscoveryProtocol::CLIENT != discovery_config.discoveryProtocol) && (DiscoveryProtocol::SUPER_CLIENT != discovery_config.discoveryProtocol)) diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index 844b6b419af..b77224eb1fc 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -49,7 +49,7 @@ namespace rtps { PDPListener::PDPListener( PDP* parent) : parent_pdp_(parent) - , temp_participant_data_(parent->getRTPSParticipant()->get_attributes().allocation) + , temp_participant_data_(parent->getRTPSParticipant()->copy_attributes().allocation) { } @@ -123,7 +123,7 @@ void PDPListener::on_new_cache_change_added( } // Filter locators - auto pattr = parent_pdp_->getRTPSParticipant()->get_attributes(); + auto pattr = parent_pdp_->getRTPSParticipant()->copy_attributes(); fastdds::rtps::network::external_locators::filter_remote_locators(temp_participant_data_, pattr.builtin.metatraffic_external_unicast_locators, pattr.default_external_unicast_locators, pattr.ignore_non_matching_locators); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index 2dbabdb4d2b..67581935571 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -119,7 +119,7 @@ bool PDPServer::init( getRTPSParticipant()->enableReader(edp->publications_reader_.first); // Initialize server dedicated thread. - RTPSParticipantAttributes part_attr = getRTPSParticipant()->get_attributes(); + RTPSParticipantAttributes part_attr = getRTPSParticipant()->copy_attributes(); uint32_t id_for_thread = static_cast(part_attr.participantID); const fastdds::rtps::ThreadSettings& thr_config = part_attr.discovery_server_thread; resource_event_thread_.init_thread(thr_config, "dds.ds_ev.%u", id_for_thread); @@ -360,7 +360,7 @@ void PDPServer::initializeParticipantProxyData( { PDP::initializeParticipantProxyData(participant_data); - auto discovery_config = getRTPSParticipant()->get_attributes().builtin.discovery_config; + auto discovery_config = getRTPSParticipant()->copy_attributes().builtin.discovery_config; if (discovery_config.discoveryProtocol != DiscoveryProtocol::SERVER && discovery_config.discoveryProtocol != DiscoveryProtocol::BACKUP) @@ -395,7 +395,7 @@ void PDPServer::match_reliable_pdp_endpoints( auto endpoints = static_cast(builtin_endpoints_.get()); const NetworkFactory& network = mp_RTPSParticipant->network_factory(); uint32_t endp = pdata.m_available_builtin_endpoints; - bool use_multicast_locators = !mp_RTPSParticipant->get_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = !mp_RTPSParticipant->copy_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); // Only SERVER and CLIENT participants will be received. All builtin must be there diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp index 14edb150371..0424144fff8 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp @@ -155,7 +155,7 @@ void PDPServerListener::on_new_cache_change_added( EPROSIMA_LOG_INFO(RTPS_PDP_LISTENER, "Participant type " << participant_type_str); bool is_client = ret.second; - auto pattr = pdp_server()->getRTPSParticipant()->get_attributes(); + auto pattr = pdp_server()->getRTPSParticipant()->copy_attributes(); fastdds::rtps::network::external_locators::filter_remote_locators(participant_data, pattr.builtin.metatraffic_external_unicast_locators, pattr.default_external_unicast_locators, pattr.ignore_non_matching_locators); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp index 89ae97142e9..86699d2d98f 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp @@ -109,7 +109,7 @@ void PDPSimple::initializeParticipantProxyData( { PDP::initializeParticipantProxyData(participant_data); - auto discovery_config = getRTPSParticipant()->get_attributes().builtin.discovery_config; + auto discovery_config = getRTPSParticipant()->copy_attributes().builtin.discovery_config; if (discovery_config.use_SIMPLE_EndpointDiscoveryProtocol) { @@ -348,7 +348,7 @@ bool PDPSimple::createPDPEndpoints() bool PDPSimple::create_dcps_participant_endpoints() { - RTPSParticipantAttributes pattr = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes pattr = mp_RTPSParticipant->copy_attributes(); const RTPSParticipantAllocationAttributes& allocation = pattr.allocation; const BuiltinAttributes& builtin_att = mp_builtin->m_att; auto endpoints = dynamic_cast(builtin_endpoints_.get()); @@ -478,7 +478,7 @@ bool PDPSimple::create_dcps_participant_endpoints() #if HAVE_SECURITY bool PDPSimple::create_dcps_participant_secure_endpoints() { - RTPSParticipantAttributes pattr = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes pattr = mp_RTPSParticipant->copy_attributes(); const RTPSParticipantAllocationAttributes& allocation = pattr.allocation; const BuiltinAttributes& builtin_att = mp_builtin->m_att; auto endpoints = dynamic_cast(builtin_endpoints_.get()); @@ -664,7 +664,7 @@ void PDPSimple::match_pdp_remote_endpoints( auto endpoints = static_cast(builtin_endpoints_.get()); const NetworkFactory& network = mp_RTPSParticipant->network_factory(); - bool use_multicast_locators = !mp_RTPSParticipant->get_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = !mp_RTPSParticipant->copy_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); const uint32_t endp = pdata.m_available_builtin_endpoints; diff --git a/src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp b/src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp index 4d1d4647ce8..d9a92ac78d6 100644 --- a/src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp @@ -48,7 +48,7 @@ PDPStatelessWriter::PDPStatelessWriter( WriterHistory* history, WriterListener* listener) : StatelessWriter(participant, guid, attributes, flow_controller, history, listener) - , interested_readers_(participant->get_attributes().allocation.participants) + , interested_readers_(participant->copy_attributes().allocation.participants) { } diff --git a/src/cpp/rtps/builtin/liveliness/WLP.cpp b/src/cpp/rtps/builtin/liveliness/WLP.cpp index c19e59ccc92..0a3ae203710 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -108,14 +108,14 @@ WLP::WLP( , mp_builtinReaderSecureHistory(nullptr) #endif // if HAVE_SECURITY , temp_reader_proxy_data_( - p->mp_participantImpl->get_attributes().allocation.locators.max_unicast_locators, - p->mp_participantImpl->get_attributes().allocation.locators.max_multicast_locators, - p->mp_participantImpl->get_attributes().allocation.data_limits, - p->mp_participantImpl->get_attributes().allocation.content_filter) + p->mp_participantImpl->copy_attributes().allocation.locators.max_unicast_locators, + p->mp_participantImpl->copy_attributes().allocation.locators.max_multicast_locators, + p->mp_participantImpl->copy_attributes().allocation.data_limits, + p->mp_participantImpl->copy_attributes().allocation.content_filter) , temp_writer_proxy_data_( - p->mp_participantImpl->get_attributes().allocation.locators.max_unicast_locators, - p->mp_participantImpl->get_attributes().allocation.locators.max_multicast_locators, - p->mp_participantImpl->get_attributes().allocation.data_limits) + p->mp_participantImpl->copy_attributes().allocation.locators.max_unicast_locators, + p->mp_participantImpl->copy_attributes().allocation.locators.max_multicast_locators, + p->mp_participantImpl->copy_attributes().allocation.data_limits) { GUID_t tmp_guid = p->mp_participantImpl->getGuid(); tmp_guid.entityId = 0; @@ -236,7 +236,7 @@ bool WLP::initWL( bool WLP::createEndpoints() { - RTPSParticipantAttributes pattr = mp_participant->get_attributes(); + RTPSParticipantAttributes pattr = mp_participant->copy_attributes(); const ResourceLimitedContainerConfig& participants_allocation = pattr.allocation.participants; // Built-in writer history @@ -320,7 +320,7 @@ bool WLP::createEndpoints() bool WLP::createSecureEndpoints() { - RTPSParticipantAttributes pattr = mp_participant->get_attributes(); + RTPSParticipantAttributes pattr = mp_participant->copy_attributes(); const ResourceLimitedContainerConfig& participants_allocation = pattr.allocation.participants; //CREATE WRITER @@ -454,7 +454,7 @@ bool WLP::assignRemoteEndpoints( const NetworkFactory& network = mp_participant->network_factory(); uint32_t endp = pdata.m_available_builtin_endpoints; uint32_t auxendp = endp; - bool use_multicast_locators = !mp_participant->get_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = !mp_participant->copy_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); std::lock_guard data_guard(temp_data_lock_); diff --git a/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp b/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp index d195bc5b44b..ecaffc72b2c 100644 --- a/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp +++ b/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp @@ -15,7 +15,7 @@ void FlowControllerFactory::init( const ThreadSettings& sender_thread_settings = (nullptr == participant_) ? ThreadSettings{} - : participant_->get_attributes().builtin_controllers_sender_thread; + : participant_->copy_attributes().builtin_controllers_sender_thread; // PureSyncFlowController -> used by volatile besteffort writers. flow_controllers_.insert(decltype(flow_controllers_)::value_type( diff --git a/src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp b/src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp index 76ce9c21dfd..5f855fc0879 100644 --- a/src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp +++ b/src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp @@ -992,7 +992,7 @@ class FlowControllerImpl : public FlowController { if (nullptr != participant) { - participant_id_ = static_cast(participant->get_attributes().participantID); + participant_id_ = static_cast(participant->copy_attributes().participantID); } uint32_t limitation = get_max_payload(); diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index de1ccf40104..561c0b77e34 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -135,7 +135,7 @@ std::vector RTPSParticipant::getParticipantNames() const return mp_impl->getParticipantNames(); } -RTPSParticipantAttributes RTPSParticipant::get_attributes() const +const RTPSParticipantAttributes& RTPSParticipant::get_attributes() const { return mp_impl->get_attributes(); } diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 65c69165cc8..475bdbe6ec5 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -3444,7 +3444,12 @@ dds::utils::TypePropagation RTPSParticipantImpl::type_propagation() const return dds::utils::to_type_propagation(m_att.properties); } -RTPSParticipantAttributes RTPSParticipantImpl::get_attributes() const +const RTPSParticipantAttributes& RTPSParticipantImpl::get_attributes() const +{ + return m_att; +} + +RTPSParticipantAttributes RTPSParticipantImpl::copy_attributes() const { std::lock_guard _(mutex_); return m_att; diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index d4e538b1c86..c96308c5a49 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -893,7 +893,9 @@ class RTPSParticipantImpl public: - RTPSParticipantAttributes get_attributes() const; + const RTPSParticipantAttributes& get_attributes() const; + + RTPSParticipantAttributes copy_attributes() const; /** * Create a Writer in this RTPSParticipant. diff --git a/src/cpp/rtps/reader/BaseReader.cpp b/src/cpp/rtps/reader/BaseReader.cpp index aeef35f6aff..9a1919a6f6b 100644 --- a/src/cpp/rtps/reader/BaseReader.cpp +++ b/src/cpp/rtps/reader/BaseReader.cpp @@ -133,7 +133,7 @@ BaseReader::~BaseReader() bool BaseReader::matched_writer_add( const PublicationBuiltinTopicData& info) { - auto alloc = mp_RTPSParticipant->get_attributes().allocation; + auto alloc = mp_RTPSParticipant->copy_attributes().allocation; WriterProxyData wdata(alloc.data_limits, info); return matched_writer_add_edp(wdata); diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 4cec0e65a5a..d7365ec39c3 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -190,7 +190,7 @@ void StatefulReader::init( RTPSParticipantImpl* pimpl, const ReaderAttributes& att) { - RTPSParticipantAttributes part_att = pimpl->get_attributes(); + RTPSParticipantAttributes part_att = pimpl->copy_attributes(); 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_)); @@ -264,7 +264,7 @@ bool StatefulReader::matched_writer_add_edp( size_t max_readers = matched_writers_pool_.max_size(); if (getMatchedWritersSize() + matched_writers_pool_.size() < max_readers) { - RTPSParticipantAttributes part_att = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes part_att = mp_RTPSParticipant->copy_attributes(); wp = new WriterProxy(this, part_att.allocation.locators, proxy_changes_config_); } else diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index cacb9df17f5..7d172f2ac59 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -123,7 +123,7 @@ bool SecurityManager::init( try { domain_id_ = participant_->get_domain_id(); - auto part_attributes = participant_->get_attributes(); + auto part_attributes = participant_->copy_attributes(); const PropertyPolicy log_properties = PropertyPolicyHelper::get_properties_with_prefix( part_attributes.properties, "dds.sec.log.builtin.DDS_LogTopic."); @@ -1124,7 +1124,7 @@ bool SecurityManager::create_participant_stateless_message_writer() participant_stateless_message_writer_hattr_, participant_stateless_message_pool_); - RTPSParticipantAttributes pattr = participant_->get_attributes(); + RTPSParticipantAttributes pattr = participant_->copy_attributes(); WriterAttributes watt; watt.endpoint.external_unicast_locators = pattr.builtin.metatraffic_external_unicast_locators; @@ -1173,7 +1173,7 @@ bool SecurityManager::create_participant_stateless_message_reader() { participant_stateless_message_reader_history_ = new ReaderHistory(participant_stateless_message_reader_hattr_); - RTPSParticipantAttributes pattr = participant_->get_attributes(); + RTPSParticipantAttributes pattr = participant_->copy_attributes(); ReaderAttributes ratt; ratt.endpoint.topicKind = NO_KEY; @@ -1272,7 +1272,7 @@ bool SecurityManager::create_participant_volatile_message_secure_writer() participant_volatile_message_secure_writer_history_ = new WriterHistory(participant_volatile_message_secure_hattr_, participant_volatile_message_secure_pool_); - RTPSParticipantAttributes pattr = participant_->get_attributes(); + RTPSParticipantAttributes pattr = participant_->copy_attributes(); WriterAttributes watt; watt.endpoint.endpointKind = WRITER; @@ -1325,7 +1325,7 @@ bool SecurityManager::create_participant_volatile_message_secure_reader() participant_volatile_message_secure_reader_history_ = new ReaderHistory(participant_volatile_message_secure_hattr_); - RTPSParticipantAttributes pattr = participant_->get_attributes(); + RTPSParticipantAttributes pattr = participant_->copy_attributes(); ReaderAttributes ratt; ratt.endpoint.topicKind = NO_KEY; diff --git a/src/cpp/rtps/writer/BaseWriter.cpp b/src/cpp/rtps/writer/BaseWriter.cpp index 9212fe30c7e..bf6255bdcb7 100644 --- a/src/cpp/rtps/writer/BaseWriter.cpp +++ b/src/cpp/rtps/writer/BaseWriter.cpp @@ -117,7 +117,7 @@ BaseWriter::~BaseWriter() bool BaseWriter::matched_reader_add( const SubscriptionBuiltinTopicData& rqos) { - auto alloc = mp_RTPSParticipant->get_attributes().allocation; + auto alloc = mp_RTPSParticipant->copy_attributes().allocation; ReaderProxyData rdata(alloc.data_limits, rqos); return matched_reader_add_edp(rdata); diff --git a/src/cpp/rtps/writer/StatefulWriter.cpp b/src/cpp/rtps/writer/StatefulWriter.cpp index 0ede85b7f5b..6d175327d77 100644 --- a/src/cpp/rtps/writer/StatefulWriter.cpp +++ b/src/cpp/rtps/writer/StatefulWriter.cpp @@ -210,7 +210,7 @@ void StatefulWriter::init( RTPSParticipantImpl* pimpl, const WriterAttributes& att) { - RTPSParticipantAttributes part_att = pimpl->get_attributes(); + RTPSParticipantAttributes part_att = pimpl->copy_attributes(); auto push_mode = PropertyPolicyHelper::find_property(att.endpoint.properties, "fastdds.push_mode"); push_mode_ = !((nullptr != push_mode) && ("false" == *push_mode)); @@ -1038,7 +1038,7 @@ bool StatefulWriter::matched_reader_add_edp( size_t max_readers = matched_readers_pool_.max_size(); if (get_matched_readers_size() + matched_readers_pool_.size() < max_readers) { - RTPSParticipantAttributes part_att = mp_RTPSParticipant->get_attributes(); + RTPSParticipantAttributes part_att = mp_RTPSParticipant->copy_attributes(); rp = new ReaderProxy(times_, part_att.allocation.locators, this, stateful_writer_listener_); } else diff --git a/src/cpp/rtps/writer/StatelessWriter.cpp b/src/cpp/rtps/writer/StatelessWriter.cpp index 10e736b0dc6..878c110c671 100644 --- a/src/cpp/rtps/writer/StatelessWriter.cpp +++ b/src/cpp/rtps/writer/StatelessWriter.cpp @@ -171,7 +171,7 @@ void StatelessWriter::init( get_builtin_guid(); RemoteLocatorsAllocationAttributes loc_alloc = - participant->get_attributes().allocation.locators; + participant->copy_attributes().allocation.locators; for (size_t i = 0; i < attributes.matched_readers_allocation.initial; ++i) { @@ -512,7 +512,7 @@ bool StatelessWriter::matched_reader_add_edp( if (get_matched_readers_size() + matched_readers_pool_.size() < max_readers) { RemoteLocatorsAllocationAttributes loc_alloc = - mp_RTPSParticipant->get_attributes().allocation.locators; + mp_RTPSParticipant->copy_attributes().allocation.locators; new_reader.reset(new ReaderLocator( this, From 186a3f33513bf96079c58a1c8bb22f728eb55198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Thu, 16 Apr 2026 14:36:03 +0200 Subject: [PATCH 09/26] Refs #23923: Doxygen & TODO in next major MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- src/cpp/rtps/participant/RTPSParticipantImpl.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index c96308c5a49..8298df4886d 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -893,8 +893,18 @@ class RTPSParticipantImpl public: + /** + * @brief Get the RTPSParticipantAttributes of this RTPSParticipantImpl. This method is not thread safe, + * it is recommended to use copy_attributes() instead. + * @return RTPSParticipantAttributes of this RTPSParticipantImpl. + */ + FASTDDS_TODO_BEFORE(4, 0, "Make this method return a copy and delete copy_attributes()"); const RTPSParticipantAttributes& get_attributes() const; + /** + * @brief Get a copy of the RTPSParticipantAttributes of this RTPSParticipantImpl in a thread safe manner. + * @return A copy of the RTPSParticipantAttributes of this RTPSParticipantImpl. + */ RTPSParticipantAttributes copy_attributes() const; /** From bcddf45864bc20f6a952371cddbe525919a1a79c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Fri, 17 Apr 2026 10:07:40 +0200 Subject: [PATCH 10/26] Refs #23923: Copy method in RTPSParticipant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- include/fastdds/rtps/participant/RTPSParticipant.hpp | 7 +++++++ src/cpp/fastdds/domain/DomainParticipantImpl.cpp | 2 +- src/cpp/rtps/participant/RTPSParticipant.cpp | 6 +++++- src/cpp/rtps/participant/RTPSParticipantImpl.hpp | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index d2da077d3ce..cd49bf6edc8 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -236,8 +236,15 @@ class FASTDDS_EXPORTED_API RTPSParticipant * Get a reference of the current state of the RTPSParticipantParameters. * @return RTPSParticipantAttributes reference. */ + FASTDDS_TODO_BEFORE(4, 0, "Make this method return a copy and delete copy_attributes()"); const RTPSParticipantAttributes& get_attributes() const; + /** + * Get a copy of the current state of the RTPSParticipantParameters. + * @return RTPSParticipantAttributes copy. + */ + RTPSParticipantAttributes copy_attributes() const; + /** * Retrieves the maximum message size. */ diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index 8db9f6ac8ef..4a1f31741be 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -432,7 +432,7 @@ ReturnCode_t DomainParticipantImpl::set_qos( else { // Trigger update of network interfaces by calling update_attributes with current attributes - patt = rtps_participant->get_attributes(); + patt = rtps_participant->copy_attributes(); } } } diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index 561c0b77e34..bd10efb42c9 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -140,6 +140,11 @@ const RTPSParticipantAttributes& RTPSParticipant::get_attributes() const return mp_impl->get_attributes(); } +RTPSParticipantAttributes RTPSParticipant::copy_attributes() const +{ + return mp_impl->copy_attributes(); +} + uint32_t RTPSParticipant::getMaxMessageSize() const { return mp_impl->getMaxMessageSize(); @@ -315,4 +320,3 @@ bool RTPSParticipant::fill_discovery_data_from_cdr_message( } /* namespace rtps */ } /* namespace fastdds */ } /* namespace eprosima */ - diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index 8298df4886d..334ea15e290 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -1066,7 +1066,7 @@ class RTPSParticipantImpl const RTPSParticipantAttributes& patt); void update_mutable_attributes( - const RTPSParticipantAttributes& patt); + const RTPSParticipantAttributes& patt); /** * Update local writer QoS From c9c7ca603b8d2f4661e12b9dfa052276615676b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Fri, 17 Apr 2026 10:08:10 +0200 Subject: [PATCH 11/26] Refs #23923: Mock and tests changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../rtps/participant/RTPSParticipant.hpp | 5 + .../rtps/participant/RTPSParticipantImpl.hpp | 5 + .../dds/participant/ParticipantTests.cpp | 107 +++++++----------- 3 files changed, 54 insertions(+), 63 deletions(-) diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index cc1b84db8cc..fd619fc330f 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -232,6 +232,11 @@ class FASTDDS_EXPORTED_API RTPSParticipant return attributes_; } + RTPSParticipantAttributes copy_attributes() const + { + return attributes_; + } + MOCK_METHOD(bool, get_publication_info, (fastdds::rtps::PublicationBuiltinTopicData&, const GUID_t&), (const)); diff --git a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp index 3cdd8d5d256..83719ced4b9 100644 --- a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp +++ b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp @@ -332,6 +332,11 @@ class RTPSParticipantImpl return attr_; } + RTPSParticipantAttributes copy_attributes() const + { + return attr_; + } + void get_sending_locators( rtps::LocatorList_t& /*locators*/) const { diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 97771d536dc..649fbf703fa 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -1002,15 +1002,22 @@ class DomainParticipantTest : public DomainParticipant }; -void get_rtps_attributes( - const DomainParticipant* participant, - fastdds::rtps::RTPSParticipantAttributes& att) +fastdds::rtps::RTPSParticipantAttributes get_rtps_attributes( + const DomainParticipant* participant) { const DomainParticipantTest* participant_test = static_cast(participant); - ASSERT_NE(nullptr, participant_test); + EXPECT_NE(nullptr, participant_test); + if (participant_test == nullptr) + { + return {}; + } const DomainParticipantImpl* participant_impl = participant_test->get_impl(); - ASSERT_NE(nullptr, participant_impl); - att = participant_impl->get_rtps_participant()->get_attributes(); + EXPECT_NE(nullptr, participant_impl); + if (participant_impl == nullptr) + { + return {}; + } + return participant_impl->get_rtps_participant()->copy_attributes(); } void helper_wait_for_at_least_entries( @@ -1156,8 +1163,7 @@ void set_and_check_with_environment_file( // Wait for the file watch callback std::this_thread::sleep_for(std::chrono::milliseconds(100)); - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::SERVER); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); } @@ -1181,8 +1187,7 @@ TEST(ParticipantTests, SimpleParticipantRemoteServerListConfiguration) (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant); - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::CLIENT); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); @@ -1219,8 +1224,7 @@ TEST(ParticipantTests, NoBuiltinMetatrafficMulticastForClients) (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant); - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::CLIENT); EXPECT_EQ(attributes.builtin.metatrafficMulticastLocatorList.size(), 0); @@ -1256,8 +1260,7 @@ TEST(ParticipantTests, TransformSimpleParticipantToSuperclientByEnvVariable) (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant); - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::CLIENT); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); @@ -1271,8 +1274,7 @@ TEST(ParticipantTests, TransformSimpleParticipantToSuperclientByEnvVariable) (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_2); - fastdds::rtps::RTPSParticipantAttributes attributes_2; - get_rtps_attributes(participant_2, attributes_2); + fastdds::rtps::RTPSParticipantAttributes attributes_2 = get_rtps_attributes(participant_2); EXPECT_EQ(attributes_2.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::SUPER_CLIENT); EXPECT_EQ(attributes_2.builtin.discovery_config.m_DiscoveryServers, output); @@ -1345,8 +1347,7 @@ TEST(ParticipantTests, SimpleParticipantRemoteServerListConfigurationDNS) PARTICIPANT_QOS_DEFAULT); ASSERT_NE(nullptr, participant); - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::CLIENT); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); @@ -1388,8 +1389,7 @@ TEST(ParticipantTests, SimpleParticipantDynamicAdditionRemoteServers) 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); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); // As the environment file does not have the ROS_DISCOVERY_SERVER variable set, this variable has been loaded from // the environment @@ -1404,7 +1404,7 @@ TEST(ParticipantTests, SimpleParticipantDynamicAdditionRemoteServers) // Wait long enough for the file watch callback std::this_thread::sleep_for(std::chrono::milliseconds(100)); - get_rtps_attributes(participant, attributes); + attributes = get_rtps_attributes(participant); fastdds::rtps::Locator_t locator; fastdds::rtps::IPLocator::setIPv4(locator, "192.168.1.133"); @@ -1434,8 +1434,7 @@ TEST(ParticipantTests, ClientParticipantRemoteServerListConfiguration) 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); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::CLIENT); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, qos_output); DomainParticipantQos result_qos = participant->get_qos(); @@ -1463,8 +1462,7 @@ TEST(ParticipantTests, ServerParticipantEnvironmentConfiguration) DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, server_qos); ASSERT_NE(nullptr, participant); - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::SERVER); EXPECT_TRUE(attributes.builtin.discovery_config.m_DiscoveryServers.empty()); DomainParticipantQos result_qos = participant->get_qos(); @@ -1493,8 +1491,7 @@ TEST(ParticipantTests, ServerParticipantRemoteServerListConfiguration) 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); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::SERVER); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, qos_output); DomainParticipantQos result_qos = participant->get_qos(); @@ -1585,8 +1582,7 @@ TEST(ParticipantTests, EasyModeParticipantCheckConfigurationPriority) // Verify that the localhost Discovery Server is created and the configured remote IP // is the one set by the QoS (i.e., ROS2_EASY_MODE environment variable is ignored). - rtps::RTPSParticipantAttributes rtps_attr; - get_rtps_attributes(participant, rtps_attr); + rtps::RTPSParticipantAttributes rtps_attr = get_rtps_attributes(participant); ASSERT_EQ(rtps_attr.builtin.discovery_config.m_DiscoveryServers.size(), 1); rtps::Locator_t expected_locator; @@ -1621,8 +1617,7 @@ TEST(ParticipantTests, EasyModeIPConfigFromXML) // Verify that the localhost Discovery Server is created and the configured remote IP // is the one set by the QoS - rtps::RTPSParticipantAttributes rtps_attr; - get_rtps_attributes(participant, rtps_attr); + rtps::RTPSParticipantAttributes rtps_attr = get_rtps_attributes(participant); ASSERT_EQ(rtps_attr.builtin.discovery_config.m_DiscoveryServers.size(), 1); rtps::Locator_t expected_locator; @@ -1675,8 +1670,7 @@ TEST(ParticipantTests, ServerParticipantReplaceRemoteServerListConfiguration) (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant); #ifndef __APPLE__ - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.discoveryProtocol, fastdds::rtps::DiscoveryProtocol::SERVER); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, qos_output); @@ -1691,7 +1685,7 @@ TEST(ParticipantTests, ServerParticipantReplaceRemoteServerListConfiguration) qos_output.push_back(locator); std::this_thread::sleep_for(std::chrono::milliseconds(100)); - get_rtps_attributes(participant, attributes); + attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, qos_output); #endif // APPLE DomainParticipantQos result_qos = participant->get_qos(); @@ -1733,8 +1727,7 @@ TEST(ParticipantTests, ServerParticipantInconsistentLocatorsRemoteServerListConf file << "{\"ROS_DISCOVERY_SERVER\": \"172.17.0.5:4321;192.168.1.133:64863\"}"; file.close(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); #endif // APPLE DomainParticipantQos result_qos = participant->get_qos(); @@ -1796,8 +1789,7 @@ TEST(ParticipantTests, ServerParticipantCorrectRemoteServerListConfiguration) (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant); #ifndef __APPLE__ - fastdds::rtps::RTPSParticipantAttributes attributes; - get_rtps_attributes(participant, attributes); + fastdds::rtps::RTPSParticipantAttributes attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); // Add new server through environment file // Even though the server added previously through the environment file is being pinged, it is not really being @@ -1814,7 +1806,7 @@ TEST(ParticipantTests, ServerParticipantCorrectRemoteServerListConfiguration) fastdds::rtps::IPLocator::setIPv4(locator, "192.168.1.133"); locator.port = 64863; output.push_back(locator); - get_rtps_attributes(participant, attributes); + attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); // Try to be consistent: add already known server std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -1825,7 +1817,7 @@ TEST(ParticipantTests, ServerParticipantCorrectRemoteServerListConfiguration) fastdds::rtps::IPLocator::setIPv4(locator, "127.0.0.1"); locator.port = 1234; output.push_back(locator); - get_rtps_attributes(participant, attributes); + attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); result_qos = participant->get_qos(); EXPECT_EQ(RETCODE_OK, participant->set_qos(result_qos)); @@ -1841,7 +1833,7 @@ TEST(ParticipantTests, ServerParticipantCorrectRemoteServerListConfiguration) result_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(locator); EXPECT_EQ(RETCODE_OK, participant->set_qos(result_qos)); output.push_back(locator); - get_rtps_attributes(participant, attributes); + attributes = get_rtps_attributes(participant); EXPECT_EQ(attributes.builtin.discovery_config.m_DiscoveryServers, output); #endif // APPLE result_qos = participant->get_qos(); @@ -4669,14 +4661,13 @@ TEST(ParticipantTests, ParticipantCreationWithBuiltinTransport) { { DomainParticipantQos qos; - fastdds::rtps::RTPSParticipantAttributes attributes_; qos.setup_transports(rtps::BuiltinTransports::DEFAULT); DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - get_rtps_attributes(participant_, attributes_); + fastdds::rtps::RTPSParticipantAttributes attributes_ = get_rtps_attributes(participant_); auto transport_check = [](fastdds::rtps::RTPSParticipantAttributes& attributes_) -> bool { @@ -4697,14 +4688,13 @@ TEST(ParticipantTests, ParticipantCreationWithBuiltinTransport) { DomainParticipantQos qos; - fastdds::rtps::RTPSParticipantAttributes attributes_; qos.setup_transports(rtps::BuiltinTransports::DEFAULTv6); DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - get_rtps_attributes(participant_, attributes_); + fastdds::rtps::RTPSParticipantAttributes attributes_ = get_rtps_attributes(participant_); auto transport_check = [](fastdds::rtps::RTPSParticipantAttributes& attributes_) -> bool { @@ -4725,14 +4715,13 @@ TEST(ParticipantTests, ParticipantCreationWithBuiltinTransport) { DomainParticipantQos qos; - fastdds::rtps::RTPSParticipantAttributes attributes_; qos.setup_transports(rtps::BuiltinTransports::SHM); DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - get_rtps_attributes(participant_, attributes_); + fastdds::rtps::RTPSParticipantAttributes attributes_ = get_rtps_attributes(participant_); auto transport_check = [](fastdds::rtps::RTPSParticipantAttributes& attributes_) -> bool { @@ -4753,14 +4742,13 @@ TEST(ParticipantTests, ParticipantCreationWithBuiltinTransport) { DomainParticipantQos qos; - fastdds::rtps::RTPSParticipantAttributes attributes_; qos.setup_transports(rtps::BuiltinTransports::UDPv4); DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - get_rtps_attributes(participant_, attributes_); + fastdds::rtps::RTPSParticipantAttributes attributes_ = get_rtps_attributes(participant_); auto transport_check = [](fastdds::rtps::RTPSParticipantAttributes& attributes_) -> bool { @@ -4781,14 +4769,13 @@ TEST(ParticipantTests, ParticipantCreationWithBuiltinTransport) { DomainParticipantQos qos; - fastdds::rtps::RTPSParticipantAttributes attributes_; qos.setup_transports(rtps::BuiltinTransports::UDPv6); DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - get_rtps_attributes(participant_, attributes_); + fastdds::rtps::RTPSParticipantAttributes attributes_ = get_rtps_attributes(participant_); auto transport_check = [](fastdds::rtps::RTPSParticipantAttributes& attributes_) -> bool { @@ -4809,14 +4796,13 @@ TEST(ParticipantTests, ParticipantCreationWithBuiltinTransport) { DomainParticipantQos qos; - fastdds::rtps::RTPSParticipantAttributes attributes_; qos.setup_transports(rtps::BuiltinTransports::LARGE_DATA); DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - get_rtps_attributes(participant_, attributes_); + fastdds::rtps::RTPSParticipantAttributes attributes_ = get_rtps_attributes(participant_); auto transport_check = [](fastdds::rtps::RTPSParticipantAttributes& attributes_) -> bool { @@ -4851,14 +4837,13 @@ TEST(ParticipantTests, ParticipantCreationWithBuiltinTransport) { DomainParticipantQos qos; - fastdds::rtps::RTPSParticipantAttributes attributes_; qos.setup_transports(rtps::BuiltinTransports::LARGE_DATAv6); DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - get_rtps_attributes(participant_, attributes_); + fastdds::rtps::RTPSParticipantAttributes attributes_ = get_rtps_attributes(participant_); auto transport_check = [](fastdds::rtps::RTPSParticipantAttributes& attributes_) -> bool { @@ -4907,8 +4892,7 @@ class BuiltinTransportsOptionsTest (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - fastdds::rtps::RTPSParticipantAttributes attr; - get_rtps_attributes(participant_, attr); + fastdds::rtps::RTPSParticipantAttributes attr = get_rtps_attributes(participant_); EXPECT_TRUE(check_options_attr(attr, options)); EXPECT_EQ(attr.userTransports.size(), 3u); EXPECT_EQ(RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant_)); @@ -4925,8 +4909,7 @@ class BuiltinTransportsOptionsTest (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - fastdds::rtps::RTPSParticipantAttributes attr; - get_rtps_attributes(participant_, attr); + fastdds::rtps::RTPSParticipantAttributes attr = get_rtps_attributes(participant_); bool udp_ok = false; for (auto& transportDescriptor : attr.userTransports) { @@ -4958,8 +4941,7 @@ class BuiltinTransportsOptionsTest (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - fastdds::rtps::RTPSParticipantAttributes attr; - get_rtps_attributes(participant_, attr); + fastdds::rtps::RTPSParticipantAttributes attr = get_rtps_attributes(participant_); EXPECT_TRUE(check_default_participant(attr)); EXPECT_EQ(RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant_)); } @@ -5110,8 +5092,7 @@ TEST(ParticipantTests, ParticipantCreationWithLargeDataOptionsThroughAPI) (uint32_t)GET_PID() % 230, qos); ASSERT_NE(nullptr, participant_); - fastdds::rtps::RTPSParticipantAttributes attr; - get_rtps_attributes(participant_, attr); + fastdds::rtps::RTPSParticipantAttributes attr = get_rtps_attributes(participant_); EXPECT_TRUE(BuiltinTransportsOptionsTest::check_options_attr(attr, options)); EXPECT_EQ(attr.userTransports.size(), 3u); From a192aa17107d8ee3a8d67830aaf83fd4b890db4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Mon, 20 Apr 2026 14:16:00 +0200 Subject: [PATCH 12/26] Refs #23923: Revision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- include/fastdds/rtps/participant/RTPSParticipant.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index cd49bf6edc8..23baacab6d5 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -234,6 +234,8 @@ class FASTDDS_EXPORTED_API RTPSParticipant /** * Get a reference of the current state of the RTPSParticipantParameters. + * @warning The returned reference is not thread safe. It is recommended to use copy_attributes() + * instead to get a thread safe copy of the attributes. * @return RTPSParticipantAttributes reference. */ FASTDDS_TODO_BEFORE(4, 0, "Make this method return a copy and delete copy_attributes()"); From a56e8ddc47b5e5f9dd01a9a57569226ebe0334b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Fri, 24 Apr 2026 12:35:05 +0200 Subject: [PATCH 13/26] Refs #23923: Add missing mutable attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 475bdbe6ec5..f8085bf796b 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1690,6 +1690,7 @@ void RTPSParticipantImpl::update_mutable_attributes( m_att.defaultUnicastLocatorList = patt.defaultUnicastLocatorList; m_att.default_external_unicast_locators = patt.default_external_unicast_locators; m_att.builtin.discovery_config.m_DiscoveryServers = patt.builtin.discovery_config.m_DiscoveryServers; + m_att.builtin.metatraffic_external_unicast_locators = patt.builtin.metatraffic_external_unicast_locators; } bool RTPSParticipantImpl::update_writer( From b1f98a15a3e96b67b7daa25a0d0a01eed95b0389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Fri, 24 Apr 2026 12:39:35 +0200 Subject: [PATCH 14/26] Refs #23923: Create const copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../rtps/participant/RTPSParticipant.hpp | 12 +++++++++- .../type_lookup_service/TypeLookupManager.cpp | 2 +- .../TypeLookupReplyListener.cpp | 2 +- .../TypeLookupRequestListener.cpp | 2 +- src/cpp/rtps/builtin/BuiltinProtocols.cpp | 2 +- .../builtin/discovery/endpoint/EDPSimple.cpp | 2 +- .../builtin/discovery/endpoint/EDPStatic.cpp | 4 ++-- .../builtin/discovery/participant/PDP.cpp | 19 +++++++-------- .../discovery/participant/PDPClient.cpp | 2 +- .../discovery/participant/PDPListener.cpp | 2 +- .../discovery/participant/PDPServer.cpp | 6 ++--- .../discovery/participant/PDPSimple.cpp | 10 ++++---- .../participant/simple/PDPStatelessWriter.cpp | 2 +- src/cpp/rtps/builtin/liveliness/WLP.cpp | 24 +++++++++---------- .../flowcontrol/FlowControllerFactory.cpp | 2 +- .../rtps/flowcontrol/FlowControllerImpl.hpp | 2 +- src/cpp/rtps/participant/RTPSParticipant.cpp | 5 ++++ .../rtps/participant/RTPSParticipantImpl.cpp | 6 +++++ .../rtps/participant/RTPSParticipantImpl.hpp | 14 ++++++++++- src/cpp/rtps/reader/BaseReader.cpp | 2 +- src/cpp/rtps/reader/StatefulReader.cpp | 6 ++--- src/cpp/rtps/security/SecurityManager.cpp | 12 ++++------ .../security/accesscontrol/AccessControl.h | 3 +-- .../security/authentication/Authentication.h | 2 +- src/cpp/rtps/writer/BaseWriter.cpp | 2 +- src/cpp/rtps/writer/StatefulWriter.cpp | 4 ++-- src/cpp/rtps/writer/StatelessWriter.cpp | 8 +++---- .../security/accesscontrol/Permissions.cpp | 5 ++-- src/cpp/security/accesscontrol/Permissions.h | 3 +-- src/cpp/security/authentication/PKIDH.cpp | 4 ++-- src/cpp/security/authentication/PKIDH.h | 2 +- .../rtps/participant/RTPSParticipant.hpp | 5 ++++ .../rtps/participant/RTPSParticipantImpl.hpp | 5 ++++ .../rtps/security/MockAccessControlPlugin.h | 3 +-- .../rtps/security/MockAuthenticationPlugin.h | 2 +- .../accesscontrol/AccessControlTests.cpp | 5 ++-- .../AuthenticationPluginTests.hpp | 8 +++---- .../authentication/BuiltinPKIDHTests.cpp | 18 +++++++------- 38 files changed, 125 insertions(+), 94 deletions(-) diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 23baacab6d5..8b7e6d0e77c 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -238,13 +238,23 @@ class FASTDDS_EXPORTED_API RTPSParticipant * instead to get a thread safe copy of the attributes. * @return RTPSParticipantAttributes reference. */ - FASTDDS_TODO_BEFORE(4, 0, "Make this method return a copy and delete copy_attributes()"); + FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); const RTPSParticipantAttributes& get_attributes() const; + /** + * @brief Get a const reference of the constant RTPSParticipantAttributes of this RTPSParticipantImpl. + * This method is thread safe because it returns a const reference to the internal attributes. + * @warning It must not be used to access mutable attributes as it could return outdated values. + * @return A const reference to the RTPSParticipantAttributes of this RTPSParticipantImpl. + */ + FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); + const RTPSParticipantAttributes& get_const_attributes() const; + /** * Get a copy of the current state of the RTPSParticipantParameters. * @return RTPSParticipantAttributes copy. */ + FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); RTPSParticipantAttributes copy_attributes() const; /** diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index f16f881bfe6..23f38dc2ba6 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -127,7 +127,7 @@ bool TypeLookupManager::init( { participant_ = protocols->mp_participantImpl; builtin_protocols_ = protocols; - auto locators_allocations = participant_->copy_attributes().allocation.locators; + const auto& locators_allocations = participant_->get_const_attributes().allocation.locators; local_instance_name_ = get_instance_name(participant_->getGuid()); diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 20e66899d7d..d13d27fbda4 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -59,7 +59,7 @@ void TypeLookupReplyListener::start_reply_processor_thread() }; // Create and start the processing thread replies_processor_thread = eprosima::create_thread(thread_func, - typelookup_manager_->participant_->copy_attributes().typelookup_service_thread, + typelookup_manager_->participant_->get_const_attributes().typelookup_service_thread, "dds.tls.replies.%u"); } } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index b0ca3fca658..e13759f3794 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -112,7 +112,7 @@ void TypeLookupRequestListener::start_request_processor_thread() }; // Create and start the processing thread request_processor_thread = eprosima::create_thread(thread_func, - typelookup_manager_->participant_->copy_attributes().typelookup_service_thread, + typelookup_manager_->participant_->get_const_attributes().typelookup_service_thread, "dds.tls.requests.%u"); } } diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index 935fc92480b..23b6aa4bfd1 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -86,7 +86,7 @@ bool BuiltinProtocols::initBuiltinProtocols( filter_server_remote_locators(p_part->network_factory()); - RTPSParticipantAllocationAttributes allocation = p_part->copy_attributes().allocation; + const RTPSParticipantAllocationAttributes& allocation = p_part->get_const_attributes().allocation; // PDP switch (m_att.discovery_config.discoveryProtocol) diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index 0d7dfc1498b..d1f5af1d296 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -755,7 +755,7 @@ void EDPSimple::assignRemoteEndpoints( const NetworkFactory& network = mp_RTPSParticipant->network_factory(); uint32_t endp = pdata.m_available_builtin_endpoints; uint32_t auxendp; - bool use_multicast_locators = !mp_PDP->getRTPSParticipant()->copy_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = !mp_PDP->getRTPSParticipant()->get_const_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); auto temp_reader_proxy_data = get_temporary_reader_proxies_pool().get(); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp index 7dd6ee9c661..86f4f36482a 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp @@ -137,8 +137,8 @@ bool EDPStatic::initEDP( } // Check there is a Participant's property changing the exchange format. - auto properties = mp_RTPSParticipant->copy_attributes().properties.properties(); - for (auto& property : properties) + const auto& properties = mp_RTPSParticipant->get_const_attributes().properties.properties(); + for (const auto& property : properties) { if (0 == property.name().compare(exchange_format_property_name)) { diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index b24a69b6287..165c987d485 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -179,7 +179,7 @@ ParticipantProxyData* PDP::add_participant_proxy_data( { // Pool is empty but limit has not been reached, so we create a new entry. ++participant_proxies_number_; - ret_val = new ParticipantProxyData(mp_RTPSParticipant->copy_attributes().allocation); + ret_val = new ParticipantProxyData(mp_RTPSParticipant->get_const_attributes().allocation); if (participant_guid != mp_RTPSParticipant->getGuid()) { ret_val->lease_duration_event = new TimedEvent(mp_RTPSParticipant->getEventResource(), @@ -487,8 +487,7 @@ bool PDP::initPDP( { EPROSIMA_LOG_INFO(RTPS_PDP, "Beginning"); mp_RTPSParticipant = part; - m_discovery = mp_RTPSParticipant->copy_attributes().builtin; - initial_announcements_ = m_discovery.discovery_config.initial_announcements; + initial_announcements_ = mp_RTPSParticipant->get_const_attributes().builtin.discovery_config.initial_announcements; //CREATE ENDPOINTS if (!createPDPEndpoints()) { @@ -967,7 +966,7 @@ ReaderProxyData* PDP::addReaderProxyData( // Pool is empty but limit has not been reached, so we create a new entry. ++reader_proxies_number_; - auto allocations = mp_RTPSParticipant->copy_attributes().allocation; + const auto& allocations = mp_RTPSParticipant->get_const_attributes().allocation; ret_val = new ReaderProxyData( allocations.locators.max_unicast_locators, @@ -1055,7 +1054,7 @@ WriterProxyData* PDP::addWriterProxyData( // Pool is empty but limit has not been reached, so we create a new entry. ++writer_proxies_number_; - auto allocations = mp_RTPSParticipant->copy_attributes().allocation; + const auto& allocations = mp_RTPSParticipant->get_const_attributes().allocation; ret_val = new WriterProxyData( allocations.locators.max_unicast_locators, @@ -1518,7 +1517,7 @@ void PDP::resend_ininitial_announcements() void PDP::set_external_participant_properties_( ParticipantProxyData* participant_data) { - auto part_attributes = mp_RTPSParticipant->copy_attributes(); + const RTPSParticipantAttributes& part_attributes = mp_RTPSParticipant->get_const_attributes(); // For each property add it if it should be sent (it is propagated) for (auto const& property : part_attributes.properties.properties()) @@ -1588,8 +1587,6 @@ static void set_builtin_endpoint_locators( const PDP* pdp, const BuiltinProtocols* builtin) { - RTPSParticipantAttributes pattr = pdp->getRTPSParticipant()->copy_attributes(); - auto part_data = pdp->getLocalParticipantProxyData(); if (nullptr == part_data) { @@ -1615,14 +1612,14 @@ static void set_builtin_endpoint_locators( // External locators are always taken from the same place endpoint.external_unicast_locators = pdp->builtin_attributes().metatraffic_external_unicast_locators; - endpoint.ignore_non_matching_locators = pattr.ignore_non_matching_locators; + endpoint.ignore_non_matching_locators = pdp->getRTPSParticipant()->get_const_attributes().ignore_non_matching_locators; } ReaderAttributes PDP::create_builtin_reader_attributes() { ReaderAttributes attributes; - RTPSParticipantAttributes pattr = getRTPSParticipant()->copy_attributes(); + const RTPSParticipantAttributes& pattr = getRTPSParticipant()->get_const_attributes(); set_builtin_matched_allocation(attributes.matched_writers_allocation, pattr); // Builtin endpoints are always reliable, transient local, keyed topics @@ -1646,7 +1643,7 @@ WriterAttributes PDP::create_builtin_writer_attributes() { WriterAttributes attributes; - RTPSParticipantAttributes pattr = getRTPSParticipant()->copy_attributes(); + const RTPSParticipantAttributes& pattr = getRTPSParticipant()->get_const_attributes(); set_builtin_matched_allocation(attributes.matched_readers_allocation, pattr); // Builtin endpoints are always reliable, transient local, keyed topics diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index e569381220a..453fbedb6cc 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -104,7 +104,7 @@ void PDPClient::initializeParticipantProxyData( { PDP::initializeParticipantProxyData(participant_data); // TODO: Remember that the PDP version USES security - auto discovery_config = getRTPSParticipant()->copy_attributes().builtin.discovery_config; + const auto& discovery_config = getRTPSParticipant()->get_const_attributes().builtin.discovery_config; if ((DiscoveryProtocol::CLIENT != discovery_config.discoveryProtocol) && (DiscoveryProtocol::SUPER_CLIENT != discovery_config.discoveryProtocol)) diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index b77224eb1fc..bdd2b588e6f 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -49,7 +49,7 @@ namespace rtps { PDPListener::PDPListener( PDP* parent) : parent_pdp_(parent) - , temp_participant_data_(parent->getRTPSParticipant()->copy_attributes().allocation) + , temp_participant_data_(parent->getRTPSParticipant()->get_const_attributes().allocation) { } diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index 67581935571..c5f3114ab9b 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -119,7 +119,7 @@ bool PDPServer::init( getRTPSParticipant()->enableReader(edp->publications_reader_.first); // Initialize server dedicated thread. - RTPSParticipantAttributes part_attr = getRTPSParticipant()->copy_attributes(); + const RTPSParticipantAttributes& part_attr = getRTPSParticipant()->get_const_attributes(); uint32_t id_for_thread = static_cast(part_attr.participantID); const fastdds::rtps::ThreadSettings& thr_config = part_attr.discovery_server_thread; resource_event_thread_.init_thread(thr_config, "dds.ds_ev.%u", id_for_thread); @@ -360,7 +360,7 @@ void PDPServer::initializeParticipantProxyData( { PDP::initializeParticipantProxyData(participant_data); - auto discovery_config = getRTPSParticipant()->copy_attributes().builtin.discovery_config; + const auto& discovery_config = getRTPSParticipant()->get_const_attributes().builtin.discovery_config; if (discovery_config.discoveryProtocol != DiscoveryProtocol::SERVER && discovery_config.discoveryProtocol != DiscoveryProtocol::BACKUP) @@ -395,7 +395,7 @@ void PDPServer::match_reliable_pdp_endpoints( auto endpoints = static_cast(builtin_endpoints_.get()); const NetworkFactory& network = mp_RTPSParticipant->network_factory(); uint32_t endp = pdata.m_available_builtin_endpoints; - bool use_multicast_locators = !mp_RTPSParticipant->copy_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = !mp_RTPSParticipant->get_const_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); // Only SERVER and CLIENT participants will be received. All builtin must be there diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp index 86699d2d98f..d9a1f045660 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp @@ -109,7 +109,7 @@ void PDPSimple::initializeParticipantProxyData( { PDP::initializeParticipantProxyData(participant_data); - auto discovery_config = getRTPSParticipant()->copy_attributes().builtin.discovery_config; + const auto& discovery_config = getRTPSParticipant()->get_const_attributes().builtin.discovery_config; if (discovery_config.use_SIMPLE_EndpointDiscoveryProtocol) { @@ -348,8 +348,7 @@ bool PDPSimple::createPDPEndpoints() bool PDPSimple::create_dcps_participant_endpoints() { - RTPSParticipantAttributes pattr = mp_RTPSParticipant->copy_attributes(); - const RTPSParticipantAllocationAttributes& allocation = pattr.allocation; + const RTPSParticipantAllocationAttributes& allocation = mp_RTPSParticipant->get_const_attributes().allocation; const BuiltinAttributes& builtin_att = mp_builtin->m_att; auto endpoints = dynamic_cast(builtin_endpoints_.get()); assert(nullptr != endpoints); @@ -478,8 +477,7 @@ bool PDPSimple::create_dcps_participant_endpoints() #if HAVE_SECURITY bool PDPSimple::create_dcps_participant_secure_endpoints() { - RTPSParticipantAttributes pattr = mp_RTPSParticipant->copy_attributes(); - const RTPSParticipantAllocationAttributes& allocation = pattr.allocation; + const RTPSParticipantAllocationAttributes& allocation = mp_RTPSParticipant->get_const_attributes().allocation; const BuiltinAttributes& builtin_att = mp_builtin->m_att; auto endpoints = dynamic_cast(builtin_endpoints_.get()); assert(nullptr != endpoints); @@ -664,7 +662,7 @@ void PDPSimple::match_pdp_remote_endpoints( auto endpoints = static_cast(builtin_endpoints_.get()); const NetworkFactory& network = mp_RTPSParticipant->network_factory(); - bool use_multicast_locators = !mp_RTPSParticipant->copy_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = !mp_RTPSParticipant->get_const_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); const uint32_t endp = pdata.m_available_builtin_endpoints; diff --git a/src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp b/src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp index d9a92ac78d6..dae8a1c2080 100644 --- a/src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp @@ -48,7 +48,7 @@ PDPStatelessWriter::PDPStatelessWriter( WriterHistory* history, WriterListener* listener) : StatelessWriter(participant, guid, attributes, flow_controller, history, listener) - , interested_readers_(participant->copy_attributes().allocation.participants) + , interested_readers_(participant->get_const_attributes().allocation.participants) { } diff --git a/src/cpp/rtps/builtin/liveliness/WLP.cpp b/src/cpp/rtps/builtin/liveliness/WLP.cpp index 0a3ae203710..2bccb2566c9 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -108,14 +108,14 @@ WLP::WLP( , mp_builtinReaderSecureHistory(nullptr) #endif // if HAVE_SECURITY , temp_reader_proxy_data_( - p->mp_participantImpl->copy_attributes().allocation.locators.max_unicast_locators, - p->mp_participantImpl->copy_attributes().allocation.locators.max_multicast_locators, - p->mp_participantImpl->copy_attributes().allocation.data_limits, - p->mp_participantImpl->copy_attributes().allocation.content_filter) + p->mp_participantImpl->get_const_attributes().allocation.locators.max_unicast_locators, + p->mp_participantImpl->get_const_attributes().allocation.locators.max_multicast_locators, + p->mp_participantImpl->get_const_attributes().allocation.data_limits, + p->mp_participantImpl->get_const_attributes().allocation.content_filter) , temp_writer_proxy_data_( - p->mp_participantImpl->copy_attributes().allocation.locators.max_unicast_locators, - p->mp_participantImpl->copy_attributes().allocation.locators.max_multicast_locators, - p->mp_participantImpl->copy_attributes().allocation.data_limits) + p->mp_participantImpl->get_const_attributes().allocation.locators.max_unicast_locators, + p->mp_participantImpl->get_const_attributes().allocation.locators.max_multicast_locators, + p->mp_participantImpl->get_const_attributes().allocation.data_limits) { GUID_t tmp_guid = p->mp_participantImpl->getGuid(); tmp_guid.entityId = 0; @@ -236,8 +236,8 @@ bool WLP::initWL( bool WLP::createEndpoints() { - RTPSParticipantAttributes pattr = mp_participant->copy_attributes(); - const ResourceLimitedContainerConfig& participants_allocation = pattr.allocation.participants; + const ResourceLimitedContainerConfig& participants_allocation = + mp_participant->get_const_attributes().allocation.participants; // Built-in writer history HistoryAttributes hatt; @@ -320,8 +320,8 @@ bool WLP::createEndpoints() bool WLP::createSecureEndpoints() { - RTPSParticipantAttributes pattr = mp_participant->copy_attributes(); - const ResourceLimitedContainerConfig& participants_allocation = pattr.allocation.participants; + const ResourceLimitedContainerConfig& participants_allocation = + mp_participant->get_const_attributes().allocation.participants; //CREATE WRITER HistoryAttributes hatt; @@ -454,7 +454,7 @@ bool WLP::assignRemoteEndpoints( const NetworkFactory& network = mp_participant->network_factory(); uint32_t endp = pdata.m_available_builtin_endpoints; uint32_t auxendp = endp; - bool use_multicast_locators = !mp_participant->copy_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = !mp_participant->get_const_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); std::lock_guard data_guard(temp_data_lock_); diff --git a/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp b/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp index ecaffc72b2c..3d845250884 100644 --- a/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp +++ b/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp @@ -15,7 +15,7 @@ void FlowControllerFactory::init( const ThreadSettings& sender_thread_settings = (nullptr == participant_) ? ThreadSettings{} - : participant_->copy_attributes().builtin_controllers_sender_thread; + : participant_->get_const_attributes().builtin_controllers_sender_thread; // PureSyncFlowController -> used by volatile besteffort writers. flow_controllers_.insert(decltype(flow_controllers_)::value_type( diff --git a/src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp b/src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp index 5f855fc0879..47804679d2b 100644 --- a/src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp +++ b/src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp @@ -992,7 +992,7 @@ class FlowControllerImpl : public FlowController { if (nullptr != participant) { - participant_id_ = static_cast(participant->copy_attributes().participantID); + participant_id_ = static_cast(participant->get_const_attributes().participantID); } uint32_t limitation = get_max_payload(); diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index bd10efb42c9..711cb9da617 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -140,6 +140,11 @@ const RTPSParticipantAttributes& RTPSParticipant::get_attributes() const return mp_impl->get_attributes(); } +const RTPSParticipantAttributes& RTPSParticipant::get_const_attributes() const +{ + return mp_impl->get_const_attributes(); +} + RTPSParticipantAttributes RTPSParticipant::copy_attributes() const { return mp_impl->copy_attributes(); diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index f8085bf796b..bfcba11f1a9 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -282,6 +282,7 @@ RTPSParticipantImpl::RTPSParticipantImpl( RTPSParticipantListener* plisten) : domain_id_(domain_id) , m_att(PParam) + , const_m_att(PParam) , m_guid(guidP, c_EntityId_RTPSParticipant) , mp_builtinProtocols(nullptr) , IdCounter(0) @@ -3450,6 +3451,11 @@ const RTPSParticipantAttributes& RTPSParticipantImpl::get_attributes() const return m_att; } +const RTPSParticipantAttributes& RTPSParticipantImpl::get_const_attributes() const +{ + return const_m_att; +} + RTPSParticipantAttributes RTPSParticipantImpl::copy_attributes() const { std::lock_guard _(mutex_); diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index 334ea15e290..67496450cb0 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -614,6 +614,8 @@ class RTPSParticipantImpl uint32_t domain_id_; //!Attributes of the RTPSParticipant RTPSParticipantAttributes m_att; + //!Constant copy of Attributes of the RTPSParticipant + const RTPSParticipantAttributes const_m_att; //! Metatraffic unicast port used by default on this participant uint32_t metatraffic_unicast_port_ = 0; //! Default unicast port used by default on this participant @@ -898,13 +900,23 @@ class RTPSParticipantImpl * it is recommended to use copy_attributes() instead. * @return RTPSParticipantAttributes of this RTPSParticipantImpl. */ - FASTDDS_TODO_BEFORE(4, 0, "Make this method return a copy and delete copy_attributes()"); + FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); const RTPSParticipantAttributes& get_attributes() const; + /** + * @brief Get a const reference of the constant RTPSParticipantAttributes of this RTPSParticipantImpl. + * This method is thread safe because it returns a const reference to the internal attributes. + * @warning It must not be used to access mutable attributes as it could return outdated values. + * @return A const reference to the RTPSParticipantAttributes of this RTPSParticipantImpl. + */ + FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); + const RTPSParticipantAttributes& get_const_attributes() const; + /** * @brief Get a copy of the RTPSParticipantAttributes of this RTPSParticipantImpl in a thread safe manner. * @return A copy of the RTPSParticipantAttributes of this RTPSParticipantImpl. */ + FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); RTPSParticipantAttributes copy_attributes() const; /** diff --git a/src/cpp/rtps/reader/BaseReader.cpp b/src/cpp/rtps/reader/BaseReader.cpp index 9a1919a6f6b..7d3d434db9a 100644 --- a/src/cpp/rtps/reader/BaseReader.cpp +++ b/src/cpp/rtps/reader/BaseReader.cpp @@ -133,7 +133,7 @@ BaseReader::~BaseReader() bool BaseReader::matched_writer_add( const PublicationBuiltinTopicData& info) { - auto alloc = mp_RTPSParticipant->copy_attributes().allocation; + auto alloc = mp_RTPSParticipant->get_const_attributes().allocation; WriterProxyData wdata(alloc.data_limits, info); return matched_writer_add_edp(wdata); diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index d7365ec39c3..0c577f3c0f0 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -190,10 +190,9 @@ void StatefulReader::init( RTPSParticipantImpl* pimpl, const ReaderAttributes& att) { - RTPSParticipantAttributes part_att = pimpl->copy_attributes(); 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, pimpl->get_const_attributes().allocation.locators, proxy_changes_config_)); } } @@ -264,8 +263,7 @@ bool StatefulReader::matched_writer_add_edp( size_t max_readers = matched_writers_pool_.max_size(); if (getMatchedWritersSize() + matched_writers_pool_.size() < max_readers) { - RTPSParticipantAttributes part_att = mp_RTPSParticipant->copy_attributes(); - wp = new WriterProxy(this, part_att.allocation.locators, proxy_changes_config_); + wp = new WriterProxy(this, mp_RTPSParticipant->get_const_attributes().allocation.locators, proxy_changes_config_); } else { diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 7d172f2ac59..8d8fb8f7106 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -123,9 +123,8 @@ bool SecurityManager::init( try { domain_id_ = participant_->get_domain_id(); - auto part_attributes = participant_->copy_attributes(); const PropertyPolicy log_properties = PropertyPolicyHelper::get_properties_with_prefix( - part_attributes.properties, + participant_->get_const_attributes().properties, "dds.sec.log.builtin.DDS_LogTopic."); // length(log_properties) == 0 considered as logging disable. @@ -214,7 +213,7 @@ bool SecurityManager::init( { // retrieve authentication properties, if any const PropertyPolicy auth_handshake_properties = PropertyPolicyHelper::get_properties_with_prefix( - part_attributes.properties, + participant_->get_const_attributes().properties, "dds.sec.auth.builtin.PKI-DH."); // if auth_handshake_properties is empty, the default values are used @@ -234,7 +233,7 @@ bool SecurityManager::init( ret = authentication_plugin_->validate_local_identity(&local_identity_handle_, adjusted_participant_key, domain_id_, - part_attributes, + participant_->get_const_attributes().properties, participant_->getGuid(), exception); } @@ -257,7 +256,7 @@ bool SecurityManager::init( local_permissions_handle_ = access_plugin_->validate_local_permissions( *authentication_plugin_, *local_identity_handle_, domain_id_, - part_attributes, + participant_->get_const_attributes().properties, exception); if (local_permissions_handle_ != nullptr) @@ -265,8 +264,7 @@ bool SecurityManager::init( if (!local_permissions_handle_->nil()) { if (access_plugin_->check_create_participant(*local_permissions_handle_, - domain_id_, - part_attributes, exception)) + domain_id_, exception)) { // Set credentials. PermissionsCredentialToken* token = nullptr; diff --git a/src/cpp/rtps/security/accesscontrol/AccessControl.h b/src/cpp/rtps/security/accesscontrol/AccessControl.h index 7b6a83def4c..0097a26fe3b 100644 --- a/src/cpp/rtps/security/accesscontrol/AccessControl.h +++ b/src/cpp/rtps/security/accesscontrol/AccessControl.h @@ -48,7 +48,7 @@ class AccessControl Authentication& auth_plugin, const IdentityHandle& identity, const uint32_t domain_id, - const RTPSParticipantAttributes& participant_attr, + const PropertyPolicy& part_props, SecurityException& exception) = 0; virtual bool get_permissions_token( @@ -88,7 +88,6 @@ class AccessControl virtual bool check_create_participant( const PermissionsHandle& local_handle, const uint32_t domain_id, - const RTPSParticipantAttributes& qos, SecurityException& exception) = 0; virtual bool check_remote_participant( diff --git a/src/cpp/rtps/security/authentication/Authentication.h b/src/cpp/rtps/security/authentication/Authentication.h index 6787e572e7a..7a25dc4bcec 100644 --- a/src/cpp/rtps/security/authentication/Authentication.h +++ b/src/cpp/rtps/security/authentication/Authentication.h @@ -80,7 +80,7 @@ class Authentication IdentityHandle** local_identity_handle, GUID_t& adjusted_participant_key, const uint32_t domain_id, - const RTPSParticipantAttributes& participant_attr, + const PropertyPolicy& part_props, const GUID_t& candidate_participant_key, SecurityException& exception) = 0; diff --git a/src/cpp/rtps/writer/BaseWriter.cpp b/src/cpp/rtps/writer/BaseWriter.cpp index bf6255bdcb7..b1ec8c1b2b9 100644 --- a/src/cpp/rtps/writer/BaseWriter.cpp +++ b/src/cpp/rtps/writer/BaseWriter.cpp @@ -117,7 +117,7 @@ BaseWriter::~BaseWriter() bool BaseWriter::matched_reader_add( const SubscriptionBuiltinTopicData& rqos) { - auto alloc = mp_RTPSParticipant->copy_attributes().allocation; + const auto& alloc = mp_RTPSParticipant->get_attributes().allocation; ReaderProxyData rdata(alloc.data_limits, rqos); return matched_reader_add_edp(rdata); diff --git a/src/cpp/rtps/writer/StatefulWriter.cpp b/src/cpp/rtps/writer/StatefulWriter.cpp index 6d175327d77..84b292e2ffb 100644 --- a/src/cpp/rtps/writer/StatefulWriter.cpp +++ b/src/cpp/rtps/writer/StatefulWriter.cpp @@ -210,7 +210,7 @@ void StatefulWriter::init( RTPSParticipantImpl* pimpl, const WriterAttributes& att) { - RTPSParticipantAttributes part_att = pimpl->copy_attributes(); + const RTPSParticipantAttributes& part_att = pimpl->get_attributes(); auto push_mode = PropertyPolicyHelper::find_property(att.endpoint.properties, "fastdds.push_mode"); push_mode_ = !((nullptr != push_mode) && ("false" == *push_mode)); @@ -1038,7 +1038,7 @@ bool StatefulWriter::matched_reader_add_edp( size_t max_readers = matched_readers_pool_.max_size(); if (get_matched_readers_size() + matched_readers_pool_.size() < max_readers) { - RTPSParticipantAttributes part_att = mp_RTPSParticipant->copy_attributes(); + const RTPSParticipantAttributes& part_att = mp_RTPSParticipant->get_attributes(); rp = new ReaderProxy(times_, part_att.allocation.locators, this, stateful_writer_listener_); } else diff --git a/src/cpp/rtps/writer/StatelessWriter.cpp b/src/cpp/rtps/writer/StatelessWriter.cpp index 878c110c671..c86014c09e6 100644 --- a/src/cpp/rtps/writer/StatelessWriter.cpp +++ b/src/cpp/rtps/writer/StatelessWriter.cpp @@ -170,8 +170,8 @@ void StatelessWriter::init( { get_builtin_guid(); - RemoteLocatorsAllocationAttributes loc_alloc = - participant->copy_attributes().allocation.locators; + const RemoteLocatorsAllocationAttributes& loc_alloc = + participant->get_attributes().allocation.locators; for (size_t i = 0; i < attributes.matched_readers_allocation.initial; ++i) { @@ -511,8 +511,8 @@ bool StatelessWriter::matched_reader_add_edp( size_t max_readers = matched_readers_pool_.max_size(); if (get_matched_readers_size() + matched_readers_pool_.size() < max_readers) { - RemoteLocatorsAllocationAttributes loc_alloc = - mp_RTPSParticipant->copy_attributes().allocation.locators; + const RemoteLocatorsAllocationAttributes& loc_alloc = + mp_RTPSParticipant->get_attributes().allocation.locators; new_reader.reset(new ReaderLocator( this, diff --git a/src/cpp/security/accesscontrol/Permissions.cpp b/src/cpp/security/accesscontrol/Permissions.cpp index 0aba022723e..df6e46d5a6f 100644 --- a/src/cpp/security/accesscontrol/Permissions.cpp +++ b/src/cpp/security/accesscontrol/Permissions.cpp @@ -818,10 +818,10 @@ PermissionsHandle* Permissions::validate_local_permissions( Authentication&, const IdentityHandle& identity, const uint32_t domain_id, - const RTPSParticipantAttributes& participant_attr, + const PropertyPolicy& part_props, SecurityException& exception) { - PropertyPolicy access_properties = PropertyPolicyHelper::get_properties_with_prefix(participant_attr.properties, + PropertyPolicy access_properties = PropertyPolicyHelper::get_properties_with_prefix(part_props, "dds.sec.access.builtin.Access-Permissions."); if (PropertyPolicyHelper::length(access_properties) == 0) @@ -1071,7 +1071,6 @@ PermissionsHandle* Permissions::validate_remote_permissions( bool Permissions::check_create_participant( const PermissionsHandle& local_handle, const uint32_t /*domain_id*/, - const RTPSParticipantAttributes&, SecurityException& exception) { bool returned_value = false; diff --git a/src/cpp/security/accesscontrol/Permissions.h b/src/cpp/security/accesscontrol/Permissions.h index 4e3af031534..6a1195e1adb 100644 --- a/src/cpp/security/accesscontrol/Permissions.h +++ b/src/cpp/security/accesscontrol/Permissions.h @@ -37,7 +37,7 @@ class Permissions : public AccessControl Authentication& auth_plugin, const IdentityHandle& identity, const uint32_t domain_id, - const RTPSParticipantAttributes& participant_attr, + const PropertyPolicy& part_props, SecurityException& exception) override; bool get_permissions_token( @@ -77,7 +77,6 @@ class Permissions : public AccessControl bool check_create_participant( const PermissionsHandle& local_handle, const uint32_t domain_id, - const RTPSParticipantAttributes& qos, SecurityException& exception) override; bool check_remote_participant( diff --git a/src/cpp/security/authentication/PKIDH.cpp b/src/cpp/security/authentication/PKIDH.cpp index defd9be14d8..3371009bf14 100644 --- a/src/cpp/security/authentication/PKIDH.cpp +++ b/src/cpp/security/authentication/PKIDH.cpp @@ -1065,13 +1065,13 @@ ValidationResult_t PKIDH::validate_local_identity( IdentityHandle** local_identity_handle, GUID_t& adjusted_participant_key, const uint32_t /*domain_id*/, - const RTPSParticipantAttributes& participant_attr, + const PropertyPolicy& part_props, const GUID_t& candidate_participant_key, SecurityException& exception) { assert(local_identity_handle); - PropertyPolicy auth_properties = PropertyPolicyHelper::get_properties_with_prefix(participant_attr.properties, + PropertyPolicy auth_properties = PropertyPolicyHelper::get_properties_with_prefix(part_props, "dds.sec.auth.builtin.PKI-DH."); if (PropertyPolicyHelper::length(auth_properties) == 0) diff --git a/src/cpp/security/authentication/PKIDH.h b/src/cpp/security/authentication/PKIDH.h index fe4c8a09d79..8a12c8faae9 100644 --- a/src/cpp/security/authentication/PKIDH.h +++ b/src/cpp/security/authentication/PKIDH.h @@ -37,7 +37,7 @@ class PKIDH : public Authentication IdentityHandle** local_identity_handle, GUID_t& adjusted_participant_key, const uint32_t domain_id, - const RTPSParticipantAttributes& participant_attr, + const PropertyPolicy& part_props, const GUID_t& candidate_participant_key, SecurityException& exception) override; diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index fd619fc330f..c9ddcca8fa7 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -232,6 +232,11 @@ class FASTDDS_EXPORTED_API RTPSParticipant return attributes_; } + const RTPSParticipantAttributes& get_const_attributes() const + { + return attributes_; + } + RTPSParticipantAttributes copy_attributes() const { return attributes_; diff --git a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp index 83719ced4b9..5d748f9a5e1 100644 --- a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp +++ b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp @@ -332,6 +332,11 @@ class RTPSParticipantImpl return attr_; } + const RTPSParticipantAttributes& get_const_attributes() const + { + return attr_; + } + RTPSParticipantAttributes copy_attributes() const { return attr_; diff --git a/test/mock/rtps/SecurityPluginFactory/rtps/security/MockAccessControlPlugin.h b/test/mock/rtps/SecurityPluginFactory/rtps/security/MockAccessControlPlugin.h index 21d6dbe4482..9940d4a7090 100644 --- a/test/mock/rtps/SecurityPluginFactory/rtps/security/MockAccessControlPlugin.h +++ b/test/mock/rtps/SecurityPluginFactory/rtps/security/MockAccessControlPlugin.h @@ -41,7 +41,7 @@ class MockAccessControlPlugin : public AccessControl Authentication & auth_plugin, const IdentityHandle& identity, const uint32_t domain_id, - const RTPSParticipantAttributes& participant_attr, + const PropertyPolicy& part_props, SecurityException & exception), (override)); MOCK_METHOD(bool, get_permissions_token, ( @@ -74,7 +74,6 @@ class MockAccessControlPlugin : public AccessControl MOCK_METHOD(bool, check_create_participant, ( const PermissionsHandle& local_handle, const uint32_t domain_id, - const RTPSParticipantAttributes& qos, SecurityException & exception), (override)); MOCK_METHOD(bool, check_remote_participant, ( diff --git a/test/mock/rtps/SecurityPluginFactory/rtps/security/MockAuthenticationPlugin.h b/test/mock/rtps/SecurityPluginFactory/rtps/security/MockAuthenticationPlugin.h index 51c372655c9..23804eb4cda 100644 --- a/test/mock/rtps/SecurityPluginFactory/rtps/security/MockAuthenticationPlugin.h +++ b/test/mock/rtps/SecurityPluginFactory/rtps/security/MockAuthenticationPlugin.h @@ -45,7 +45,7 @@ class MockAuthenticationPlugin : public Authentication MOCK_METHOD(ValidationResult_t, validate_local_identity, (IdentityHandle * *local_identity_handle, GUID_t & adjusted_participant_key, const uint32_t domain_id, - const RTPSParticipantAttributes& participant_attr, + const PropertyPolicy& part_props, const GUID_t& candidate_participant_key, SecurityException & exception), (override)); diff --git a/test/unittest/security/accesscontrol/AccessControlTests.cpp b/test/unittest/security/accesscontrol/AccessControlTests.cpp index ffb1fd3dda3..67e1af80f07 100644 --- a/test/unittest/security/accesscontrol/AccessControlTests.cpp +++ b/test/unittest/security/accesscontrol/AccessControlTests.cpp @@ -167,6 +167,7 @@ void AccessControlTest::get_access_handle( bool should_success) { IdentityHandle* identity_handle = nullptr; + auto part_props = participant_attr.properties; ValidationResult_t result = ValidationResult_t::VALIDATION_FAILED; SecurityException exception; @@ -176,7 +177,7 @@ void AccessControlTest::get_access_handle( &identity_handle, adjusted_participant_key, domain_id, - participant_attr, + part_props, candidate_participant_key, exception); @@ -188,7 +189,7 @@ void AccessControlTest::get_access_handle( authentication_plugin, *identity_handle, domain_id, - participant_attr, + part_props, exception); bool success = *access_handle != nullptr; diff --git a/test/unittest/security/authentication/AuthenticationPluginTests.hpp b/test/unittest/security/authentication/AuthenticationPluginTests.hpp index d129df30f30..cb8ef1639a5 100644 --- a/test/unittest/security/authentication/AuthenticationPluginTests.hpp +++ b/test/unittest/security/authentication/AuthenticationPluginTests.hpp @@ -111,7 +111,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_validation_ok) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -140,7 +140,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_wrong_validation) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -170,7 +170,7 @@ TEST_F(AuthenticationPluginTest, handshake_process_ok) result = plugin.validate_local_identity(&local_identity_handle1, adjusted_participant_key1, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key1, exception); @@ -182,7 +182,7 @@ TEST_F(AuthenticationPluginTest, handshake_process_ok) result = plugin.validate_local_identity(&local_identity_handle2, adjusted_participant_key2, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key2, exception); diff --git a/test/unittest/security/authentication/BuiltinPKIDHTests.cpp b/test/unittest/security/authentication/BuiltinPKIDHTests.cpp index ab0dcc91e31..2ae94de2bb0 100644 --- a/test/unittest/security/authentication/BuiltinPKIDHTests.cpp +++ b/test/unittest/security/authentication/BuiltinPKIDHTests.cpp @@ -444,7 +444,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_kagree_algo) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -500,7 +500,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_validation_ok_with_pwd) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -535,7 +535,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_no_pwd) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -570,7 +570,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_wrong_pwd) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -603,7 +603,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_wrong_identity_ca) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -636,7 +636,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_wrong_identity_certific result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -672,7 +672,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_revoked_certificate) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -705,7 +705,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_revoked_certificate_wit result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); @@ -738,7 +738,7 @@ TEST_F(AuthenticationPluginTest, validate_local_identity_expired_certificate) result = plugin.validate_local_identity(&local_identity_handle, adjusted_participant_key, domain_id, - participant_attr, + participant_attr.properties, candidate_participant_key, exception); From 9e0a882f3c410618e16375588c0f9dfea6e9cf2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Mon, 27 Apr 2026 09:42:49 +0200 Subject: [PATCH 15/26] Refs #23923: Uncrustify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp | 3 ++- src/cpp/rtps/builtin/discovery/participant/PDP.cpp | 3 ++- src/cpp/rtps/reader/StatefulReader.cpp | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index d1f5af1d296..ab17373d4e8 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -755,7 +755,8 @@ void EDPSimple::assignRemoteEndpoints( const NetworkFactory& network = mp_RTPSParticipant->network_factory(); uint32_t endp = pdata.m_available_builtin_endpoints; uint32_t auxendp; - bool use_multicast_locators = !mp_PDP->getRTPSParticipant()->get_const_attributes().builtin.avoid_builtin_multicast || + bool use_multicast_locators = + !mp_PDP->getRTPSParticipant()->get_const_attributes().builtin.avoid_builtin_multicast || pdata.metatraffic_locators.unicast.empty(); auto temp_reader_proxy_data = get_temporary_reader_proxies_pool().get(); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 165c987d485..814e93e0e4c 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -1612,7 +1612,8 @@ static void set_builtin_endpoint_locators( // External locators are always taken from the same place endpoint.external_unicast_locators = pdp->builtin_attributes().metatraffic_external_unicast_locators; - endpoint.ignore_non_matching_locators = pdp->getRTPSParticipant()->get_const_attributes().ignore_non_matching_locators; + endpoint.ignore_non_matching_locators = + pdp->getRTPSParticipant()->get_const_attributes().ignore_non_matching_locators; } ReaderAttributes PDP::create_builtin_reader_attributes() diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 0c577f3c0f0..152719cc09f 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -192,7 +192,8 @@ void StatefulReader::init( { for (size_t n = 0; n < att.matched_writers_allocation.initial; ++n) { - matched_writers_pool_.push_back(new WriterProxy(this, pimpl->get_const_attributes().allocation.locators, proxy_changes_config_)); + matched_writers_pool_.push_back(new WriterProxy(this, pimpl->get_const_attributes().allocation.locators, + proxy_changes_config_)); } } @@ -263,7 +264,8 @@ bool StatefulReader::matched_writer_add_edp( size_t max_readers = matched_writers_pool_.max_size(); if (getMatchedWritersSize() + matched_writers_pool_.size() < max_readers) { - wp = new WriterProxy(this, mp_RTPSParticipant->get_const_attributes().allocation.locators, proxy_changes_config_); + wp = new WriterProxy(this, mp_RTPSParticipant->get_const_attributes().allocation.locators, + proxy_changes_config_); } else { From 5cec6ff14c23b3de0441c6bb6c18fc83df967920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Mon, 27 Apr 2026 09:44:05 +0200 Subject: [PATCH 16/26] Refs #23923: Spelling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- include/fastdds/dds/publisher/DataWriter.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fastdds/dds/publisher/DataWriter.hpp b/include/fastdds/dds/publisher/DataWriter.hpp index a49f345d17c..c8e98a53712 100644 --- a/include/fastdds/dds/publisher/DataWriter.hpp +++ b/include/fastdds/dds/publisher/DataWriter.hpp @@ -485,7 +485,7 @@ class DataWriter : public DomainEntity * * @param [out] subscription_data subscription data struct * @param subscription_handle InstanceHandle_t of the subscription - * @return RETCODE_OK if successfull, RETCODE_BAD_PARAMETER otherwise + * @return RETCODE_OK if successful, RETCODE_BAD_PARAMETER otherwise */ FASTDDS_EXPORTED_API ReturnCode_t get_matched_subscription_data( SubscriptionBuiltinTopicData& subscription_data, @@ -495,7 +495,7 @@ class DataWriter : public DomainEntity * @brief Fills the given vector with the InstanceHandle_t of matched DataReaders * * @param [out] subscription_handles Vector where the InstanceHandle_t are returned - * @return RETCODE_OK if successfull, RETCODE_ERROR otherwise + * @return RETCODE_OK if successful, RETCODE_ERROR otherwise */ FASTDDS_EXPORTED_API ReturnCode_t get_matched_subscriptions( std::vector& subscription_handles) const; From 79fcb595658181220444e5b78207abaaef1b1e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Mon, 27 Apr 2026 14:57:18 +0200 Subject: [PATCH 17/26] Refs #23923: Split const and mutable RTPSParticipantAttributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../attributes/RTPSParticipantAttributes.hpp | 350 ++++++++++++++++++ .../rtps/participant/RTPSParticipant.hpp | 11 +- .../builtin/discovery/participant/PDP.cpp | 8 +- .../discovery/participant/PDPServer.cpp | 2 +- src/cpp/rtps/participant/RTPSParticipant.cpp | 2 +- .../rtps/participant/RTPSParticipantImpl.cpp | 6 +- .../rtps/participant/RTPSParticipantImpl.hpp | 13 +- .../rtps/participant/RTPSParticipant.hpp | 5 +- .../attributes/RTPSParticipantAttributes.hpp | 348 +++++++++++++++++ .../rtps/participant/RTPSParticipantImpl.hpp | 5 +- 10 files changed, 728 insertions(+), 22 deletions(-) diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index 1b806b0bf66..1a4fc815b9a 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -421,6 +421,128 @@ class BuiltinAttributes }; +/** + * Class BuiltinMutableAttributes, to define the behavior of the mutable RTPSParticipant builtin protocols. + * This class is a subset of BuiltinAttributes. It is separated to keep the logic of constant and mutable attributes separated. + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class BuiltinMutableAttributes +{ +public: + + //! Metatraffic Unicast Locator List + LocatorList_t metatrafficUnicastLocatorList; + + //! Metatraffic Multicast Locator List. + LocatorList_t metatrafficMulticastLocatorList; + + //! The collection of external locators to use for communication on metatraffic topics. + fastdds::rtps::ExternalLocators metatraffic_external_unicast_locators; + + BuiltinMutableAttributes() = default; + + BuiltinMutableAttributes( + const BuiltinAttributes& builtin) + : metatrafficUnicastLocatorList(builtin.metatrafficUnicastLocatorList) + , metatrafficMulticastLocatorList(builtin.metatrafficMulticastLocatorList) + , metatraffic_external_unicast_locators(builtin.metatraffic_external_unicast_locators) + { + } + + ~BuiltinMutableAttributes() = default; + + bool operator ==( + const BuiltinMutableAttributes& b) const + { + return (this->metatrafficUnicastLocatorList == b.metatrafficUnicastLocatorList) && + (this->metatrafficMulticastLocatorList == b.metatrafficMulticastLocatorList) && + (this->metatraffic_external_unicast_locators == b.metatraffic_external_unicast_locators); + } + +}; + +/** + * Class BuiltinConstantAttributes, to define the behavior of the constant RTPSParticipant builtin protocols. + * This class is a subset of BuiltinAttributes. It is separated to keep the logic of constant and mutable attributes separated. + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class BuiltinConstantAttributes +{ +public: + + //! Discovery protocol related attributes + DiscoverySettings discovery_config; + + //! Indicates to use the WriterLiveliness protocol. + bool use_WriterLivelinessProtocol = true; + + //! Network Configuration + NetworkConfigSet_t network_configuration = 0; + + //! Initial peers. + LocatorList_t initialPeersList; + + //! Memory policy for builtin readers + MemoryManagementPolicy_t readerHistoryMemoryPolicy = + MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; + + //! Maximum payload size for builtin readers + uint32_t readerPayloadSize = BUILTIN_DATA_MAX_SIZE; + + //! Memory policy for builtin writers + MemoryManagementPolicy_t writerHistoryMemoryPolicy = + MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; + + //! Maximum payload size for builtin writers + uint32_t writerPayloadSize = BUILTIN_DATA_MAX_SIZE; + + //! Mutation tries if the port is being used. + uint32_t mutation_tries = 100u; + + //! Set to true to avoid multicast traffic on builtin endpoints + bool avoid_builtin_multicast = true; + + //! Flow controller name to use for the builtin writers + std::string flow_controller_name = ""; + + BuiltinConstantAttributes() = default; + + BuiltinConstantAttributes( + const BuiltinAttributes& builtin) + : discovery_config(builtin.discovery_config) + , use_WriterLivelinessProtocol(builtin.use_WriterLivelinessProtocol) + , network_configuration(builtin.network_configuration) + , initialPeersList(builtin.initialPeersList) + , readerHistoryMemoryPolicy(builtin.readerHistoryMemoryPolicy) + , readerPayloadSize(builtin.readerPayloadSize) + , writerHistoryMemoryPolicy(builtin.writerHistoryMemoryPolicy) + , writerPayloadSize(builtin.writerPayloadSize) + , mutation_tries(builtin.mutation_tries) + , avoid_builtin_multicast(builtin.avoid_builtin_multicast) + , flow_controller_name(builtin.flow_controller_name) + { + } + + ~BuiltinConstantAttributes() = default; + + bool operator ==( + const BuiltinConstantAttributes& b) const + { + return (this->discovery_config == b.discovery_config) && + (this->use_WriterLivelinessProtocol == b.use_WriterLivelinessProtocol) && + (this->network_configuration == b.network_configuration) && + (this->initialPeersList == b.initialPeersList) && + (this->readerHistoryMemoryPolicy == b.readerHistoryMemoryPolicy) && + (this->readerPayloadSize == b.readerPayloadSize) && + (this->writerHistoryMemoryPolicy == b.writerHistoryMemoryPolicy) && + (this->writerPayloadSize == b.writerPayloadSize) && + (this->mutation_tries == b.mutation_tries) && + (this->flow_controller_name == b.flow_controller_name) && + (this->avoid_builtin_multicast == b.avoid_builtin_multicast); + } + +}; + /** * Class RTPSParticipantAttributes used to define different aspects of a RTPSParticipant. * @ingroup RTPS_ATTRIBUTES_MODULE @@ -597,6 +719,234 @@ class RTPSParticipantAttributes fastcdr::string_255 name{"RTPSParticipant"}; }; +/** + * Class RTPSMutablePartAttributes used to define mutable aspects of a RTPSParticipant. + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class RTPSParticipantMutableAttributes +{ +public: + + RTPSParticipantMutableAttributes() = default; + + RTPSParticipantMutableAttributes( + const RTPSParticipantAttributes& attrs) + : defaultUnicastLocatorList(attrs.defaultUnicastLocatorList) + , default_external_unicast_locators(attrs.default_external_unicast_locators) + , userData(attrs.userData) + , builtin(attrs.builtin) + { + } + + ~RTPSParticipantMutableAttributes() = default; + + bool operator ==( + const RTPSParticipantMutableAttributes& b) const + { + return (this->defaultUnicastLocatorList == b.defaultUnicastLocatorList) && + (this->default_external_unicast_locators == b.default_external_unicast_locators) && + (this->userData == b.userData) && + (this->builtin == b.builtin); + + } + + /** + * Default list of Unicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the case + * that it was defined with NO UnicastLocators. At least ONE locator should be included in this list. + */ + LocatorList_t defaultUnicastLocatorList; + + /** + * The collection of external locators to use for communication on user created topics. + */ + fastdds::rtps::ExternalLocators default_external_unicast_locators; + + //! User Data of the participant + std::vector userData; + + //! Builtin parameters. + BuiltinMutableAttributes builtin; +}; + +/** + * Class RTPSParticipantConstantAttributes used to define constant aspects of a RTPSParticipant. + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class RTPSParticipantConstantAttributes +{ + using FlowControllerDescriptorList = std::vector>; + +public: + + RTPSParticipantConstantAttributes() = default; + + RTPSParticipantConstantAttributes( + const RTPSParticipantAttributes& attrs) + : defaultMulticastLocatorList(attrs.defaultMulticastLocatorList) + , ignore_non_matching_locators(attrs.ignore_non_matching_locators) + , sendSocketBufferSize(attrs.sendSocketBufferSize) + , listenSocketBufferSize(attrs.listenSocketBufferSize) + , netmaskFilter(attrs.netmaskFilter) + , prefix(attrs.prefix) + , builtin(attrs.builtin) + , port(attrs.port) + , participantID(attrs.participantID) + , easy_mode_ip(attrs.easy_mode_ip) + , userTransports(attrs.userTransports) + , useBuiltinTransports(attrs.useBuiltinTransports) + , allocation(attrs.allocation) + , properties(attrs.properties) + , flow_controllers(attrs.flow_controllers) + , builtin_controllers_sender_thread(attrs.builtin_controllers_sender_thread) + , timed_events_thread(attrs.timed_events_thread) + , discovery_server_thread(attrs.discovery_server_thread) + , typelookup_service_thread(attrs.typelookup_service_thread) + , builtin_transports_reception_threads(attrs.builtin_transports_reception_threads) +#if HAVE_SECURITY + , security_log_thread(attrs.security_log_thread) +#endif // if HAVE_SECURITY + , max_msg_size_no_frag(attrs.max_msg_size_no_frag) + , name(attrs.getName()) + { + } + + ~RTPSParticipantConstantAttributes() = default; + + bool operator ==( + const RTPSParticipantConstantAttributes& b) const + { + return (this->defaultMulticastLocatorList == b.defaultMulticastLocatorList) && + (this->ignore_non_matching_locators == b.ignore_non_matching_locators) && + (this->sendSocketBufferSize == b.sendSocketBufferSize) && + (this->listenSocketBufferSize == b.listenSocketBufferSize) && + (this->netmaskFilter == b.netmaskFilter) && + (this->builtin == b.builtin) && + (this->port == b.port) && + (this->participantID == b.participantID) && + (this->easy_mode_ip == b.easy_mode_ip) && + (this->useBuiltinTransports == b.useBuiltinTransports) && + (this->allocation == b.allocation) && + (this->properties == b.properties) && + (this->prefix == b.prefix) && + (this->flow_controllers == b.flow_controllers) && + (this->builtin_controllers_sender_thread == b.builtin_controllers_sender_thread) && + (this->timed_events_thread == b.timed_events_thread) && +#if HAVE_SECURITY + (this->security_log_thread == b.security_log_thread) && +#endif // if HAVE_SECURITY + (this->discovery_server_thread == b.discovery_server_thread) && + (this->typelookup_service_thread == b.typelookup_service_thread) && + (this->builtin_transports_reception_threads == b.builtin_transports_reception_threads); + } + + /** + * Default list of Multicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the + * case that it was defined with NO MulticastLocators. This is usually left empty. + */ + LocatorList_t defaultMulticastLocatorList; + + /** + * Whether locators that don't match with the announced locators should be kept. + */ + bool ignore_non_matching_locators = false; + + /*! + * @brief Send socket buffer size for the send resource. Zero value indicates to use default system buffer size. + * Default value: 0. + */ + uint32_t sendSocketBufferSize = 0; + + /*! Listen socket buffer for all listen resources. Zero value indicates to use default system buffer size. + * Default value: 0. + */ + uint32_t listenSocketBufferSize = 0; + + //! Netmask filter configuration + fastdds::rtps::NetmaskFilterKind netmaskFilter = fastdds::rtps::NetmaskFilterKind::AUTO; + + //! Optionally allows user to define the GuidPrefix_t + GuidPrefix_t prefix; + + inline bool ReadguidPrefix( + const char* pfx) + { + return bool(std::istringstream(pfx) >> prefix); + } + + //! Builtin parameters. + BuiltinConstantAttributes builtin; + + //! Port Parameters + PortParameters port; + + //! Participant ID + int32_t participantID = -1; + + //! IP of the Host where master Server is located (EASY_MODE context) + std::string easy_mode_ip = ""; + + //! User defined transports to use alongside or in place of builtins. + std::vector> userTransports; + + //! Set as false to disable the creation of the default transports. + bool useBuiltinTransports = true; + + //! Holds allocation limits affecting collections managed by a participant. + RTPSParticipantAllocationAttributes allocation; + + //! Property policies + PropertyPolicy properties; + + //! Set the name of the participant. + inline void setName( + const char* nam) + { + name = nam; + } + + //! Get the name of the participant. + inline const char* getName() const + { + return name.c_str(); + } + + //! Flow controllers. + FlowControllerDescriptorList flow_controllers; + + //! Thread settings for the builtin flow controllers sender threads + fastdds::rtps::ThreadSettings builtin_controllers_sender_thread; + + //! Thread settings for the timed events thread + fastdds::rtps::ThreadSettings timed_events_thread; + + //! Thread settings for the discovery server thread + fastdds::rtps::ThreadSettings discovery_server_thread; + + //! Thread settings for the builtin TypeLookup service requests and replies threads + fastdds::rtps::ThreadSettings typelookup_service_thread; + + //! Thread settings for the builtin transports reception threads + fastdds::rtps::ThreadSettings builtin_transports_reception_threads; + +#if HAVE_SECURITY + //! Thread settings for the security log thread + fastdds::rtps::ThreadSettings security_log_thread; +#endif // if HAVE_SECURITY + + /*! Maximum message size used to avoid fragmentation, set ONLY in LARGE_DATA. If this value is + * not zero, the network factory will allow the initialization of UDP transports with maxMessageSize + * higher than 65500K. + */ + uint32_t max_msg_size_no_frag = 0; + +private: + + //! Name of the participant. + fastcdr::string_255 name{"RTPSParticipant"}; + +}; + + } // namespace rtps } // namespace fastdds } // namespace eprosima diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 8b7e6d0e77c..1ba94fc491c 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -238,7 +238,8 @@ class FASTDDS_EXPORTED_API RTPSParticipant * instead to get a thread safe copy of the attributes. * @return RTPSParticipantAttributes reference. */ - FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); const RTPSParticipantAttributes& get_attributes() const; /** @@ -247,14 +248,16 @@ class FASTDDS_EXPORTED_API RTPSParticipant * @warning It must not be used to access mutable attributes as it could return outdated values. * @return A const reference to the RTPSParticipantAttributes of this RTPSParticipantImpl. */ - FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); - const RTPSParticipantAttributes& get_const_attributes() const; + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); + const RTPSParticipantConstantAttributes& get_const_attributes() const; /** * Get a copy of the current state of the RTPSParticipantParameters. * @return RTPSParticipantAttributes copy. */ - FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); RTPSParticipantAttributes copy_attributes() const; /** diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 814e93e0e4c..874238b96e0 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -1517,7 +1517,7 @@ void PDP::resend_ininitial_announcements() void PDP::set_external_participant_properties_( ParticipantProxyData* participant_data) { - const RTPSParticipantAttributes& part_attributes = mp_RTPSParticipant->get_const_attributes(); + const RTPSParticipantConstantAttributes& part_attributes = mp_RTPSParticipant->get_const_attributes(); // For each property add it if it should be sent (it is propagated) for (auto const& property : part_attributes.properties.properties()) @@ -1565,7 +1565,7 @@ void PDP::set_external_participant_properties_( static void set_builtin_matched_allocation( ResourceLimitedContainerConfig& allocation, - const RTPSParticipantAttributes& pattr) + const RTPSParticipantConstantAttributes& pattr) { // Matched endpoints will depend on total number of participants allocation = pattr.allocation.participants; @@ -1620,7 +1620,7 @@ ReaderAttributes PDP::create_builtin_reader_attributes() { ReaderAttributes attributes; - const RTPSParticipantAttributes& pattr = getRTPSParticipant()->get_const_attributes(); + const RTPSParticipantConstantAttributes& pattr = getRTPSParticipant()->get_const_attributes(); set_builtin_matched_allocation(attributes.matched_writers_allocation, pattr); // Builtin endpoints are always reliable, transient local, keyed topics @@ -1644,7 +1644,7 @@ WriterAttributes PDP::create_builtin_writer_attributes() { WriterAttributes attributes; - const RTPSParticipantAttributes& pattr = getRTPSParticipant()->get_const_attributes(); + const RTPSParticipantConstantAttributes& pattr = getRTPSParticipant()->get_const_attributes(); set_builtin_matched_allocation(attributes.matched_readers_allocation, pattr); // Builtin endpoints are always reliable, transient local, keyed topics diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index c5f3114ab9b..be27d5b97f5 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -119,7 +119,7 @@ bool PDPServer::init( getRTPSParticipant()->enableReader(edp->publications_reader_.first); // Initialize server dedicated thread. - const RTPSParticipantAttributes& part_attr = getRTPSParticipant()->get_const_attributes(); + const RTPSParticipantConstantAttributes& part_attr = getRTPSParticipant()->get_const_attributes(); uint32_t id_for_thread = static_cast(part_attr.participantID); const fastdds::rtps::ThreadSettings& thr_config = part_attr.discovery_server_thread; resource_event_thread_.init_thread(thr_config, "dds.ds_ev.%u", id_for_thread); diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index 711cb9da617..bf84e7e613d 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -140,7 +140,7 @@ const RTPSParticipantAttributes& RTPSParticipant::get_attributes() const return mp_impl->get_attributes(); } -const RTPSParticipantAttributes& RTPSParticipant::get_const_attributes() const +const RTPSParticipantConstantAttributes& RTPSParticipant::get_const_attributes() const { return mp_impl->get_const_attributes(); } diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index bfcba11f1a9..04b8b280a6d 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -282,7 +282,7 @@ RTPSParticipantImpl::RTPSParticipantImpl( RTPSParticipantListener* plisten) : domain_id_(domain_id) , m_att(PParam) - , const_m_att(PParam) + , m_const_att(PParam) , m_guid(guidP, c_EntityId_RTPSParticipant) , mp_builtinProtocols(nullptr) , IdCounter(0) @@ -3451,9 +3451,9 @@ const RTPSParticipantAttributes& RTPSParticipantImpl::get_attributes() const return m_att; } -const RTPSParticipantAttributes& RTPSParticipantImpl::get_const_attributes() const +const RTPSParticipantConstantAttributes& RTPSParticipantImpl::get_const_attributes() const { - return const_m_att; + return m_const_att; } RTPSParticipantAttributes RTPSParticipantImpl::copy_attributes() const diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index 67496450cb0..a949d65b8b6 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -615,7 +615,7 @@ class RTPSParticipantImpl //!Attributes of the RTPSParticipant RTPSParticipantAttributes m_att; //!Constant copy of Attributes of the RTPSParticipant - const RTPSParticipantAttributes const_m_att; + const RTPSParticipantConstantAttributes m_const_att; //! Metatraffic unicast port used by default on this participant uint32_t metatraffic_unicast_port_ = 0; //! Default unicast port used by default on this participant @@ -900,7 +900,8 @@ class RTPSParticipantImpl * it is recommended to use copy_attributes() instead. * @return RTPSParticipantAttributes of this RTPSParticipantImpl. */ - FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); const RTPSParticipantAttributes& get_attributes() const; /** @@ -909,14 +910,16 @@ class RTPSParticipantImpl * @warning It must not be used to access mutable attributes as it could return outdated values. * @return A const reference to the RTPSParticipantAttributes of this RTPSParticipantImpl. */ - FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); - const RTPSParticipantAttributes& get_const_attributes() const; + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); + const RTPSParticipantConstantAttributes& get_const_attributes() const; /** * @brief Get a copy of the RTPSParticipantAttributes of this RTPSParticipantImpl in a thread safe manner. * @return A copy of the RTPSParticipantAttributes of this RTPSParticipantImpl. */ - FASTDDS_TODO_BEFORE(4, 0, "Refactor to differentiate mutable and constant objects and make getters thread safe"); + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); RTPSParticipantAttributes copy_attributes() const; /** diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index c9ddcca8fa7..2682d692885 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -232,9 +232,9 @@ class FASTDDS_EXPORTED_API RTPSParticipant return attributes_; } - const RTPSParticipantAttributes& get_const_attributes() const + const RTPSParticipantConstantAttributes& get_const_attributes() const { - return attributes_; + return const_attributes_; } RTPSParticipantAttributes copy_attributes() const @@ -271,6 +271,7 @@ class FASTDDS_EXPORTED_API RTPSParticipant const GUID_t m_guid; mutable ResourceEvent mp_event_thr; RTPSParticipantAttributes attributes_; + RTPSParticipantConstantAttributes const_attributes_; RTPSParticipantImpl* mp_impl; }; diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index cdc86c1aa9a..6181b0184bf 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -409,6 +409,128 @@ class BuiltinAttributes }; +/** + * Class BuiltinMutableAttributes, to define the behavior of the mutable RTPSParticipant builtin protocols. + * This class is a subset of BuiltinAttributes. It is separated to keep the logic of constant and mutable attributes separated. + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class BuiltinMutableAttributes +{ +public: + + //! Metatraffic Unicast Locator List + LocatorList_t metatrafficUnicastLocatorList; + + //! Metatraffic Multicast Locator List. + LocatorList_t metatrafficMulticastLocatorList; + + //! The collection of external locators to use for communication on metatraffic topics. + fastdds::rtps::ExternalLocators metatraffic_external_unicast_locators; + + BuiltinMutableAttributes() = default; + + BuiltinMutableAttributes( + const BuiltinAttributes& builtin) + : metatrafficUnicastLocatorList(builtin.metatrafficUnicastLocatorList) + , metatrafficMulticastLocatorList(builtin.metatrafficMulticastLocatorList) + , metatraffic_external_unicast_locators(builtin.metatraffic_external_unicast_locators) + { + } + + ~BuiltinMutableAttributes() = default; + + bool operator ==( + const BuiltinMutableAttributes& b) const + { + return (this->metatrafficUnicastLocatorList == b.metatrafficUnicastLocatorList) && + (this->metatrafficMulticastLocatorList == b.metatrafficMulticastLocatorList) && + (this->metatraffic_external_unicast_locators == b.metatraffic_external_unicast_locators); + } + +}; + +/** + * Class BuiltinConstantAttributes, to define the behavior of the constant RTPSParticipant builtin protocols. + * This class is a subset of BuiltinAttributes. It is separated to keep the logic of constant and mutable attributes separated. + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class BuiltinConstantAttributes +{ +public: + + //! Discovery protocol related attributes + DiscoverySettings discovery_config; + + //! Indicates to use the WriterLiveliness protocol. + bool use_WriterLivelinessProtocol = true; + + //! Network Configuration + NetworkConfigSet_t network_configuration = 0; + + //! Initial peers. + LocatorList_t initialPeersList; + + //! Memory policy for builtin readers + MemoryManagementPolicy_t readerHistoryMemoryPolicy = + MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; + + //! Maximum payload size for builtin readers + uint32_t readerPayloadSize = BUILTIN_DATA_MAX_SIZE; + + //! Memory policy for builtin writers + MemoryManagementPolicy_t writerHistoryMemoryPolicy = + MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; + + //! Maximum payload size for builtin writers + uint32_t writerPayloadSize = BUILTIN_DATA_MAX_SIZE; + + //! Mutation tries if the port is being used. + uint32_t mutation_tries = 100u; + + //! Set to true to avoid multicast traffic on builtin endpoints + bool avoid_builtin_multicast = true; + + //! Flow controller name to use for the builtin writers + std::string flow_controller_name = ""; + + BuiltinConstantAttributes() = default; + + BuiltinConstantAttributes( + const BuiltinAttributes& builtin) + : discovery_config(builtin.discovery_config) + , use_WriterLivelinessProtocol(builtin.use_WriterLivelinessProtocol) + , network_configuration(builtin.network_configuration) + , initialPeersList(builtin.initialPeersList) + , readerHistoryMemoryPolicy(builtin.readerHistoryMemoryPolicy) + , readerPayloadSize(builtin.readerPayloadSize) + , writerHistoryMemoryPolicy(builtin.writerHistoryMemoryPolicy) + , writerPayloadSize(builtin.writerPayloadSize) + , mutation_tries(builtin.mutation_tries) + , avoid_builtin_multicast(builtin.avoid_builtin_multicast) + , flow_controller_name(builtin.flow_controller_name) + { + } + + ~BuiltinConstantAttributes() = default; + + bool operator ==( + const BuiltinConstantAttributes& b) const + { + return (this->discovery_config == b.discovery_config) && + (this->use_WriterLivelinessProtocol == b.use_WriterLivelinessProtocol) && + (this->network_configuration == b.network_configuration) && + (this->initialPeersList == b.initialPeersList) && + (this->readerHistoryMemoryPolicy == b.readerHistoryMemoryPolicy) && + (this->readerPayloadSize == b.readerPayloadSize) && + (this->writerHistoryMemoryPolicy == b.writerHistoryMemoryPolicy) && + (this->writerPayloadSize == b.writerPayloadSize) && + (this->mutation_tries == b.mutation_tries) && + (this->flow_controller_name == b.flow_controller_name) && + (this->avoid_builtin_multicast == b.avoid_builtin_multicast); + } + +}; + /** * Class RTPSParticipantAttributes used to define different aspects of a RTPSParticipant. * @ingroup RTPS_ATTRIBUTES_MODULE @@ -622,6 +744,232 @@ class RTPSParticipantAttributes fastcdr::string_255 name{"RTPSParticipant"}; }; +/** + * Class RTPSMutablePartAttributes used to define mutable aspects of a RTPSParticipant. + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class RTPSParticipantMutableAttributes +{ +public: + + RTPSParticipantMutableAttributes() = default; + + RTPSParticipantMutableAttributes( + const RTPSParticipantAttributes& attrs) + : defaultUnicastLocatorList(attrs.defaultUnicastLocatorList) + , default_external_unicast_locators(attrs.default_external_unicast_locators) + , userData(attrs.userData) + , builtin(attrs.builtin) + { + } + + ~RTPSParticipantMutableAttributes() = default; + + bool operator ==( + const RTPSParticipantMutableAttributes& b) const + { + return (this->defaultUnicastLocatorList == b.defaultUnicastLocatorList) && + (this->default_external_unicast_locators == b.default_external_unicast_locators) && + (this->userData == b.userData) && + (this->builtin == b.builtin); + } + + /** + * Default list of Unicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the case + * that it was defined with NO UnicastLocators. At least ONE locator should be included in this list. + */ + LocatorList_t defaultUnicastLocatorList; + + /** + * The collection of external locators to use for communication on user created topics. + */ + fastdds::rtps::ExternalLocators default_external_unicast_locators; + + //! User Data of the participant + std::vector userData; + + //! Builtin parameters. + BuiltinMutableAttributes builtin; +}; + +/** + * Class RTPSParticipantConstantAttributes used to define constant aspects of a RTPSParticipant. + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class RTPSParticipantConstantAttributes +{ + using FlowControllerDescriptorList = std::vector>; + +public: + + RTPSParticipantConstantAttributes() = default; + + RTPSParticipantConstantAttributes( + const RTPSParticipantAttributes& attrs) + : defaultMulticastLocatorList(attrs.defaultMulticastLocatorList) + , ignore_non_matching_locators(attrs.ignore_non_matching_locators) + , sendSocketBufferSize(attrs.sendSocketBufferSize) + , listenSocketBufferSize(attrs.listenSocketBufferSize) + , netmaskFilter(attrs.netmaskFilter) + , prefix(attrs.prefix) + , builtin(attrs.builtin) + , port(attrs.port) + , participantID(attrs.participantID) + , easy_mode_ip(attrs.easy_mode_ip) + , userTransports(attrs.userTransports) + , useBuiltinTransports(attrs.useBuiltinTransports) + , allocation(attrs.allocation) + , properties(attrs.properties) + , flow_controllers(attrs.flow_controllers) + , builtin_controllers_sender_thread(attrs.builtin_controllers_sender_thread) + , timed_events_thread(attrs.timed_events_thread) + , discovery_server_thread(attrs.discovery_server_thread) + , typelookup_service_thread(attrs.typelookup_service_thread) + , builtin_transports_reception_threads(attrs.builtin_transports_reception_threads) +#if HAVE_SECURITY + , security_log_thread(attrs.security_log_thread) +#endif // if HAVE_SECURITY + , max_msg_size_no_frag(attrs.max_msg_size_no_frag) + , name(attrs.getName()) + { + } + + ~RTPSParticipantConstantAttributes() = default; + + bool operator ==( + const RTPSParticipantConstantAttributes& b) const + { + return (this->defaultMulticastLocatorList == b.defaultMulticastLocatorList) && + (this->ignore_non_matching_locators == b.ignore_non_matching_locators) && + (this->sendSocketBufferSize == b.sendSocketBufferSize) && + (this->listenSocketBufferSize == b.listenSocketBufferSize) && + (this->netmaskFilter == b.netmaskFilter) && + (this->builtin == b.builtin) && + (this->port == b.port) && + (this->participantID == b.participantID) && + (this->easy_mode_ip == b.easy_mode_ip) && + (this->useBuiltinTransports == b.useBuiltinTransports) && + (this->allocation == b.allocation) && + (this->properties == b.properties) && + (this->prefix == b.prefix) && + (this->flow_controllers == b.flow_controllers) && + (this->builtin_controllers_sender_thread == b.builtin_controllers_sender_thread) && + (this->timed_events_thread == b.timed_events_thread) && +#if HAVE_SECURITY + (this->security_log_thread == b.security_log_thread) && +#endif // if HAVE_SECURITY + (this->discovery_server_thread == b.discovery_server_thread) && + (this->typelookup_service_thread == b.typelookup_service_thread) && + (this->builtin_transports_reception_threads == b.builtin_transports_reception_threads); + } + + /** + * Default list of Multicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the + * case that it was defined with NO MulticastLocators. This is usually left empty. + */ + LocatorList_t defaultMulticastLocatorList; + + /** + * Whether locators that don't match with the announced locators should be kept. + */ + bool ignore_non_matching_locators = false; + + /*! + * @brief Send socket buffer size for the send resource. Zero value indicates to use default system buffer size. + * Default value: 0. + */ + uint32_t sendSocketBufferSize = 0; + + /*! Listen socket buffer for all listen resources. Zero value indicates to use default system buffer size. + * Default value: 0. + */ + uint32_t listenSocketBufferSize = 0; + + //! Netmask filter configuration + fastdds::rtps::NetmaskFilterKind netmaskFilter = fastdds::rtps::NetmaskFilterKind::AUTO; + + //! Optionally allows user to define the GuidPrefix_t + GuidPrefix_t prefix; + + inline bool ReadguidPrefix( + const char* pfx) + { + return bool(std::istringstream(pfx) >> prefix); + } + + //! Builtin parameters. + BuiltinConstantAttributes builtin; + + //! Port Parameters + PortParameters port; + + //! Participant ID + int32_t participantID = -1; + + //! IP of the Host where master Server is located (EASY_MODE context) + std::string easy_mode_ip = ""; + + //! User defined transports to use alongside or in place of builtins. + std::vector> userTransports; + + //! Set as false to disable the creation of the default transports. + bool useBuiltinTransports = true; + + //! Holds allocation limits affecting collections managed by a participant. + RTPSParticipantAllocationAttributes allocation; + + //! Property policies + PropertyPolicy properties; + + //! Set the name of the participant. + inline void setName( + const char* nam) + { + name = nam; + } + + //! Get the name of the participant. + inline const char* getName() const + { + return name.c_str(); + } + + //! Flow controllers. + FlowControllerDescriptorList flow_controllers; + + //! Thread settings for the builtin flow controllers sender threads + fastdds::rtps::ThreadSettings builtin_controllers_sender_thread; + + //! Thread settings for the timed events thread + fastdds::rtps::ThreadSettings timed_events_thread; + + //! Thread settings for the discovery server thread + fastdds::rtps::ThreadSettings discovery_server_thread; + + //! Thread settings for the builtin TypeLookup service requests and replies threads + fastdds::rtps::ThreadSettings typelookup_service_thread; + + //! Thread settings for the builtin transports reception threads + fastdds::rtps::ThreadSettings builtin_transports_reception_threads; + +#if HAVE_SECURITY + //! Thread settings for the security log thread + fastdds::rtps::ThreadSettings security_log_thread; +#endif // if HAVE_SECURITY + + /*! Maximum message size used to avoid fragmentation, set ONLY in LARGE_DATA. If this value is + * not zero, the network factory will allow the initialization of UDP transports with maxMessageSize + * higher than 65500K. + */ + uint32_t max_msg_size_no_frag = 0; + +private: + + //! Name of the participant. + fastcdr::string_255 name{"RTPSParticipant"}; + +}; + } // namespace rtps } // namespace fastdds } // namespace eprosima diff --git a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp index 5d748f9a5e1..7634038cf22 100644 --- a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp +++ b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp @@ -332,9 +332,9 @@ class RTPSParticipantImpl return attr_; } - const RTPSParticipantAttributes& get_const_attributes() const + const RTPSParticipantConstantAttributes& get_const_attributes() const { - return attr_; + return const_attr_; } RTPSParticipantAttributes copy_attributes() const @@ -470,6 +470,7 @@ class RTPSParticipantImpl MockParticipantListener listener_; RTPSParticipantAttributes attr_; + RTPSParticipantConstantAttributes const_attr_; NetworkFactory network_factory_ {attr_}; From 926c9e6fd62a16351c543fcb59036f7db46f3ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Tue, 28 Apr 2026 11:44:59 +0200 Subject: [PATCH 18/26] Refs #23923: Review - Fix Mutable & Constant attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../attributes/RTPSParticipantAttributes.hpp | 61 +++++++++++++------ .../rtps/participant/RTPSParticipant.hpp | 27 +++++--- src/cpp/rtps/participant/RTPSParticipant.cpp | 5 ++ .../rtps/participant/RTPSParticipantImpl.cpp | 13 ++-- .../rtps/participant/RTPSParticipantImpl.hpp | 29 ++++++--- src/cpp/rtps/reader/BaseReader.cpp | 2 +- 6 files changed, 98 insertions(+), 39 deletions(-) diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index 1a4fc815b9a..3f15077ba4f 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -344,6 +344,33 @@ class DiscoverySettings std::string static_edp_xml_config_ = ""; }; +/** + * Class MutableDiscoverySettings, to define the mutable attributes of the several discovery protocols available + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class MutableDiscoverySettings +{ +public: + + //! Discovery Server initial connections, needed if `discoveryProtocol` = CLIENT | SUPER_CLIENT | SERVER | BACKUP + eprosima::fastdds::rtps::LocatorList m_DiscoveryServers; + + MutableDiscoverySettings() = default; + + MutableDiscoverySettings( + const DiscoverySettings& discovery_settings) + : m_DiscoveryServers(discovery_settings.m_DiscoveryServers) + { + } + + bool operator ==( + const MutableDiscoverySettings& b) const + { + return (this->m_DiscoveryServers == b.m_DiscoveryServers); + } + +}; + /** * Class BuiltinAttributes, to define the behavior of the RTPSParticipant builtin protocols. * @ingroup RTPS_ATTRIBUTES_MODULE @@ -430,12 +457,12 @@ class BuiltinMutableAttributes { public: + //! Discovery protocol related attributes + MutableDiscoverySettings discovery_config; + //! Metatraffic Unicast Locator List LocatorList_t metatrafficUnicastLocatorList; - //! Metatraffic Multicast Locator List. - LocatorList_t metatrafficMulticastLocatorList; - //! The collection of external locators to use for communication on metatraffic topics. fastdds::rtps::ExternalLocators metatraffic_external_unicast_locators; @@ -443,8 +470,8 @@ class BuiltinMutableAttributes BuiltinMutableAttributes( const BuiltinAttributes& builtin) - : metatrafficUnicastLocatorList(builtin.metatrafficUnicastLocatorList) - , metatrafficMulticastLocatorList(builtin.metatrafficMulticastLocatorList) + : discovery_config(builtin.discovery_config) + , metatrafficUnicastLocatorList(builtin.metatrafficUnicastLocatorList) , metatraffic_external_unicast_locators(builtin.metatraffic_external_unicast_locators) { } @@ -454,8 +481,8 @@ class BuiltinMutableAttributes bool operator ==( const BuiltinMutableAttributes& b) const { - return (this->metatrafficUnicastLocatorList == b.metatrafficUnicastLocatorList) && - (this->metatrafficMulticastLocatorList == b.metatrafficMulticastLocatorList) && + return (this->discovery_config == b.discovery_config) && + (this->metatrafficUnicastLocatorList == b.metatrafficUnicastLocatorList) && (this->metatraffic_external_unicast_locators == b.metatraffic_external_unicast_locators); } @@ -470,7 +497,10 @@ class BuiltinConstantAttributes { public: - //! Discovery protocol related attributes + /** + * Discovery protocol related attributes. Only the discovery server list is mutable, which must be + * accessed through the BuiltinMutableAttributes class. Its value in this class is only used as initial value. + */ DiscoverySettings discovery_config; //! Indicates to use the WriterLiveliness protocol. @@ -479,6 +509,9 @@ class BuiltinConstantAttributes //! Network Configuration NetworkConfigSet_t network_configuration = 0; + //! Metatraffic Multicast Locator List + LocatorList_t metatrafficMulticastLocatorList; + //! Initial peers. LocatorList_t initialPeersList; @@ -512,6 +545,7 @@ class BuiltinConstantAttributes : discovery_config(builtin.discovery_config) , use_WriterLivelinessProtocol(builtin.use_WriterLivelinessProtocol) , network_configuration(builtin.network_configuration) + , metatrafficMulticastLocatorList(builtin.metatrafficMulticastLocatorList) , initialPeersList(builtin.initialPeersList) , readerHistoryMemoryPolicy(builtin.readerHistoryMemoryPolicy) , readerPayloadSize(builtin.readerPayloadSize) @@ -531,6 +565,7 @@ class BuiltinConstantAttributes return (this->discovery_config == b.discovery_config) && (this->use_WriterLivelinessProtocol == b.use_WriterLivelinessProtocol) && (this->network_configuration == b.network_configuration) && + (this->metatrafficMulticastLocatorList == b.metatrafficMulticastLocatorList) && (this->initialPeersList == b.initialPeersList) && (this->readerHistoryMemoryPolicy == b.readerHistoryMemoryPolicy) && (this->readerPayloadSize == b.readerPayloadSize) && @@ -720,7 +755,7 @@ class RTPSParticipantAttributes }; /** - * Class RTPSMutablePartAttributes used to define mutable aspects of a RTPSParticipant. + * Class RTPSParticipantMutableAttributes used to define mutable aspects of a RTPSParticipant. * @ingroup RTPS_ATTRIBUTES_MODULE */ class RTPSParticipantMutableAttributes @@ -747,7 +782,6 @@ class RTPSParticipantMutableAttributes (this->default_external_unicast_locators == b.default_external_unicast_locators) && (this->userData == b.userData) && (this->builtin == b.builtin); - } /** @@ -897,13 +931,6 @@ class RTPSParticipantConstantAttributes //! Property policies PropertyPolicy properties; - //! Set the name of the participant. - inline void setName( - const char* nam) - { - name = nam; - } - //! Get the name of the participant. inline const char* getName() const { diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 1ba94fc491c..855f60185ba 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -232,32 +232,41 @@ class FASTDDS_EXPORTED_API RTPSParticipant */ std::vector getParticipantNames() const; + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** - * Get a reference of the current state of the RTPSParticipantParameters. + * Get a reference of the current state of the RTPSParticipantAttributes. * @warning The returned reference is not thread safe. It is recommended to use copy_attributes() * instead to get a thread safe copy of the attributes. * @return RTPSParticipantAttributes reference. */ - FASTDDS_TODO_BEFORE(4, 0, - "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); const RTPSParticipantAttributes& get_attributes() const; + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** - * @brief Get a const reference of the constant RTPSParticipantAttributes of this RTPSParticipantImpl. + * @brief Get a const reference of RTPSParticipantConstantAttributes of this RTPSParticipantImpl. * This method is thread safe because it returns a const reference to the internal attributes. * @warning It must not be used to access mutable attributes as it could return outdated values. - * @return A const reference to the RTPSParticipantAttributes of this RTPSParticipantImpl. + * @return A const reference to the RTPSParticipantConstantAttributes of this RTPSParticipantImpl. */ - FASTDDS_TODO_BEFORE(4, 0, - "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); const RTPSParticipantConstantAttributes& get_const_attributes() const; + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** - * Get a copy of the current state of the RTPSParticipantParameters. - * @return RTPSParticipantAttributes copy. + * @brief Get a const copy of RTPSParticipantMutableAttributes of this RTPSParticipantImpl. + * This method is thread safe because it returns a const copy of the internal attributes. + * @return A const copy of the RTPSParticipantMutableAttributes of this RTPSParticipantImpl. */ + const RTPSParticipantMutableAttributes get_mutable_attributes() const; + FASTDDS_TODO_BEFORE(4, 0, "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); + /** + * Get a copy of the current state of the RTPSParticipantAttributes. + * @return RTPSParticipantAttributes copy. + */ RTPSParticipantAttributes copy_attributes() const; /** diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index bf84e7e613d..923f137dbdb 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -145,6 +145,11 @@ const RTPSParticipantConstantAttributes& RTPSParticipant::get_const_attributes() return mp_impl->get_const_attributes(); } +const RTPSParticipantMutableAttributes RTPSParticipant::get_mutable_attributes() const +{ + return mp_impl->get_mutable_attributes(); +} + RTPSParticipantAttributes RTPSParticipant::copy_attributes() const { return mp_impl->copy_attributes(); diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 04b8b280a6d..1f60d2eab36 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1686,12 +1686,12 @@ void RTPSParticipantImpl::update_mutable_attributes( const RTPSParticipantAttributes& patt) { // NTS - m_att.userData = patt.userData; - m_att.builtin.metatrafficUnicastLocatorList = patt.builtin.metatrafficUnicastLocatorList; - m_att.defaultUnicastLocatorList = patt.defaultUnicastLocatorList; - m_att.default_external_unicast_locators = patt.default_external_unicast_locators; m_att.builtin.discovery_config.m_DiscoveryServers = patt.builtin.discovery_config.m_DiscoveryServers; m_att.builtin.metatraffic_external_unicast_locators = patt.builtin.metatraffic_external_unicast_locators; + m_att.builtin.metatrafficUnicastLocatorList = patt.builtin.metatrafficUnicastLocatorList; + m_att.default_external_unicast_locators = patt.default_external_unicast_locators; + m_att.defaultUnicastLocatorList = patt.defaultUnicastLocatorList; + m_att.userData = patt.userData; } bool RTPSParticipantImpl::update_writer( @@ -3456,6 +3456,11 @@ const RTPSParticipantConstantAttributes& RTPSParticipantImpl::get_const_attribut return m_const_att; } +const RTPSParticipantMutableAttributes RTPSParticipantImpl::get_mutable_attributes() const +{ + return RTPSParticipantMutableAttributes(m_att); +} + RTPSParticipantAttributes RTPSParticipantImpl::copy_attributes() const { std::lock_guard _(mutex_); diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index a949d65b8b6..630cb4d0f7d 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -895,31 +895,40 @@ class RTPSParticipantImpl public: + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** * @brief Get the RTPSParticipantAttributes of this RTPSParticipantImpl. This method is not thread safe, * it is recommended to use copy_attributes() instead. * @return RTPSParticipantAttributes of this RTPSParticipantImpl. */ - FASTDDS_TODO_BEFORE(4, 0, - "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); const RTPSParticipantAttributes& get_attributes() const; + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** - * @brief Get a const reference of the constant RTPSParticipantAttributes of this RTPSParticipantImpl. + * @brief Get a const reference of RTPSParticipantConstantAttributes of this RTPSParticipantImpl. * This method is thread safe because it returns a const reference to the internal attributes. - * @warning It must not be used to access mutable attributes as it could return outdated values. - * @return A const reference to the RTPSParticipantAttributes of this RTPSParticipantImpl. + * @warning It must not be used to access mutable attributes as it could return outdated values. Use get_mutable_attributes instead. + * @return A const reference to the RTPSParticipantConstantAttributes of this RTPSParticipantImpl. */ + const RTPSParticipantConstantAttributes& get_const_attributes() const; + FASTDDS_TODO_BEFORE(4, 0, "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); - const RTPSParticipantConstantAttributes& get_const_attributes() const; + /** + * @brief Get a const copy of RTPSParticipantMutableAttributes of this RTPSParticipantImpl. + * This method is thread safe because it returns a const copy of the internal attributes. + * @return A const copy of the RTPSParticipantMutableAttributes of this RTPSParticipantImpl. + */ + const RTPSParticipantMutableAttributes get_mutable_attributes() const; + FASTDDS_TODO_BEFORE(4, 0, + "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** * @brief Get a copy of the RTPSParticipantAttributes of this RTPSParticipantImpl in a thread safe manner. * @return A copy of the RTPSParticipantAttributes of this RTPSParticipantImpl. */ - FASTDDS_TODO_BEFORE(4, 0, - "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); RTPSParticipantAttributes copy_attributes() const; /** @@ -1080,6 +1089,10 @@ class RTPSParticipantImpl void update_attributes( const RTPSParticipantAttributes& patt); + /** + * Update only mutable participant attributes. + * @param patt New participant attributes. + */ void update_mutable_attributes( const RTPSParticipantAttributes& patt); diff --git a/src/cpp/rtps/reader/BaseReader.cpp b/src/cpp/rtps/reader/BaseReader.cpp index 7d3d434db9a..b657f7a1703 100644 --- a/src/cpp/rtps/reader/BaseReader.cpp +++ b/src/cpp/rtps/reader/BaseReader.cpp @@ -133,7 +133,7 @@ BaseReader::~BaseReader() bool BaseReader::matched_writer_add( const PublicationBuiltinTopicData& info) { - auto alloc = mp_RTPSParticipant->get_const_attributes().allocation; + const auto& alloc = mp_RTPSParticipant->get_const_attributes().allocation; WriterProxyData wdata(alloc.data_limits, info); return matched_writer_add_edp(wdata); From e3e065fa12adfc5e81a9fa408975f15a72545e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Tue, 28 Apr 2026 11:45:31 +0200 Subject: [PATCH 19/26] Refs #23923: Review - Apply methods and composition of BuiltinAttributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../attributes/RTPSParticipantAttributes.hpp | 36 +++++++++++++++ .../builtin/discovery/participant/PDP.cpp | 45 +++++++++++-------- .../discovery/participant/PDPListener.cpp | 20 +++++---- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index 3f15077ba4f..ca086cb617f 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -371,6 +371,10 @@ class MutableDiscoverySettings }; +// Forward declaration to allow assignment from Constant and Mutable attributes. +class BuiltinConstantAttributes; +class BuiltinMutableAttributes; + /** * Class BuiltinAttributes, to define the behavior of the RTPSParticipant builtin protocols. * @ingroup RTPS_ATTRIBUTES_MODULE @@ -427,6 +431,17 @@ class BuiltinAttributes virtual ~BuiltinAttributes() = default; + /** + * Composes this object from a BuiltinConstantAttributes and a BuiltinMutableAttributes. + * Every field is assigned: constant fields are taken from @c builtin_const, mutable fields + * are taken from @c builtin_mutable. + * @param builtin_const Constant builtin attributes to copy from. + * @param builtin_mutable Mutable builtin attributes to copy from. + */ + void compose( + const BuiltinConstantAttributes& builtin_const, + const BuiltinMutableAttributes& builtin_mutable); + bool operator ==( const BuiltinAttributes& b) const { @@ -578,6 +593,27 @@ class BuiltinConstantAttributes }; +inline void BuiltinAttributes::compose( + const BuiltinConstantAttributes& builtin_const, + const BuiltinMutableAttributes& builtin_mutable) +{ + discovery_config = builtin_const.discovery_config; + discovery_config.m_DiscoveryServers = builtin_mutable.discovery_config.m_DiscoveryServers; + use_WriterLivelinessProtocol = builtin_const.use_WriterLivelinessProtocol; + network_configuration = builtin_const.network_configuration; + metatrafficUnicastLocatorList = builtin_mutable.metatrafficUnicastLocatorList; + metatrafficMulticastLocatorList = builtin_const.metatrafficMulticastLocatorList; + metatraffic_external_unicast_locators = builtin_mutable.metatraffic_external_unicast_locators; + initialPeersList = builtin_const.initialPeersList; + readerHistoryMemoryPolicy = builtin_const.readerHistoryMemoryPolicy; + readerPayloadSize = builtin_const.readerPayloadSize; + writerHistoryMemoryPolicy = builtin_const.writerHistoryMemoryPolicy; + writerPayloadSize = builtin_const.writerPayloadSize; + mutation_tries = builtin_const.mutation_tries; + avoid_builtin_multicast = builtin_const.avoid_builtin_multicast; + flow_controller_name = builtin_const.flow_controller_name; +} + /** * Class RTPSParticipantAttributes used to define different aspects of a RTPSParticipant. * @ingroup RTPS_ATTRIBUTES_MODULE diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 874238b96e0..057be022d71 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -306,12 +306,13 @@ std::string PDP::check_participant_type( void PDP::initializeParticipantProxyData( ParticipantProxyData* participant_data) { - RTPSParticipantAttributes attributes = mp_RTPSParticipant->copy_attributes(); + RTPSParticipantMutableAttributes mutable_attrs = mp_RTPSParticipant->get_mutable_attributes(); bool announce_locators = !mp_RTPSParticipant->is_intraprocess_only(); from_guid_prefix_to_topic_key(participant_data->guid.guidPrefix, participant_data->key.value); participant_data->domain_id = mp_RTPSParticipant->get_domain_id(); - participant_data->lease_duration = attributes.builtin.discovery_config.leaseDuration; + participant_data->lease_duration = + mp_RTPSParticipant->get_const_attributes().builtin.discovery_config.leaseDuration; //set_VendorId_eProsima(participant_data->m_VendorId); participant_data->vendor_id = c_VendorId_eProsima; participant_data->product_version.major = FASTDDS_VERSION_MAJOR; @@ -324,7 +325,7 @@ void PDP::initializeParticipantProxyData( participant_data->m_available_builtin_endpoints |= builtin_endpoints_->builtin_endpoints(); - if (attributes.builtin.use_WriterLivelinessProtocol) + if (mp_RTPSParticipant->get_const_attributes().builtin.use_WriterLivelinessProtocol) { participant_data->m_available_builtin_endpoints |= fastdds::rtps::BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_WRITER; @@ -370,13 +371,14 @@ void PDP::initializeParticipantProxyData( if (announce_locators) { - participant_data->m_network_configuration = attributes.builtin.network_configuration; + participant_data->m_network_configuration = + mp_RTPSParticipant->get_const_attributes().builtin.network_configuration; - for (const Locator_t& loc : attributes.defaultUnicastLocatorList) + for (const Locator_t& loc : mutable_attrs.defaultUnicastLocatorList) { participant_data->default_locators.add_unicast_locator(loc); } - for (const Locator_t& loc : attributes.defaultMulticastLocatorList) + for (const Locator_t& loc : mp_RTPSParticipant->get_const_attributes().defaultMulticastLocatorList) { participant_data->default_locators.add_multicast_locator(loc); } @@ -394,7 +396,7 @@ void PDP::initializeParticipantProxyData( // If it has not been set, use guid if (persistent == c_GuidPrefix_Unknown) { - persistent = attributes.prefix; + persistent = mp_RTPSParticipant->get_const_attributes().prefix; } // If persistent is set, set it into the participant proxy @@ -428,13 +430,13 @@ void PDP::initializeParticipantProxyData( } fastdds::rtps::network::external_locators::add_external_locators(*participant_data, - attributes.builtin.metatraffic_external_unicast_locators, - attributes.default_external_unicast_locators); + mutable_attrs.builtin.metatraffic_external_unicast_locators, + mutable_attrs.default_external_unicast_locators); } - participant_data->participant_name = std::string(attributes.getName()); + participant_data->participant_name = std::string(mp_RTPSParticipant->get_const_attributes().getName()); - participant_data->user_data = attributes.userData; + participant_data->user_data = mutable_attrs.userData; #if HAVE_SECURITY if (mp_RTPSParticipant->is_secure()) @@ -471,13 +473,17 @@ void PDP::initializeParticipantProxyData( // Fill wire_protocol qos participant_data->wire_protocol = dds::WireProtocolConfigQos(); participant_data->wire_protocol->prefix = participant_data->guid.guidPrefix; - participant_data->wire_protocol->participant_id = attributes.participantID; - participant_data->wire_protocol->builtin = attributes.builtin; - participant_data->wire_protocol->port = attributes.port; - participant_data->wire_protocol->default_unicast_locator_list = attributes.defaultUnicastLocatorList; - participant_data->wire_protocol->default_multicast_locator_list = attributes.defaultMulticastLocatorList; - participant_data->wire_protocol->default_external_unicast_locators = attributes.default_external_unicast_locators; - participant_data->wire_protocol->ignore_non_matching_locators = attributes.ignore_non_matching_locators; + participant_data->wire_protocol->participant_id = mp_RTPSParticipant->get_const_attributes().participantID; + participant_data->wire_protocol->builtin.compose(mp_RTPSParticipant->get_const_attributes().builtin, + mutable_attrs.builtin); + participant_data->wire_protocol->port = mp_RTPSParticipant->get_const_attributes().port; + participant_data->wire_protocol->default_unicast_locator_list = mutable_attrs.defaultUnicastLocatorList; + participant_data->wire_protocol->default_multicast_locator_list = + mp_RTPSParticipant->get_const_attributes().defaultMulticastLocatorList; + participant_data->wire_protocol->default_external_unicast_locators = + mutable_attrs.default_external_unicast_locators; + participant_data->wire_protocol->ignore_non_matching_locators = + mp_RTPSParticipant->get_const_attributes().ignore_non_matching_locators; participant_data->should_send_optional_qos(mp_RTPSParticipant->should_send_optional_qos()); } @@ -487,7 +493,8 @@ bool PDP::initPDP( { EPROSIMA_LOG_INFO(RTPS_PDP, "Beginning"); mp_RTPSParticipant = part; - initial_announcements_ = mp_RTPSParticipant->get_const_attributes().builtin.discovery_config.initial_announcements; + m_discovery = mp_RTPSParticipant->copy_attributes().builtin; + initial_announcements_ = m_discovery.discovery_config.initial_announcements; //CREATE ENDPOINTS if (!createPDPEndpoints()) { diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index bdd2b588e6f..70be0165018 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -76,10 +76,11 @@ void PDPListener::on_new_cache_change_added( GUID_t guid; iHandle2GUID(guid, change->instanceHandle); + RTPSParticipantImpl* part = parent_pdp_->getRTPSParticipant(); if (change->kind == ALIVE) { // Ignore announcement from own RTPSParticipant - if (guid == parent_pdp_->getRTPSParticipant()->getGuid()) + if (guid == part->getGuid()) { EPROSIMA_LOG_INFO(RTPS_PDP, "Message from own RTPSParticipant, removing"); parent_pdp_->builtin_endpoints_->remove_from_pdp_reader_history(change); @@ -105,14 +106,14 @@ void PDPListener::on_new_cache_change_added( CDRMessage_t msg(change->serializedPayload); temp_participant_data_.clear(); if (temp_participant_data_.read_from_cdr_message(&msg, true, - parent_pdp_->getRTPSParticipant()->network_factory(), + part->network_factory(), true, change_in->vendor_id)) { // After correctly reading it change->instanceHandle = temp_participant_data_.m_key; guid = temp_participant_data_.guid; - if (parent_pdp_->getRTPSParticipant()->is_participant_ignored(guid.guidPrefix)) + if (part->is_participant_ignored(guid.guidPrefix)) { return; } @@ -123,10 +124,11 @@ void PDPListener::on_new_cache_change_added( } // Filter locators - auto pattr = parent_pdp_->getRTPSParticipant()->copy_attributes(); + auto mutable_pattr = part->get_mutable_attributes(); fastdds::rtps::network::external_locators::filter_remote_locators(temp_participant_data_, - pattr.builtin.metatraffic_external_unicast_locators, pattr.default_external_unicast_locators, - pattr.ignore_non_matching_locators); + mutable_pattr.builtin.metatraffic_external_unicast_locators, + mutable_pattr.default_external_unicast_locators, + part->get_const_attributes().ignore_non_matching_locators); // Check if participant already exists (updated info) ParticipantProxyData* pdata = nullptr; @@ -167,10 +169,10 @@ void PDPListener::on_new_cache_change_added( #ifdef FASTDDS_STATISTICS //! Removal of a participant proxy should trigger //! a connections update on the local participant connection list - if (nullptr != parent_pdp_->getRTPSParticipant()->get_connections_observer()) + if (nullptr != part->get_connections_observer()) { - parent_pdp_->getRTPSParticipant()->get_connections_observer()->on_local_entity_connections_change( - parent_pdp_->getRTPSParticipant()->getGuid()); + part->get_connections_observer()->on_local_entity_connections_change( + part->getGuid()); } #endif //FASTDDS_STATISTICS reader->getMutex().lock(); From ba66dbb1be2131966d501501d31941aaef5f3aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Tue, 28 Apr 2026 11:45:42 +0200 Subject: [PATCH 20/26] Refs #23923: Review - Update Tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../rtps/participant/RTPSParticipant.hpp | 5 ++ .../attributes/RTPSParticipantAttributes.hpp | 88 +++++++++++++++++-- .../rtps/participant/RTPSParticipantImpl.hpp | 5 ++ 3 files changed, 89 insertions(+), 9 deletions(-) diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index 2682d692885..8ea5d98ea2b 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -237,6 +237,11 @@ class FASTDDS_EXPORTED_API RTPSParticipant return const_attributes_; } + const RTPSParticipantMutableAttributes get_mutable_attributes() const + { + return RTPSParticipantMutableAttributes{attributes_}; + } + RTPSParticipantAttributes copy_attributes() const { return attributes_; diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index 6181b0184bf..fe4c115056f 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -332,6 +332,37 @@ class DiscoverySettings std::string static_edp_xml_config_ = ""; }; +/** + * Class MutableDiscoverySettings, to define the mutable attributes of the several discovery protocols available + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class MutableDiscoverySettings +{ +public: + + //! Discovery Server initial connections, needed if `discoveryProtocol` = CLIENT | SUPER_CLIENT | SERVER | BACKUP + eprosima::fastdds::rtps::LocatorList m_DiscoveryServers; + + MutableDiscoverySettings() = default; + + MutableDiscoverySettings( + const DiscoverySettings& discovery_settings) + : m_DiscoveryServers(discovery_settings.m_DiscoveryServers) + { + } + + bool operator ==( + const MutableDiscoverySettings& b) const + { + return (this->m_DiscoveryServers == b.m_DiscoveryServers); + } + +}; + +// Forward declaration to allow assignment from Constant and Mutable attributes. +class BuiltinConstantAttributes; +class BuiltinMutableAttributes; + /** * Class BuiltinAttributes, to define the behavior of the RTPSParticipant builtin protocols. * @ingroup RTPS_ATTRIBUTES_MODULE @@ -388,6 +419,17 @@ class BuiltinAttributes virtual ~BuiltinAttributes() = default; + /** + * Composes this object from a BuiltinConstantAttributes and a BuiltinMutableAttributes. + * Every field is assigned: constant fields are taken from @c builtin_const, mutable fields + * are taken from @c builtin_mutable. + * @param builtin_const Constant builtin attributes to copy from. + * @param builtin_mutable Mutable builtin attributes to copy from. + */ + void compose( + const BuiltinConstantAttributes& builtin_const, + const BuiltinMutableAttributes& builtin_mutable); + bool operator ==( const BuiltinAttributes& b) const { @@ -418,12 +460,12 @@ class BuiltinMutableAttributes { public: + //! Discovery protocol related attributes + MutableDiscoverySettings discovery_config; + //! Metatraffic Unicast Locator List LocatorList_t metatrafficUnicastLocatorList; - //! Metatraffic Multicast Locator List. - LocatorList_t metatrafficMulticastLocatorList; - //! The collection of external locators to use for communication on metatraffic topics. fastdds::rtps::ExternalLocators metatraffic_external_unicast_locators; @@ -431,8 +473,8 @@ class BuiltinMutableAttributes BuiltinMutableAttributes( const BuiltinAttributes& builtin) - : metatrafficUnicastLocatorList(builtin.metatrafficUnicastLocatorList) - , metatrafficMulticastLocatorList(builtin.metatrafficMulticastLocatorList) + : discovery_config(builtin.discovery_config) + , metatrafficUnicastLocatorList(builtin.metatrafficUnicastLocatorList) , metatraffic_external_unicast_locators(builtin.metatraffic_external_unicast_locators) { } @@ -442,8 +484,8 @@ class BuiltinMutableAttributes bool operator ==( const BuiltinMutableAttributes& b) const { - return (this->metatrafficUnicastLocatorList == b.metatrafficUnicastLocatorList) && - (this->metatrafficMulticastLocatorList == b.metatrafficMulticastLocatorList) && + return (this->discovery_config == b.discovery_config) && + (this->metatrafficUnicastLocatorList == b.metatrafficUnicastLocatorList) && (this->metatraffic_external_unicast_locators == b.metatraffic_external_unicast_locators); } @@ -458,7 +500,10 @@ class BuiltinConstantAttributes { public: - //! Discovery protocol related attributes + /** + * Discovery protocol related attributes. Only the discovery server list is mutable, which must be + * accessed through the BuiltinMutableAttributes class. Its value in this class is only used as initial value. + */ DiscoverySettings discovery_config; //! Indicates to use the WriterLiveliness protocol. @@ -467,6 +512,9 @@ class BuiltinConstantAttributes //! Network Configuration NetworkConfigSet_t network_configuration = 0; + //! Metatraffic Multicast Locator List + LocatorList_t metatrafficMulticastLocatorList; + //! Initial peers. LocatorList_t initialPeersList; @@ -500,6 +548,7 @@ class BuiltinConstantAttributes : discovery_config(builtin.discovery_config) , use_WriterLivelinessProtocol(builtin.use_WriterLivelinessProtocol) , network_configuration(builtin.network_configuration) + , metatrafficMulticastLocatorList(builtin.metatrafficMulticastLocatorList) , initialPeersList(builtin.initialPeersList) , readerHistoryMemoryPolicy(builtin.readerHistoryMemoryPolicy) , readerPayloadSize(builtin.readerPayloadSize) @@ -519,6 +568,7 @@ class BuiltinConstantAttributes return (this->discovery_config == b.discovery_config) && (this->use_WriterLivelinessProtocol == b.use_WriterLivelinessProtocol) && (this->network_configuration == b.network_configuration) && + (this->metatrafficMulticastLocatorList == b.metatrafficMulticastLocatorList) && (this->initialPeersList == b.initialPeersList) && (this->readerHistoryMemoryPolicy == b.readerHistoryMemoryPolicy) && (this->readerPayloadSize == b.readerPayloadSize) && @@ -530,6 +580,26 @@ class BuiltinConstantAttributes } }; +inline void BuiltinAttributes::compose( + const BuiltinConstantAttributes& builtin_const, + const BuiltinMutableAttributes& builtin_mutable) +{ + discovery_config = builtin_const.discovery_config; + discovery_config.m_DiscoveryServers = builtin_mutable.discovery_config.m_DiscoveryServers; + use_WriterLivelinessProtocol = builtin_const.use_WriterLivelinessProtocol; + network_configuration = builtin_const.network_configuration; + metatrafficUnicastLocatorList = builtin_mutable.metatrafficUnicastLocatorList; + metatrafficMulticastLocatorList = builtin_const.metatrafficMulticastLocatorList; + metatraffic_external_unicast_locators = builtin_mutable.metatraffic_external_unicast_locators; + initialPeersList = builtin_const.initialPeersList; + readerHistoryMemoryPolicy = builtin_const.readerHistoryMemoryPolicy; + readerPayloadSize = builtin_const.readerPayloadSize; + writerHistoryMemoryPolicy = builtin_const.writerHistoryMemoryPolicy; + writerPayloadSize = builtin_const.writerPayloadSize; + mutation_tries = builtin_const.mutation_tries; + avoid_builtin_multicast = builtin_const.avoid_builtin_multicast; + flow_controller_name = builtin_const.flow_controller_name; +} /** * Class RTPSParticipantAttributes used to define different aspects of a RTPSParticipant. @@ -745,7 +815,7 @@ class RTPSParticipantAttributes }; /** - * Class RTPSMutablePartAttributes used to define mutable aspects of a RTPSParticipant. + * Class RTPSParticipantMutableAttributes used to define mutable aspects of a RTPSParticipant. * @ingroup RTPS_ATTRIBUTES_MODULE */ class RTPSParticipantMutableAttributes diff --git a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp index 7634038cf22..6848bdde94f 100644 --- a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp +++ b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp @@ -337,6 +337,11 @@ class RTPSParticipantImpl return const_attr_; } + const RTPSParticipantMutableAttributes get_mutable_attributes() const + { + return RTPSParticipantMutableAttributes{attr_}; + } + RTPSParticipantAttributes copy_attributes() const { return attr_; From 8cc52cd51829f10a3b7dc52a604114492a2dc163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Tue, 28 Apr 2026 14:53:36 +0200 Subject: [PATCH 21/26] Refs #23923: Review - Add ConstantDiscoverySettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../attributes/RTPSParticipantAttributes.hpp | 127 +++++++++++++++++- .../rtps/participant/RTPSParticipantImpl.cpp | 1 + .../attributes/RTPSParticipantAttributes.hpp | 104 ++++++++++++++ 3 files changed, 227 insertions(+), 5 deletions(-) diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index ca086cb617f..7a7d6f0ea0c 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -371,6 +371,110 @@ class MutableDiscoverySettings }; +/** + * Class ConstantDiscoverySettings, to define the constant attributes of the several discovery protocols available + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class ConstantDiscoverySettings +{ +public: + + //! Chosen discovery protocol + DiscoveryProtocol discoveryProtocol = DiscoveryProtocol::SIMPLE; + + /** + * If set to true, SimpleEDP would be used. + */ + bool use_SIMPLE_EndpointDiscoveryProtocol = true; + + /** + * If set to true, StaticEDP based on an XML file would be implemented. + * The XML filename must be provided. + */ + bool use_STATIC_EndpointDiscoveryProtocol = false; + + /** + * Lease Duration of the RTPSParticipant, + * indicating how much time remote RTPSParticipants should consider this RTPSParticipant alive. + */ + dds::Duration_t leaseDuration = { 20, 0 }; + + /** + * The period for the RTPSParticipant to send its Discovery Message to all other discovered RTPSParticipants + * as well as to all Multicast ports. + */ + dds::Duration_t leaseDuration_announcementperiod = { 3, 0 }; + + //!Initial announcements configuration + InitialAnnouncementConfig initial_announcements; + + //!Attributes of the SimpleEDP protocol + SimpleEDPAttributes m_simpleEDP; + + //! function that returns a PDP object (only if EXTERNAL selected) + PDPFactory m_PDPfactory{}; + /** + * The period for the RTPSParticipant to: + * send its Discovery Message to its servers + * check for EDP endpoints matching + */ + dds::Duration_t discoveryServer_client_syncperiod = { 0, 450 * 1000000}; // 450 milliseconds + + //! Filtering participants out depending on location + ParticipantFilteringFlags ignoreParticipantFlags = ParticipantFilteringFlags::NO_FILTER; + + ConstantDiscoverySettings() = default; + + ConstantDiscoverySettings( + const DiscoverySettings& discovery_settings) + : discoveryProtocol(discovery_settings.discoveryProtocol) + , use_SIMPLE_EndpointDiscoveryProtocol(discovery_settings.use_SIMPLE_EndpointDiscoveryProtocol) + , use_STATIC_EndpointDiscoveryProtocol(discovery_settings.use_STATIC_EndpointDiscoveryProtocol) + , leaseDuration(discovery_settings.leaseDuration) + , leaseDuration_announcementperiod(discovery_settings.leaseDuration_announcementperiod) + , initial_announcements(discovery_settings.initial_announcements) + , m_simpleEDP(discovery_settings.m_simpleEDP) + , m_PDPfactory(discovery_settings.m_PDPfactory) + , discoveryServer_client_syncperiod(discovery_settings.discoveryServer_client_syncperiod) + , ignoreParticipantFlags(discovery_settings.ignoreParticipantFlags) + , static_edp_xml_config_(discovery_settings.static_edp_xml_config()) + { + } + + bool operator ==( + const ConstantDiscoverySettings& b) const + { + return (this->discoveryProtocol == b.discoveryProtocol) && + (this->use_SIMPLE_EndpointDiscoveryProtocol == b.use_SIMPLE_EndpointDiscoveryProtocol) && + (this->use_STATIC_EndpointDiscoveryProtocol == b.use_STATIC_EndpointDiscoveryProtocol) && + (this->discoveryServer_client_syncperiod == b.discoveryServer_client_syncperiod) && + (this->m_PDPfactory == b.m_PDPfactory) && + (this->leaseDuration == b.leaseDuration) && + (this->leaseDuration_announcementperiod == b.leaseDuration_announcementperiod) && + (this->initial_announcements == b.initial_announcements) && + (this->m_simpleEDP == b.m_simpleEDP) && + (this->static_edp_xml_config_ == b.static_edp_xml_config_) && + (this->ignoreParticipantFlags == b.ignoreParticipantFlags); + } + + /** + * Get the static endpoint XML configuration. + * @return URI specifying the static endpoint XML configuration. + * The string could contain a filename (file://) or the XML content directly (data://). + */ + const char* static_edp_xml_config() const + { + return static_edp_xml_config_.c_str(); + } + +private: + + //! URI specifying the static EDP XML configuration, only necessary if use_STATIC_EndpointDiscoveryProtocol=true + //! This string could contain a filename or the XML content directly. + std::string static_edp_xml_config_ = ""; + +}; + // Forward declaration to allow assignment from Constant and Mutable attributes. class BuiltinConstantAttributes; class BuiltinMutableAttributes; @@ -513,10 +617,10 @@ class BuiltinConstantAttributes public: /** - * Discovery protocol related attributes. Only the discovery server list is mutable, which must be + * Discovery protocol related constant attributes. Only the discovery server list is mutable, which must be * accessed through the BuiltinMutableAttributes class. Its value in this class is only used as initial value. */ - DiscoverySettings discovery_config; + ConstantDiscoverySettings discovery_config; //! Indicates to use the WriterLiveliness protocol. bool use_WriterLivelinessProtocol = true; @@ -597,13 +701,23 @@ inline void BuiltinAttributes::compose( const BuiltinConstantAttributes& builtin_const, const BuiltinMutableAttributes& builtin_mutable) { - discovery_config = builtin_const.discovery_config; + // Constant Discovery settings + discovery_config.discoveryProtocol = builtin_const.discovery_config.discoveryProtocol; + discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = builtin_const.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol; + discovery_config.use_STATIC_EndpointDiscoveryProtocol = builtin_const.discovery_config.use_STATIC_EndpointDiscoveryProtocol; + discovery_config.leaseDuration = builtin_const.discovery_config.leaseDuration; + discovery_config.leaseDuration_announcementperiod = builtin_const.discovery_config.leaseDuration_announcementperiod; + discovery_config.initial_announcements = builtin_const.discovery_config.initial_announcements; + discovery_config.m_simpleEDP = builtin_const.discovery_config.m_simpleEDP; + discovery_config.m_PDPfactory = builtin_const.discovery_config.m_PDPfactory; + discovery_config.discoveryServer_client_syncperiod = builtin_const.discovery_config.discoveryServer_client_syncperiod; + discovery_config.ignoreParticipantFlags = builtin_const.discovery_config.ignoreParticipantFlags; + // Mutable Discovery settings discovery_config.m_DiscoveryServers = builtin_mutable.discovery_config.m_DiscoveryServers; + // Constant settings use_WriterLivelinessProtocol = builtin_const.use_WriterLivelinessProtocol; network_configuration = builtin_const.network_configuration; - metatrafficUnicastLocatorList = builtin_mutable.metatrafficUnicastLocatorList; metatrafficMulticastLocatorList = builtin_const.metatrafficMulticastLocatorList; - metatraffic_external_unicast_locators = builtin_mutable.metatraffic_external_unicast_locators; initialPeersList = builtin_const.initialPeersList; readerHistoryMemoryPolicy = builtin_const.readerHistoryMemoryPolicy; readerPayloadSize = builtin_const.readerPayloadSize; @@ -612,6 +726,9 @@ inline void BuiltinAttributes::compose( mutation_tries = builtin_const.mutation_tries; avoid_builtin_multicast = builtin_const.avoid_builtin_multicast; flow_controller_name = builtin_const.flow_controller_name; + // Mutable settings + metatrafficUnicastLocatorList = builtin_mutable.metatrafficUnicastLocatorList; + metatraffic_external_unicast_locators = builtin_mutable.metatraffic_external_unicast_locators; } /** diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 1f60d2eab36..0a952cd68b2 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -3458,6 +3458,7 @@ const RTPSParticipantConstantAttributes& RTPSParticipantImpl::get_const_attribut const RTPSParticipantMutableAttributes RTPSParticipantImpl::get_mutable_attributes() const { + std::lock_guard _(mutex_); return RTPSParticipantMutableAttributes(m_att); } diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index fe4c115056f..bee6a3a67ed 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -359,6 +359,110 @@ class MutableDiscoverySettings }; +/** + * Class ConstantDiscoverySettings, to define the constant attributes of the several discovery protocols available + * @ingroup RTPS_ATTRIBUTES_MODULE + */ +class ConstantDiscoverySettings +{ +public: + + //! Chosen discovery protocol + DiscoveryProtocol discoveryProtocol = DiscoveryProtocol::SIMPLE; + + /** + * If set to true, SimpleEDP would be used. + */ + bool use_SIMPLE_EndpointDiscoveryProtocol = true; + + /** + * If set to true, StaticEDP based on an XML file would be implemented. + * The XML filename must be provided. + */ + bool use_STATIC_EndpointDiscoveryProtocol = false; + + /** + * Lease Duration of the RTPSParticipant, + * indicating how much time remote RTPSParticipants should consider this RTPSParticipant alive. + */ + dds::Duration_t leaseDuration = { 20, 0 }; + + /** + * The period for the RTPSParticipant to send its Discovery Message to all other discovered RTPSParticipants + * as well as to all Multicast ports. + */ + dds::Duration_t leaseDuration_announcementperiod = { 3, 0 }; + + //!Initial announcements configuration + InitialAnnouncementConfig initial_announcements; + + //!Attributes of the SimpleEDP protocol + SimpleEDPAttributes m_simpleEDP; + + //! function that returns a PDP object (only if EXTERNAL selected) + PDPFactory m_PDPfactory{}; + /** + * The period for the RTPSParticipant to: + * send its Discovery Message to its servers + * check for EDP endpoints matching + */ + dds::Duration_t discoveryServer_client_syncperiod = { 0, 450 * 1000000}; // 450 milliseconds + + //! Filtering participants out depending on location + ParticipantFilteringFlags ignoreParticipantFlags = ParticipantFilteringFlags::NO_FILTER; + + ConstantDiscoverySettings() = default; + + ConstantDiscoverySettings( + const DiscoverySettings& discovery_settings) + : discoveryProtocol(discovery_settings.discoveryProtocol) + , use_SIMPLE_EndpointDiscoveryProtocol(discovery_settings.use_SIMPLE_EndpointDiscoveryProtocol) + , use_STATIC_EndpointDiscoveryProtocol(discovery_settings.use_STATIC_EndpointDiscoveryProtocol) + , leaseDuration(discovery_settings.leaseDuration) + , leaseDuration_announcementperiod(discovery_settings.leaseDuration_announcementperiod) + , initial_announcements(discovery_settings.initial_announcements) + , m_simpleEDP(discovery_settings.m_simpleEDP) + , m_PDPfactory(discovery_settings.m_PDPfactory) + , discoveryServer_client_syncperiod(discovery_settings.discoveryServer_client_syncperiod) + , ignoreParticipantFlags(discovery_settings.ignoreParticipantFlags) + , static_edp_xml_config_(discovery_settings.static_edp_xml_config()) + { + } + + bool operator ==( + const ConstantDiscoverySettings& b) const + { + return (this->discoveryProtocol == b.discoveryProtocol) && + (this->use_SIMPLE_EndpointDiscoveryProtocol == b.use_SIMPLE_EndpointDiscoveryProtocol) && + (this->use_STATIC_EndpointDiscoveryProtocol == b.use_STATIC_EndpointDiscoveryProtocol) && + (this->discoveryServer_client_syncperiod == b.discoveryServer_client_syncperiod) && + (this->m_PDPfactory == b.m_PDPfactory) && + (this->leaseDuration == b.leaseDuration) && + (this->leaseDuration_announcementperiod == b.leaseDuration_announcementperiod) && + (this->initial_announcements == b.initial_announcements) && + (this->m_simpleEDP == b.m_simpleEDP) && + (this->static_edp_xml_config_ == b.static_edp_xml_config_) && + (this->ignoreParticipantFlags == b.ignoreParticipantFlags); + } + + /** + * Get the static endpoint XML configuration. + * @return URI specifying the static endpoint XML configuration. + * The string could contain a filename (file://) or the XML content directly (data://). + */ + const char* static_edp_xml_config() const + { + return static_edp_xml_config_.c_str(); + } + +private: + + //! URI specifying the static EDP XML configuration, only necessary if use_STATIC_EndpointDiscoveryProtocol=true + //! This string could contain a filename or the XML content directly. + std::string static_edp_xml_config_ = ""; + +}; + // Forward declaration to allow assignment from Constant and Mutable attributes. class BuiltinConstantAttributes; class BuiltinMutableAttributes; From 36370f758fbc46200400c30d21ae6e78afb56971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Tue, 28 Apr 2026 15:29:26 +0200 Subject: [PATCH 22/26] Refs #23923: Solve using statement visibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../fastdds/rtps/attributes/RTPSParticipantAttributes.hpp | 8 ++++---- .../fastdds/rtps/attributes/RTPSParticipantAttributes.hpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index 7a7d6f0ea0c..2a5a1512545 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -737,10 +737,10 @@ inline void BuiltinAttributes::compose( */ class RTPSParticipantAttributes { - using FlowControllerDescriptorList = std::vector>; - public: + using FlowControllerDescriptorList = std::vector>; + RTPSParticipantAttributes() = default; virtual ~RTPSParticipantAttributes() = default; @@ -961,10 +961,10 @@ class RTPSParticipantMutableAttributes */ class RTPSParticipantConstantAttributes { - using FlowControllerDescriptorList = std::vector>; - public: + using FlowControllerDescriptorList = std::vector>; + RTPSParticipantConstantAttributes() = default; RTPSParticipantConstantAttributes( diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index bee6a3a67ed..bfb2bcb513d 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -711,10 +711,10 @@ inline void BuiltinAttributes::compose( */ class RTPSParticipantAttributes { - using FlowControllerDescriptorList = std::vector>; - public: + using FlowControllerDescriptorList = std::vector>; + RTPSParticipantAttributes() = default; virtual ~RTPSParticipantAttributes() = default; @@ -972,10 +972,10 @@ class RTPSParticipantMutableAttributes */ class RTPSParticipantConstantAttributes { - using FlowControllerDescriptorList = std::vector>; - public: + using FlowControllerDescriptorList = std::vector>; + RTPSParticipantConstantAttributes() = default; RTPSParticipantConstantAttributes( From e15700926439d69c98af66f21c8fac90ae0ffe7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Tue, 28 Apr 2026 16:13:40 +0200 Subject: [PATCH 23/26] Refs #23923: Uncrustify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- .../rtps/attributes/RTPSParticipantAttributes.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp index 2a5a1512545..8def5dae10b 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp @@ -703,14 +703,17 @@ inline void BuiltinAttributes::compose( { // Constant Discovery settings discovery_config.discoveryProtocol = builtin_const.discovery_config.discoveryProtocol; - discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = builtin_const.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol; - discovery_config.use_STATIC_EndpointDiscoveryProtocol = builtin_const.discovery_config.use_STATIC_EndpointDiscoveryProtocol; + discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = + builtin_const.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol; + discovery_config.use_STATIC_EndpointDiscoveryProtocol = + builtin_const.discovery_config.use_STATIC_EndpointDiscoveryProtocol; discovery_config.leaseDuration = builtin_const.discovery_config.leaseDuration; discovery_config.leaseDuration_announcementperiod = builtin_const.discovery_config.leaseDuration_announcementperiod; discovery_config.initial_announcements = builtin_const.discovery_config.initial_announcements; discovery_config.m_simpleEDP = builtin_const.discovery_config.m_simpleEDP; discovery_config.m_PDPfactory = builtin_const.discovery_config.m_PDPfactory; - discovery_config.discoveryServer_client_syncperiod = builtin_const.discovery_config.discoveryServer_client_syncperiod; + discovery_config.discoveryServer_client_syncperiod = + builtin_const.discovery_config.discoveryServer_client_syncperiod; discovery_config.ignoreParticipantFlags = builtin_const.discovery_config.ignoreParticipantFlags; // Mutable Discovery settings discovery_config.m_DiscoveryServers = builtin_mutable.discovery_config.m_DiscoveryServers; From 27a8452afed849c2364251afb1192a7900842491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Wed, 29 Apr 2026 16:19:13 +0200 Subject: [PATCH 24/26] Refs #23923: Store constant attributes set at 'setup_' methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 4 +++- src/cpp/rtps/participant/RTPSParticipantImpl.hpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 0a952cd68b2..4161e0bd906 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -282,7 +282,6 @@ RTPSParticipantImpl::RTPSParticipantImpl( RTPSParticipantListener* plisten) : domain_id_(domain_id) , m_att(PParam) - , m_const_att(PParam) , m_guid(guidP, c_EntityId_RTPSParticipant) , mp_builtinProtocols(nullptr) , IdCounter(0) @@ -345,6 +344,9 @@ RTPSParticipantImpl::RTPSParticipantImpl( } #endif // if HAVE_SECURITY + // Store the constant attributes. Need to do it at this point to ensure we capture the constant attributes + // set at "setup_" methods, but before setup_builtin_protocols, which already access constant values. + m_const_att = m_att; // Initialize builtin protocols if (!setup_builtin_protocols()) { diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index 630cb4d0f7d..edd754c82de 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -615,7 +615,7 @@ class RTPSParticipantImpl //!Attributes of the RTPSParticipant RTPSParticipantAttributes m_att; //!Constant copy of Attributes of the RTPSParticipant - const RTPSParticipantConstantAttributes m_const_att; + RTPSParticipantConstantAttributes m_const_att; //! Metatraffic unicast port used by default on this participant uint32_t metatraffic_unicast_port_ = 0; //! Default unicast port used by default on this participant From 82261ce3b77cff57708ae1c1731d0516f46c529e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Thu, 30 Apr 2026 07:47:36 +0200 Subject: [PATCH 25/26] Refs #23923: Init const attributes and update later MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 4161e0bd906..e81965d9615 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -282,6 +282,7 @@ RTPSParticipantImpl::RTPSParticipantImpl( RTPSParticipantListener* plisten) : domain_id_(domain_id) , m_att(PParam) + , m_const_att(PParam) , m_guid(guidP, c_EntityId_RTPSParticipant) , mp_builtinProtocols(nullptr) , IdCounter(0) @@ -344,7 +345,7 @@ RTPSParticipantImpl::RTPSParticipantImpl( } #endif // if HAVE_SECURITY - // Store the constant attributes. Need to do it at this point to ensure we capture the constant attributes + // Update constant attributes. Need to do it at this point to ensure we capture the constant attributes // set at "setup_" methods, but before setup_builtin_protocols, which already access constant values. m_const_att = m_att; // Initialize builtin protocols From 74342245558f3d12856a870ce08e0b0520ffb30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ferreira=20Gonz=C3=A1lez?= Date: Mon, 4 May 2026 10:37:08 +0200 Subject: [PATCH 26/26] Refs #23923: Review - Improve doxygen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Ferreira González --- include/fastdds/rtps/participant/RTPSParticipant.hpp | 5 ++--- src/cpp/rtps/participant/RTPSParticipantImpl.hpp | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 855f60185ba..e5b9a12d5bf 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -246,8 +246,7 @@ class FASTDDS_EXPORTED_API RTPSParticipant "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** * @brief Get a const reference of RTPSParticipantConstantAttributes of this RTPSParticipantImpl. - * This method is thread safe because it returns a const reference to the internal attributes. - * @warning It must not be used to access mutable attributes as it could return outdated values. + * This method is thread safe because it returns a const reference to the internal constant attributes. * @return A const reference to the RTPSParticipantConstantAttributes of this RTPSParticipantImpl. */ const RTPSParticipantConstantAttributes& get_const_attributes() const; @@ -256,7 +255,7 @@ class FASTDDS_EXPORTED_API RTPSParticipant "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** * @brief Get a const copy of RTPSParticipantMutableAttributes of this RTPSParticipantImpl. - * This method is thread safe because it returns a const copy of the internal attributes. + * This method is thread safe because it returns a const copy of the internal mutable attributes. * @return A const copy of the RTPSParticipantMutableAttributes of this RTPSParticipantImpl. */ const RTPSParticipantMutableAttributes get_mutable_attributes() const; diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp index edd754c82de..1c7e720c2fa 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.hpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.hpp @@ -908,8 +908,7 @@ class RTPSParticipantImpl "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** * @brief Get a const reference of RTPSParticipantConstantAttributes of this RTPSParticipantImpl. - * This method is thread safe because it returns a const reference to the internal attributes. - * @warning It must not be used to access mutable attributes as it could return outdated values. Use get_mutable_attributes instead. + * This method is thread safe because it returns a const reference to the internal constant attributes. * @return A const reference to the RTPSParticipantConstantAttributes of this RTPSParticipantImpl. */ const RTPSParticipantConstantAttributes& get_const_attributes() const; @@ -918,7 +917,7 @@ class RTPSParticipantImpl "Make RTPSParticipantAttributes a composition of RTPSParticipantConstantAttributes and RTPSParticipantMutableAttributes"); /** * @brief Get a const copy of RTPSParticipantMutableAttributes of this RTPSParticipantImpl. - * This method is thread safe because it returns a const copy of the internal attributes. + * This method is thread safe because it returns a const copy of the internal mutable attributes. * @return A const copy of the RTPSParticipantMutableAttributes of this RTPSParticipantImpl. */ const RTPSParticipantMutableAttributes get_mutable_attributes() const;