From 0cfda34923f95f6b66ab150aeb2c9e8451056918 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Mon, 18 Dec 2023 20:48:11 +0100 Subject: [PATCH 01/35] Refs #20157: Implemented async_get_type replies. Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.cpp | 33 +++++++ .../type_lookup_service/TypeLookupManager.hpp | 29 ++++++ .../TypeLookupReplyListener.cpp | 89 +++++++++++++------ .../TypeLookupReplyListener.hpp | 10 +++ 4 files changed, 135 insertions(+), 26 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 4960c44aade..95c379a53f9 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -389,6 +389,22 @@ ReturnCode_t TypeLookupManager::check_type_identifier_received_impl( } } +void TypeLookupManager::notify_callbacks( + xtypes::TypeIdentfierWithSize type_identifier_with_size) +{ + // Check that type is not solved + auto callbacks_it = async_get_type_callbacks_.find(type_identifier_with_size); + if (callbacks_it != async_get_type_callbacks_.end()) + { + for (AsyncGetTypeCallback& callback : callbacks_it->second) + { + callback(); + } + // Erase the solved TypeIdentfierWithSize + remove_async_get_type_callback(type_identifier_with_size); + } +} + bool TypeLookupManager::add_async_get_type_request( const SampleIdentity& request, const xtypes::TypeIdentfierWithSize& type_identifier_with_size) @@ -447,6 +463,23 @@ bool TypeLookupManager::remove_async_get_type_callback( } } +bool TypeLookupManager::remove_async_get_types_request( + SampleIdentity request) +{ + std::unique_lock lock(async_get_types_mutex_); + try + { + async_get_type_requests_.erase(request); + return true; + } + catch (const std::exception& e) + { + EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, + "Error in TypeLookupManager::remove_async_get_types_request: " << e.what()); + return false; + } +} + bool TypeLookupManager::create_endpoints() { bool ret = true; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index 56780262461..d1d845e2091 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -189,6 +189,20 @@ class TypeLookupManager private: + /** + * Checks if the given TypeIdentfierWithSize is known by the TypeObjectRegistry. + * Uses get_type_dependencies() and get_types() to get those that are not known. + * Adds a callback to the async_get_type_callbacks_ entry of the TypeIdentfierWithSize, or creates a new one if + * TypeIdentfierWithSize was not in the map before + * @param type_identifier_with_size[in] TypeIdentfierWithSize to check. + * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. + * @return ReturnCode_t RETCODE_OK if type is known. + * RETCODE_NO_DATA if the type is being discovered. + * RETCODE_ERROR if the request was not sent or the callback was not added correctly. + */ + ReturnCode_t check_type_identifier_received( + const xtypes::TypeIdentfierWithSize& type_identifier_with_size, + const fastrtps::rtps::GuidPrefix_t& type_server); /** * Checks if the given TypeIdentfierWithSize is known by the TypeObjectRegistry. * Uses get_type_dependencies() and get_types() to get those that are not known. @@ -228,6 +242,13 @@ class TypeLookupManager std::vector::smart_ptr, AsyncCallback>>>& async_get_type_callbacks); + /** + * Notifies callbacks for a given TypeIdentfierWithSize + * @param type_identifier_with_size[in] TypeIdentfierWithSize of the callbacks to notify. + */ + void notify_callbacks( + xtypes::TypeIdentfierWithSize type_identifier_with_size); + /** * Adds a callback to the async_get_type_callbacks_ entry of the TypeIdentfierWithSize, or creates a new one if * TypeIdentfierWithSize was not in the map before @@ -247,6 +268,14 @@ class TypeLookupManager bool remove_async_get_type_callback( const xtypes::TypeIdentfierWithSize& type_identifier_with_size); + /** + * Removes a SampleIdentity from the async_get_type_callbacks_. + * @param request[in] SampleIdentity to be removed. + * @return true if removed. false otherwise + */ + bool remove_async_get_types_request( + SampleIdentity request); + /** * Complete requests common fields, create CacheChange, serialize request and add change to writer history. * @param type_id[in] TypeIdentfierWithSize that originated the request. diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 0b0092b03e1..b8754135a30 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -29,14 +29,15 @@ #include #include +#include using eprosima::fastrtps::rtps::RTPSReader; using eprosima::fastrtps::rtps::CacheChange_t; using eprosima::fastdds::dds::Log; - using eprosima::fastrtps::rtps::c_EntityId_TypeLookup_reply_writer; + namespace eprosima { namespace fastdds { namespace dds { @@ -52,6 +53,63 @@ TypeLookupReplyListener::~TypeLookupReplyListener() { } +void TypeLookupReplyListener::check_get_types_reply( + SampleIdentity request_id, + const TypeLookup_getTypes_Out& reply) +{ + // Check if we were waiting that reply SampleIdentity + auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); + if (requests_it != typelookup_manager_->async_get_type_requests_.end()) + { + for (xtypes::TypeIdentifierTypeObjectPair pair : reply.types()) + { + if (RETCODE_OK == fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + register_type_object(pair.type_identifier(), pair.type_object())) + { + typelookup_manager_->notify_callbacks(requests_it->second); + } + } + // Erase the processed SampleIdentity + typelookup_manager_->remove_async_get_types_request(request_id); + } +} + +void TypeLookupReplyListener::check_get_type_dependencies_reply( + SampleIdentity request_id, + const TypeLookup_getTypeDependencies_Out& reply) +{ + // Check if we were waiting that reply SampleIdentity + auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); + if (requests_it != typelookup_manager_->async_get_type_requests_.end()) + { + bool are_dependencies_solved = true; + for (xtypes::TypeIdentfierWithSize type_id : reply.dependent_typeids()) + { + ReturnCode_t solve_ret = typelookup_manager_->check_type_identifier_received(type_id); + if (RETCODE_OK != solve_ret) + { + are_dependencies_solved = false; + } + } + + // If all dependencies are known, ask for the parent type + if (are_dependencies_solved) + { + xtypes::TypeIdentifierSeq uknown_type; + uknown_type.push_back(requests_it->second.type_id()); + + SampleIdentity get_types_request = typelookup_manager_->get_types(uknown_type); + if (builtin::INVALID_SAMPLE_IDENTITY != get_types_request) + { + // Store the sent request and associated TypeIdentfierWithSize + typelookup_manager_->add_async_get_type_request(get_types_request, requests_it->second); + } + } + // Erase the processed SampleIdentity + typelookup_manager_->remove_async_get_types_request(request_id); + } +} + void TypeLookupReplyListener::onNewCacheChangeAdded( RTPSReader* reader, const CacheChange_t* const changeIN) @@ -72,35 +130,14 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( { case TypeLookup_getTypes_HashId: { - const TypeLookup_getTypes_Out types = reply.return_value().getType().result(); - for (auto pair : types.types()) - { - if (pair.type_object()._d() == eprosima::fastdds::dds::xtypes::EK_COMPLETE) // Just in case - { - // TODO (adelcampo) Change to xtypes with TypeObjectRegistry - // If build_dynamic_type failed, just sent the nullptr already contained on it. - // tlm_->participant_->getListener()->on_type_discovery( - // tlm_->participant_->getUserRTPSParticipant(), - // reply.header.requestId, - // "", // No topic_name available - // &pair.type_identifier(), - // &pair.type_object(), - // DynamicType_ptr(nullptr)); - } - } - // TODO Call a callback once the job is done + check_get_types_reply(reply.header().relatedRequestId(), + reply.return_value().getType().result()); break; } case TypeLookup_getDependencies_HashId: { - //const TypeLookup_getTypeDependencies_Out dependencies = - // reply.return_value.getTypeDependencies().result(); - - // TODO (adelcampo) Change to xtypes with TypeObjectRegistry - // tlm_->get_RTPS_participant()->getListener()->on_type_dependencies_reply( - // tlm_->builtin_protocols_->mp_participantImpl->getUserRTPSParticipant(), - // reply.header().relatedRequestId(), - // reply.return_value().getTypeDependencies().result().dependent_typeids()); + check_get_type_dependencies_reply(reply.header().relatedRequestId(), + reply.return_value().getTypeDependencies().result()); break; } default: diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 1209c5c1a41..fc12de21059 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -24,6 +24,8 @@ #include #include +#include + namespace eprosima { namespace fastrtps { namespace rtps { @@ -60,6 +62,14 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa */ virtual ~TypeLookupReplyListener() override; + void check_get_types_reply( + SampleIdentity request_id, + const TypeLookup_getTypes_Out& reply); + + void check_get_type_dependencies_reply( + SampleIdentity request_id, + const TypeLookup_getTypeDependencies_Out& reply); + /** * @brief Method call when this class is notified of a new cache change * @param reader The reader receiving the cache change From 194d33be2176d7f33113802fde897cacf1ec6cbc Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 21 Dec 2023 17:29:14 +0100 Subject: [PATCH 02/35] Refs #20157: Changeds to instance_name. Signed-off-by: adriancampo --- .../TypeLookupReplyListener.cpp | 18 +++++++-------- .../TypeLookupReplyListener.hpp | 22 ++++++++++++++++--- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index b8754135a30..0b4c8a4e40f 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -54,7 +54,7 @@ TypeLookupReplyListener::~TypeLookupReplyListener() } void TypeLookupReplyListener::check_get_types_reply( - SampleIdentity request_id, + const SampleIdentity& request_id, const TypeLookup_getTypes_Out& reply) { // Check if we were waiting that reply SampleIdentity @@ -75,7 +75,8 @@ void TypeLookupReplyListener::check_get_types_reply( } void TypeLookupReplyListener::check_get_type_dependencies_reply( - SampleIdentity request_id, + const SampleIdentity& request_id, + const fastrtps::rtps::GuidPrefix_t type_server, const TypeLookup_getTypeDependencies_Out& reply) { // Check if we were waiting that reply SampleIdentity @@ -85,7 +86,7 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( bool are_dependencies_solved = true; for (xtypes::TypeIdentfierWithSize type_id : reply.dependent_typeids()) { - ReturnCode_t solve_ret = typelookup_manager_->check_type_identifier_received(type_id); + ReturnCode_t solve_ret = typelookup_manager_->check_type_identifier_received(type_id, type_server); if (RETCODE_OK != solve_ret) { are_dependencies_solved = false; @@ -98,7 +99,7 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( xtypes::TypeIdentifierSeq uknown_type; uknown_type.push_back(requests_it->second.type_id()); - SampleIdentity get_types_request = typelookup_manager_->get_types(uknown_type); + SampleIdentity get_types_request = typelookup_manager_->get_types(uknown_type, type_server); if (builtin::INVALID_SAMPLE_IDENTITY != get_types_request) { // Store the sent request and associated TypeIdentfierWithSize @@ -112,9 +113,9 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( void TypeLookupReplyListener::onNewCacheChangeAdded( RTPSReader* reader, - const CacheChange_t* const changeIN) + const CacheChange_t* const change_in) { - CacheChange_t* change = const_cast(changeIN); + CacheChange_t* change = const_cast(change_in); if (change->writerGUID.entityId != c_EntityId_TypeLookup_reply_writer) { @@ -130,13 +131,12 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( { case TypeLookup_getTypes_HashId: { - check_get_types_reply(reply.header().relatedRequestId(), - reply.return_value().getType().result()); + check_get_types_reply(reply.header().relatedRequestId(), reply.return_value().getType().result()); break; } case TypeLookup_getDependencies_HashId: { - check_get_type_dependencies_reply(reply.header().relatedRequestId(), + check_get_type_dependencies_reply(reply.header().relatedRequestId(), change->writerGUID.guidPrefix, reply.return_value().getTypeDependencies().result()); break; } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index fc12de21059..1893addf81f 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -62,16 +62,32 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa */ virtual ~TypeLookupReplyListener() override; + /** + * @brief Registers TypeIdentifier and TypeObject in TypeObjectRegistry. + * Also notifies all callbacks for the type and removes the current SampleIdentity from the list. + * @param request_id[in] The SampleIdentity of the request + * @param reply[in] The reply data + */ void check_get_types_reply( - SampleIdentity request_id, + const SampleIdentity& request_id, const TypeLookup_getTypes_Out& reply); + /** + * @brief Checks if all dependencies are solved. + * If they are not, sends next request and adds it to the list.. + * If they are, sends get_types request and adds it to the list. + * Also removes the current SampleIdentity from the list. + * @param request_id[in] The SampleIdentity of the request + * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. + * @param reply[in] The reply data + */ void check_get_type_dependencies_reply( - SampleIdentity request_id, + const SampleIdentity& request_id, + const fastrtps::rtps::GuidPrefix_t type_server, const TypeLookup_getTypeDependencies_Out& reply); /** - * @brief Method call when this class is notified of a new cache change + * @brief Method called when this class is notified of a new cache change * @param reader The reader receiving the cache change * @param change The cache change */ From 1b6d46aabe984f0c47ce1a76f260d8b84010fbe2 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 4 Jan 2024 19:32:17 +0100 Subject: [PATCH 03/35] Refs #20157: Changes to check_type_identifier_received Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupReplyListener.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 0b4c8a4e40f..5d05d8a5ccd 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -83,18 +83,17 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); if (requests_it != typelookup_manager_->async_get_type_requests_.end()) { - bool are_dependencies_solved = true; + bool all_dependencies_known = true; for (xtypes::TypeIdentfierWithSize type_id : reply.dependent_typeids()) { - ReturnCode_t solve_ret = typelookup_manager_->check_type_identifier_received(type_id, type_server); - if (RETCODE_OK != solve_ret) + if (RETCODE_OK != typelookup_manager_->check_type_identifier_received(type_id, type_server, nullptr)) { - are_dependencies_solved = false; + all_dependencies_known = false; } } // If all dependencies are known, ask for the parent type - if (are_dependencies_solved) + if (all_dependencies_known) { xtypes::TypeIdentifierSeq uknown_type; uknown_type.push_back(requests_it->second.type_id()); From cf38084863dde4fddf21c87507dcee2ab340ff84 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Sun, 7 Jan 2024 11:07:38 +0100 Subject: [PATCH 04/35] Refs #20157: Added continuation point checks. Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.cpp | 83 ++++++++++++++++++- .../type_lookup_service/TypeLookupManager.hpp | 12 +-- .../TypeLookupReplyListener.cpp | 80 +++++++++++++----- .../TypeLookupReplyListener.hpp | 2 +- .../type_lookup_service/TypeLookupManager.hpp | 13 +-- 5 files changed, 153 insertions(+), 37 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 95c379a53f9..c87b7107e2d 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -256,12 +256,18 @@ void TypeLookupManager::remove_remote_endpoints( SampleIdentity TypeLookupManager::get_type_dependencies( const xtypes::TypeIdentifierSeq& id_seq, - const fastrtps::rtps::GuidPrefix_t& type_server) const + const fastrtps::rtps::GuidPrefix_t& type_server, + const std::vector& continuation_point) const { SampleIdentity id = INVALID_SAMPLE_IDENTITY; TypeLookup_getTypeDependencies_In in; - in.type_ids() = id_seq; + in.type_ids(id_seq); + if (!continuation_point.empty()) + { + in.continuation_point(continuation_point); + } + TypeLookup_RequestPubSubType type; TypeLookup_Request* request = static_cast(type.createData()); request->data().getTypeDependencies(in); @@ -281,7 +287,7 @@ SampleIdentity TypeLookupManager::get_types( SampleIdentity id = INVALID_SAMPLE_IDENTITY; TypeLookup_getTypes_In in; - in.type_ids() = id_seq; + in.type_ids(id_seq); TypeLookup_RequestPubSubType type; TypeLookup_Request* request = static_cast(type.createData()); request->data().getTypes(in); @@ -320,6 +326,50 @@ ReturnCode_t TypeLookupManager::async_get_type( return result; } +ReturnCode_t TypeLookupManager::check_type_identifier_received( + const xtypes::TypeIdentfierWithSize& type_identifier_with_size, + const fastrtps::rtps::GuidPrefix_t& type_server) +{ + // Check if the type is known + if (fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + is_type_identifier_known(type_identifier_with_size)) + { + return RETCODE_OK; + } + + // Check if TypeIdentfierWithSize already exists in the map + auto writer_it = async_get_type_writer_callbacks_.find(type_identifier_with_size); + if (writer_it != async_get_type_writer_callbacks_.end()) + { + // Return without sending new request + return RETCODE_NO_DATA; + } + + // If not found in the writer map, check the reader map + auto reader_it = async_get_type_reader_callbacks_.find(type_identifier_with_size); + if (reader_it != async_get_type_reader_callbacks_.end()) + { + // Return without sending new request + return RETCODE_NO_DATA; + } + + // TypeIdentfierWithSize doesn't exist, create a new entry + xtypes::TypeIdentifierSeq unknown_type{type_identifier_with_size.type_id()}; + SampleIdentity get_type_dependencies_request = get_type_dependencies(unknown_type, type_server); + if (INVALID_SAMPLE_IDENTITY != get_type_dependencies_request) + { + // Store the sent request + add_async_get_type_request(get_type_dependencies_request, type_identifier_with_size); + return RETCODE_NO_DATA; + } + else + { + // Failed to send request, return error + EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Failed to send get_type_dependencies request"); + return RETCODE_ERROR; + } +} + ReturnCode_t TypeLookupManager::check_type_identifier_received( eprosima::ProxyPool::smart_ptr&& temp_writer_data, const AsyncGetTypeWriterCallback& callback) @@ -405,6 +455,33 @@ void TypeLookupManager::notify_callbacks( } } +void TypeLookupManager::notify_callbacks( + xtypes::TypeIdentfierWithSize type_identifier_with_size) +{ + // Check that type is not solved + auto writer_callbacks_it = async_get_type_writer_callbacks_.find(type_identifier_with_size); + if (writer_callbacks_it != async_get_type_writer_callbacks_.end()) + { + for (auto& proxy_callback_pair : writer_callbacks_it->second) + { + proxy_callback_pair.second(std::move(proxy_callback_pair.first)); + } + //Erase the solved TypeIdentfierWithSize + remove_async_get_type_callback(type_identifier_with_size); + } + + auto reader_callbacks_it = async_get_type_reader_callbacks_.find(type_identifier_with_size); + if (reader_callbacks_it != async_get_type_reader_callbacks_.end()) + { + for (auto& proxy_callback_pair : reader_callbacks_it->second) + { + proxy_callback_pair.second(std::move(proxy_callback_pair.first)); + } + // Erase the solved TypeIdentfierWithSize + remove_async_get_type_callback(type_identifier_with_size); + } +} + bool TypeLookupManager::add_async_get_type_request( const SampleIdentity& request, const xtypes::TypeIdentfierWithSize& type_identifier_with_size) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index d1d845e2091..1ab3a20e4d0 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -154,18 +154,20 @@ class TypeLookupManager * associated with a sequence of TypeIdentifiers. * @param id_seq[in] Sequence of TypeIdentifiers for which dependencies are needed. * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. - * @return The SampleIdentity of the request sended. + * @param continuation_point[in] Continuation point for a previous partially answered request. + * @return The SampleIdentity of the sent request. */ SampleIdentity get_type_dependencies( const xtypes::TypeIdentifierSeq& id_seq, - const fastrtps::rtps::GuidPrefix_t& type_server) const; + const fastrtps::rtps::GuidPrefix_t& type_server, + const std::vector& continuation_point = std::vector()) const; /** - * Create and send a request using the builtin TypeLookup Service to retrieve TypeObjects associated with a + * Create and send a request using the built-in TypeLookup Service to retrieve TypeObjects associated with a * sequence of TypeIdentifiers. * @param id_seq[in] Sequence of TypeIdentifiers for which TypeObjects are to be retrieved. - * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. - * @return The SampleIdentity of the request sended. + * @param type_server[in] GuidPrefix corresponding to the remote participant whose TypeInformation is being resolved. + * @return The SampleIdentity of the sent request. */ SampleIdentity get_types( const xtypes::TypeIdentifierSeq& id_seq, diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 5d05d8a5ccd..a65c113b136 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -57,7 +57,7 @@ void TypeLookupReplyListener::check_get_types_reply( const SampleIdentity& request_id, const TypeLookup_getTypes_Out& reply) { - // Check if we were waiting that reply SampleIdentity + // Check if the received reply SampleIdentity corresponds to an outstanding request auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); if (requests_it != typelookup_manager_->async_get_type_requests_.end()) { @@ -66,10 +66,11 @@ void TypeLookupReplyListener::check_get_types_reply( if (RETCODE_OK == fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). register_type_object(pair.type_identifier(), pair.type_object())) { + // Notify the callbacks associated with the request typelookup_manager_->notify_callbacks(requests_it->second); } } - // Erase the processed SampleIdentity + // Remove the processed SampleIdentity from the outstanding requests typelookup_manager_->remove_async_get_types_request(request_id); } } @@ -79,35 +80,63 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( const fastrtps::rtps::GuidPrefix_t type_server, const TypeLookup_getTypeDependencies_Out& reply) { - // Check if we were waiting that reply SampleIdentity + // Check if the received reply SampleIdentity corresponds to an outstanding request auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); - if (requests_it != typelookup_manager_->async_get_type_requests_.end()) + if (requests_it == typelookup_manager_->async_get_type_requests_.end()) { - bool all_dependencies_known = true; - for (xtypes::TypeIdentfierWithSize type_id : reply.dependent_typeids()) + // The reply is not associated with any outstanding request, ignore it + return; + } + + // Check each dependent TypeIdentifierWithSize to ensure all dependencies are known + bool all_dependencies_known = std::all_of( + reply.dependent_typeids().begin(), reply.dependent_typeids().end(), + [&](const xtypes::TypeIdentfierWithSize& type_id) { - if (RETCODE_OK != typelookup_manager_->check_type_identifier_received(type_id, type_server, nullptr)) - { - all_dependencies_known = false; - } - } + // Check if the dependent TypeIdentifierWithSize is known; creating a new request if it is not + return RETCODE_OK == typelookup_manager_->check_type_identifier_received(type_id, type_server); + }); - // If all dependencies are known, ask for the parent type - if (all_dependencies_known) + // If the received reply has continuation point, send next request + if (!reply.continuation_point().empty()) + { + // Make a new request with the continuation point + xtypes::TypeIdentifierSeq unknown_type{requests_it->second.type_id()}; + SampleIdentity next_request_id = typelookup_manager_-> + get_type_dependencies(unknown_type, type_server, reply.continuation_point()); + if (INVALID_SAMPLE_IDENTITY != next_request_id) + { + // Store the sent requests and associated TypeIdentfierWithSize + typelookup_manager_->add_async_get_type_request(next_request_id, requests_it->second); + } + else { - xtypes::TypeIdentifierSeq uknown_type; - uknown_type.push_back(requests_it->second.type_id()); + // Failed to send request + EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Failed to send get_type_dependencies request"); + } + } + // If all dependencies are known and there is no continuation point, request the parent type + else if (all_dependencies_known) + { + xtypes::TypeIdentifierSeq unknown_type{requests_it->second.type_id()}; - SampleIdentity get_types_request = typelookup_manager_->get_types(uknown_type, type_server); - if (builtin::INVALID_SAMPLE_IDENTITY != get_types_request) - { - // Store the sent request and associated TypeIdentfierWithSize - typelookup_manager_->add_async_get_type_request(get_types_request, requests_it->second); - } + // Initiate a type request to obtain the parent type + SampleIdentity get_types_request = typelookup_manager_->get_types(unknown_type, type_server); + + if (INVALID_SAMPLE_IDENTITY != get_types_request) + { + // Store the type request + typelookup_manager_->add_async_get_type_request(get_types_request, requests_it->second); + } + else + { + // Failed to send request + EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Failed to send get_types request"); } - // Erase the processed SampleIdentity - typelookup_manager_->remove_async_get_types_request(request_id); } + + // Remove the processed SampleIdentity from the outstanding requests + typelookup_manager_->remove_async_get_types_request(request_id); } void TypeLookupReplyListener::onNewCacheChangeAdded( @@ -116,13 +145,16 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( { CacheChange_t* change = const_cast(change_in); + // Check if the data is received from the expected TypeLookup Reply writer if (change->writerGUID.entityId != c_EntityId_TypeLookup_reply_writer) { + // Log a warning and remove the change from the history EPROSIMA_LOG_WARNING(TL_REPLY_READER, "Received data from a bad endpoint."); reader->getHistory()->remove_change(change); } EPROSIMA_LOG_INFO(TYPELOOKUP_SERVICE_REPLY_LISTENER, "Received new cache change"); + // Process the received TypeLookup Reply and handle different types of replies TypeLookup_Reply reply; if (typelookup_manager_->receive_reply(*change, reply)) { @@ -143,6 +175,8 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( break; } } + + // Remove the processed cache change from the history reader->getHistory()->remove_change(change); } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 1893addf81f..4367df53f7c 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -74,7 +74,7 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa /** * @brief Checks if all dependencies are solved. - * If they are not, sends next request and adds it to the list.. + * If they are not, sends next request and adds it to the list. * If they are, sends get_types request and adds it to the list. * Also removes the current SampleIdentity from the list. * @param request_id[in] The SampleIdentity of the request diff --git a/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index 27a49169974..43ba6d8bb1c 100644 --- a/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -66,11 +66,14 @@ class TypeLookupManager { } - MOCK_CONST_METHOD1(get_type_dependencies, fastrtps::rtps::SampleIdentity( - const fastdds::dds::xtypes::TypeIdentifierSeq&)); - - MOCK_CONST_METHOD1(get_types, fastrtps::rtps::SampleIdentity( - const fastdds::dds::xtypes::TypeIdentifierSeq&)); + MOCK_CONST_METHOD3(get_type_dependencies, SampleIdentity( + const fastrtps::types::TypeIdentifierSeq&, + const fastrtps::rtps::GuidPrefix_t&, + const std::vector&)); + + MOCK_CONST_METHOD2(get_types, SampleIdentity( + const fastrtps::types::TypeIdentifierSeq&, + const fastrtps::rtps::GuidPrefix_t&)); void remove_remote_endpoints( fastrtps::rtps::ParticipantProxyData* pdata) From fb1ddd9e6b8fa537ccf0a2b7206e35800160a88e Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 10 Jan 2024 19:08:05 +0100 Subject: [PATCH 05/35] Refs #20157: Removed old function Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index c87b7107e2d..0efabb3a3f4 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -439,22 +439,6 @@ ReturnCode_t TypeLookupManager::check_type_identifier_received_impl( } } -void TypeLookupManager::notify_callbacks( - xtypes::TypeIdentfierWithSize type_identifier_with_size) -{ - // Check that type is not solved - auto callbacks_it = async_get_type_callbacks_.find(type_identifier_with_size); - if (callbacks_it != async_get_type_callbacks_.end()) - { - for (AsyncGetTypeCallback& callback : callbacks_it->second) - { - callback(); - } - // Erase the solved TypeIdentfierWithSize - remove_async_get_type_callback(type_identifier_with_size); - } -} - void TypeLookupManager::notify_callbacks( xtypes::TypeIdentfierWithSize type_identifier_with_size) { From ea7cc75445418e14a9d6ff4bea4ed657ec5f1f58 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Tue, 19 Dec 2023 16:03:53 +0100 Subject: [PATCH 06/35] Refs #20160: Implemented async_get_type request listener. Signed-off-by: adriancampo --- .../TypeLookupRequestListener.cpp | 110 +++++++++--------- .../TypeLookupRequestListener.hpp | 20 ++++ 2 files changed, 78 insertions(+), 52 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index dfe39fcb5f8..853a5a5763b 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -19,6 +19,8 @@ #include +#include +#include #include #include @@ -28,6 +30,8 @@ #include #include +#include +#include using eprosima::fastrtps::rtps::RTPSReader; using eprosima::fastrtps::rtps::CacheChange_t; @@ -50,6 +54,54 @@ TypeLookupRequestListener::~TypeLookupRequestListener() { } +void TypeLookupRequestListener::check_get_types_request( + SampleIdentity request_id, + const TypeLookup_getTypes_In& request) +{ + TypeLookup_getTypes_Out out; + for (const xtypes::TypeIdentifier& type_id : request.type_ids()) + { + xtypes::TypeObject obj; + if (RETCODE_OK == fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + get_type_object(type_id, obj)) + { + xtypes::TypeIdentifierTypeObjectPair pair; + pair.type_identifier(type_id); + pair.type_object(obj); + out.types().push_back(std::move(pair)); + } + } + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); + TypeLookup_getTypes_Result result; + result.result(out); + reply->return_value().getType(result); + reply->header().relatedRequestId() = request_id; + + typelookup_manager_->send_reply(*reply); + typelookup_manager_->reply_type_.deleteData(reply); +} + +void TypeLookupRequestListener::check_get_type_dependencies_request( + SampleIdentity request_id, + const TypeLookup_getTypeDependencies_In& request) +{ + TypeLookup_getTypeDependencies_Out out; + + std::unordered_set type_dependencies; + if (RETCODE_OK == fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + get_type_dependencies(request.type_ids(), type_dependencies)) + { + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); + TypeLookup_getTypeDependencies_Result result; + result.result(out); + reply->return_value().getTypeDependencies(result); + reply->header().relatedRequestId() = request_id; + + typelookup_manager_->send_reply(*reply); + typelookup_manager_->reply_type_.deleteData(reply); + } +} + void TypeLookupRequestListener::onNewCacheChangeAdded( RTPSReader* reader, const CacheChange_t* const changeIN) @@ -70,63 +122,17 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( { case TypeLookup_getTypes_HashId: { - const TypeLookup_getTypes_In in = request.data().getTypes(); - TypeLookup_getTypes_Out out; - - for (const xtypes::TypeIdentifier& type_id : in.type_ids()) - { - xtypes::TypeObject obj; - // TODO (adelcampo) Change to xtypes - // const TypeIdentifier* obj_ident = factory_->typelookup_get_type(type_id, obj); - xtypes::TypeIdentifier* obj_ident = nullptr; - - if (obj_ident != nullptr && obj._d() != fastdds::dds::xtypes::TK_NONE) - { - xtypes::TypeIdentifierTypeObjectPair pair; - pair.type_identifier(type_id); - pair.type_object(obj); - out.types().push_back(std::move(pair)); - } - - if (obj_ident != nullptr && !(type_id == *obj_ident)) - { - xtypes::TypeIdentifierPair pair; - pair.type_identifier1(*obj_ident); - pair.type_identifier2(type_id); - out.complete_to_minimal().push_back(std::move(pair)); - } - } - - TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); - TypeLookup_getTypes_Result result; - result.result(out); - reply->return_value().getType(result); - reply->header().relatedRequestId() = request.header().requestId(); - - typelookup_manager_->send_reply(*reply); - typelookup_manager_->reply_type_.deleteData(reply); + std::async(std::launch::async, + &TypeLookupRequestListener::check_get_types_request, this, + request.header().requestId(), request.data().getTypes()); break; } case TypeLookup_getDependencies_HashId: { - const TypeLookup_getTypeDependencies_In in = request.data().getTypeDependencies(); - TypeLookup_getTypeDependencies_Out out; - //for (size_t index = 0; index < in.type_ids.size(); ++index) - { - // TODO (adelcampo) Change to xtypes - // out.dependent_typeids = factory_->typelookup_get_type_dependencies( - // in.type_ids, in.continuation_point, out.continuation_point, 255); // TODO: Make configurable? - } - - TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); - TypeLookup_getTypeDependencies_Result result; - result.result(out); - reply->return_value().getTypeDependencies(result); - reply->header().relatedRequestId() = request.header().requestId(); - - typelookup_manager_->send_reply(*reply); - typelookup_manager_->reply_type_.deleteData(reply); + std::async(std::launch::async, + &TypeLookupRequestListener::check_get_type_dependencies_request, this, + request.header().requestId(), request.data().getTypeDependencies()); break; } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index aebd5d30160..19e34ec163f 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -24,6 +24,8 @@ #include #include +#include + namespace eprosima { namespace fastrtps { namespace rtps { @@ -60,6 +62,24 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public */ virtual ~TypeLookupRequestListener() override; + /** + * @brief Gets TypeObject from TypeObjectRegistry, creates and sends reply + * @param request_id[in] The SampleIdentity of the request + * @param request[in] The request data + */ + void check_get_types_request( + SampleIdentity request_id, + const TypeLookup_getTypes_In& request); + + /** + * @brief Gets type dependencies from TypeObjectRegistry, creates and sends reply + * @param request_id[in] The SampleIdentity of the request + * @param request[in] The request data + */ + void check_get_type_dependencies_request( + SampleIdentity request_id, + const TypeLookup_getTypeDependencies_In& request); + /** * @brief Method call when this class is notified of a new cache change * @param reader The reader receiving the cache change From 6eafc4b79f523f74dc5f7d0771f7445ef09d0497 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 10 Jan 2024 19:06:19 +0100 Subject: [PATCH 07/35] Refs #20160: Added continuation point management Signed-off-by: adriancampo --- .../TypeLookupReplyListener.hpp | 11 +- .../TypeLookupRequestListener.cpp | 127 +++++++++++++++++- .../TypeLookupRequestListener.hpp | 55 +++++++- .../type_lookup_service/TypeLookupManager.hpp | 5 +- 4 files changed, 178 insertions(+), 20 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 4367df53f7c..7c347f2b914 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -17,12 +17,10 @@ * */ -#ifndef TYPELOOKUP_REPLY_LISTENER_HPP_ -#define TYPELOOKUP_REPLY_LISTENER_HPP_ -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC +#ifndef _FASTDDS_TYPELOOKUP_SERVICE_REPLY_LISTENER_HPP_ +#define _FASTDDS_TYPELOOKUP_SERVICE_REPLY_LISTENER_HPP_ -#include -#include +#include #include @@ -114,5 +112,4 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa } /* namespace dds */ } /* namespace fastdds */ } /* namespace eprosima */ -#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif /* TYPELOOKUP_REPLY_LISTENER_HPP_*/ +#endif /* _FASTDDS_TYPELOOKUP_SERVICE_REPLY_LISTENER_HPP_*/ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index 853a5a5763b..967a09503a0 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -44,6 +44,53 @@ namespace fastdds { namespace dds { namespace builtin { +const int MAX_DEPENDENCIES_PER_REQUEST = 100; + +/** + * @brief Calculates the opaque value of continuation point. + * @param continuation_point[in] The continuation point. + * @return The value of the continuation_point. + */ +size_t calculate_continuation_point( + const std::vector& continuation_point) +{ + size_t result = 0; + for (size_t i = 0; i < continuation_point.size(); ++i) + { + result = (result << 8) | continuation_point[i]; + } + return result; +} + +/** + * @brief Creates a continuation point with the given value. + * @param value[in] The desired value. + * @return The continuation_point. + */ +std::vector create_continuation_point( + int value) +{ + std::vector continuation_point(32, 0); + + for (int value_i = 0; value_i < value; value_i++) + { + for (int i = continuation_point.size() - 1; i >= 0; --i) + { + if (continuation_point[i] < 255) + { + ++continuation_point[i]; + // Break after successful increment + break; + } + else + { + continuation_point[i] = 0; + } + } + } + return continuation_point; +} + TypeLookupRequestListener::TypeLookupRequestListener( TypeLookupManager* manager) : typelookup_manager_(manager) @@ -85,12 +132,37 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( SampleIdentity request_id, const TypeLookup_getTypeDependencies_In& request) { - TypeLookup_getTypeDependencies_Out out; - std::unordered_set type_dependencies; - if (RETCODE_OK == fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). - get_type_dependencies(request.type_ids(), type_dependencies)) + ReturnCode_t result; + // Check if the received request has been done before and needed a continuation point + { + std::lock_guard lock(requests_with_continuation_mutex_); + auto requests_it = requests_with_continuation_.find(request.type_ids()); + if (requests_it != requests_with_continuation_.end()) + { + // Get the dependencies without chechking the registry + type_dependencies = requests_it->second; + result = RETCODE_OK; + } + else + { + // Get the dependencies from the registry + result = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + get_type_dependencies(request.type_ids(), type_dependencies); + + // If there are too many dependent types, store the result for future requests + if (result == RETCODE_OK && type_dependencies.size() > MAX_DEPENDENCIES_PER_REQUEST) + { + requests_with_continuation_.emplace(request.type_ids(), type_dependencies); + } + } + } + + if (RETCODE_OK == result) { + TypeLookup_getTypeDependencies_Out out = + prepare_dependent_types(request.type_ids(), type_dependencies, request.continuation_point()); + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); TypeLookup_getTypeDependencies_Result result; result.result(out); @@ -102,6 +174,52 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( } } +TypeLookup_getTypeDependencies_Out TypeLookupRequestListener::prepare_dependent_types( + const xtypes::TypeIdentifierSeq& id_seq, + const std::unordered_set& type_dependencies, + const std::vector& continuation_point) +{ + TypeLookup_getTypeDependencies_Out out; + + std::vector dependent_types; + if (type_dependencies.size() < MAX_DEPENDENCIES_PER_REQUEST) + { + std::copy(type_dependencies.begin(), type_dependencies.end(), std::back_inserter(dependent_types)); + } + else + { + size_t start_index = 0; + if (!continuation_point.empty()) + { + start_index = calculate_continuation_point(continuation_point) * MAX_DEPENDENCIES_PER_REQUEST; + } + + auto start_it = std::next(type_dependencies.begin(), start_index); + auto end_it = std::next(start_it, std::min(MAX_DEPENDENCIES_PER_REQUEST, + type_dependencies.size() - start_index)); + std::copy(start_it, end_it, std::back_inserter(dependent_types)); + + if ((start_index + MAX_DEPENDENCIES_PER_REQUEST) > type_dependencies.size()) + { + // Is all dependent types have been sent, remove from map + std::lock_guard lock(requests_with_continuation_mutex_); + auto requests_it = requests_with_continuation_.find(id_seq); + if (requests_it != requests_with_continuation_.end()) + { + requests_with_continuation_.erase(requests_it); + } + } + else + { + out.continuation_point(create_continuation_point(calculate_continuation_point(continuation_point) + 1)); + } + } + + out.dependent_typeids(dependent_types); + + return out; +} + void TypeLookupRequestListener::onNewCacheChangeAdded( RTPSReader* reader, const CacheChange_t* const changeIN) @@ -151,6 +269,7 @@ void TypeLookupRequestListener::onWriterChangeReceivedByAll( } } // namespace builtin + } // namespace dds } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index 19e34ec163f..3c7377ef87b 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -17,14 +17,39 @@ * */ -#ifndef TYPELOOKUP_REQUEST_LISTENER_HPP_ -#define TYPELOOKUP_REQUEST_LISTENER_HPP_ -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC +#ifndef _FASTDDS_TYPELOOKUP_SERVICE_REQUEST_LISTENER_HPP_ +#define _FASTDDS_TYPELOOKUP_SERVICE_REQUEST_LISTENER_HPP_ -#include -#include +#include +#include +#include + +#include #include +#include + +namespace std { + +template <> +struct hash +{ + std::size_t operator ()( + const eprosima::fastdds::dds::xtypes::TypeIdentifierSeq& k) const + { + std::size_t hash_value = 0; + for (const auto& id : k) + { + hash_value ^= (static_cast(id.equivalence_hash()[0]) << 16) | + (static_cast(id.equivalence_hash()[1]) << 8) | + (static_cast(id.equivalence_hash()[2])); + } + return hash_value; + } + +}; + +} // std namespace eprosima { namespace fastrtps { @@ -80,6 +105,17 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public SampleIdentity request_id, const TypeLookup_getTypeDependencies_In& request); + /** + * @brief Builds a TypeLookup_getTypeDependencies_Out ussing continuation points to manage size + * @param id_seq[in] Sequence of TypeIdentifiers for which dependencies are needed. + * @param type_dependencies[in] The full list of dependencies of the type + * @param continuation_point[in] The continuation point of the previous request + */ + TypeLookup_getTypeDependencies_Out prepare_dependent_types( + const xtypes::TypeIdentifierSeq& id_seq, + const std::unordered_set& type_dependencies, + const std::vector& continuation_point); + /** * @brief Method call when this class is notified of a new cache change * @param reader The reader receiving the cache change @@ -103,11 +139,16 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public //! A pointer to the typelookup manager TypeLookupManager* typelookup_manager_; + //!Mutex to protect access to requests_with_continuation_ + std::mutex requests_with_continuation_mutex_; + + //!Collection of the requests that needed continuation points. + std::unordered_map > requests_with_continuation_; }; } /* namespace builtin */ } /* namespace dds */ } /* namespace fastdds */ } /* namespace eprosima */ -#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif /* TYPELOOKUP_REQUEST_LISTENER_HPP_*/ +#endif /* _FASTDDS_TYPELOOKUP_SERVICE_REQUEST_LISTENER_HPP_*/ diff --git a/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index 43ba6d8bb1c..983af2d0fe2 100644 --- a/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -23,6 +23,7 @@ #include #include +#include namespace eprosima { @@ -67,12 +68,12 @@ class TypeLookupManager } MOCK_CONST_METHOD3(get_type_dependencies, SampleIdentity( - const fastrtps::types::TypeIdentifierSeq&, + const eprosima::fastdds::dds::xtypes::TypeIdentifierSeq&, const fastrtps::rtps::GuidPrefix_t&, const std::vector&)); MOCK_CONST_METHOD2(get_types, SampleIdentity( - const fastrtps::types::TypeIdentifierSeq&, + const eprosima::fastdds::dds::xtypes::TypeIdentifierSeq&, const fastrtps::rtps::GuidPrefix_t&)); void remove_remote_endpoints( From c391c63f63adc30d584a18064a38bbeb3c7bfe97 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 11 Jan 2024 10:14:40 +0100 Subject: [PATCH 08/35] Refs #20160: Renames and comments improvements Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.hpp | 70 +++++++++---------- .../TypeLookupReplyListener.hpp | 18 ++--- .../TypeLookupRequestListener.cpp | 57 +++++++++------ .../TypeLookupRequestListener.hpp | 39 ++++++----- 4 files changed, 99 insertions(+), 85 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index 1ab3a20e4d0..46f47d1bdd2 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -144,7 +144,7 @@ class TypeLookupManager /** * Remove remote endpoints from the typelookup service. - * @param pdata Pointer to the ParticipantProxyData to remove + * @param pdata Pointer to the ParticipantProxyData to remove. */ void remove_remote_endpoints( fastrtps::rtps::ParticipantProxyData* pdata); @@ -195,7 +195,7 @@ class TypeLookupManager * Checks if the given TypeIdentfierWithSize is known by the TypeObjectRegistry. * Uses get_type_dependencies() and get_types() to get those that are not known. * Adds a callback to the async_get_type_callbacks_ entry of the TypeIdentfierWithSize, or creates a new one if - * TypeIdentfierWithSize was not in the map before + * TypeIdentfierWithSize was not in the map before. * @param type_identifier_with_size[in] TypeIdentfierWithSize to check. * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. * @return ReturnCode_t RETCODE_OK if type is known. @@ -209,7 +209,7 @@ class TypeLookupManager * Checks if the given TypeIdentfierWithSize is known by the TypeObjectRegistry. * Uses get_type_dependencies() and get_types() to get those that are not known. * Adds a callback to the async_get_type_callbacks_ entry of the TypeIdentfierWithSize, or creates a new one if - * TypeIdentfierWithSize was not in the map before + * TypeIdentfierWithSize was not in the map before. * @param temp_proxy_data[in] Temporary Writer/Reader ProxyData that originated the request. * @param callback[in] Callback to add. * @return ReturnCode_t RETCODE_OK if type is known. @@ -245,7 +245,7 @@ class TypeLookupManager AsyncCallback>>>& async_get_type_callbacks); /** - * Notifies callbacks for a given TypeIdentfierWithSize + * Notifies callbacks for a given TypeIdentfierWithSize. * @param type_identifier_with_size[in] TypeIdentfierWithSize of the callbacks to notify. */ void notify_callbacks( @@ -253,10 +253,10 @@ class TypeLookupManager /** * Adds a callback to the async_get_type_callbacks_ entry of the TypeIdentfierWithSize, or creates a new one if - * TypeIdentfierWithSize was not in the map before - * @param request[in] SampleIdentity of the request + * TypeIdentfierWithSize was not in the map before. + * @param request[in] SampleIdentity of the request. * @param type_identifier_with_size[in] TypeIdentfierWithSize that originated the request. - * @return true if added. false otherwise + * @return true if added. false otherwise. */ bool add_async_get_type_request( const SampleIdentity& request, @@ -265,7 +265,7 @@ class TypeLookupManager /** * Removes a TypeIdentfierWithSize from the async_get_type_callbacks_. * @param type_identifier_with_size[in] TypeIdentfierWithSize to be removed. - * @return true if removed. false otherwise + * @return true if removed, false otherwise. */ bool remove_async_get_type_callback( const xtypes::TypeIdentfierWithSize& type_identifier_with_size); @@ -273,7 +273,7 @@ class TypeLookupManager /** * Removes a SampleIdentity from the async_get_type_callbacks_. * @param request[in] SampleIdentity to be removed. - * @return true if removed. false otherwise + * @return true if removed, false otherwise. */ bool remove_async_get_types_request( SampleIdentity request); @@ -298,8 +298,8 @@ class TypeLookupManager /** * Used for request reception. Deserialize the request and check if it is directed to the local DomainParticipant. - * @param change[in] CacheChange_t of the request - * @param request[out] TypeLookup_Request after deserialization + * @param change[in] CacheChange_t of the request. + * @param request[out] TypeLookup_Request after deserialization. * @return true if the request is deserialized and directed to the local participant, false otherwise. */ bool receive_request( @@ -308,8 +308,8 @@ class TypeLookupManager /** * Used for reply reception. Deserialize and check that the reply's recipient is the local participant. - * @param change[in] CacheChange_t of the reply - * @param reply[out] TypeLookup_Reply after deserialize + * @param change[in] CacheChange_t of the reply. + * @param reply[out] TypeLookup_Reply after deserialize. * @return true if the request is deserialized and the reply's recipient is us, false otherwise. */ bool receive_reply( @@ -326,8 +326,8 @@ class TypeLookupManager } /** - * Create instance name as defined in section 7.6.3.3.4 XTypes 1.3 specification - * @param guid[in] GuidPrefix_t to be included in the instance name + * Create instance name as defined in section 7.6.3.3.4 XTypes 1.3 specification. + * @param guid[in] GuidPrefix_t to be included in the instance name. * @return The instance name. */ std::string get_instance_name( @@ -339,72 +339,72 @@ class TypeLookupManager */ bool create_endpoints(); - //!Pointer to the local RTPSParticipant. + //! Pointer to the local RTPSParticipant. fastrtps::rtps::RTPSParticipantImpl* participant_ = nullptr; - //!Own instance name + //! Own instance name. std::string local_instance_name_; - //!Pointer to the BuiltinProtocols class. + //! Pointer to the BuiltinProtocols class. fastrtps::rtps::BuiltinProtocols* builtin_protocols_ = nullptr; - //!Pointer to the RTPSWriter for the TypeLookup_Request. + //! Pointer to the RTPSWriter for the TypeLookup_Request. fastrtps::rtps::StatefulWriter* builtin_request_writer_ = nullptr; - //!Pointer to the RTPSReader for the TypeLookup_Request. + //! Pointer to the RTPSReader for the TypeLookup_Request. fastrtps::rtps::StatefulReader* builtin_request_reader_ = nullptr; - //!Pointer to the RTPSWriter for the TypeLookup_Reply. + //! Pointer to the RTPSWriter for the TypeLookup_Reply. fastrtps::rtps::StatefulWriter* builtin_reply_writer_ = nullptr; - //!Pointer to the RTPSReader for the TypeLookup_Reply. + //! Pointer to the RTPSReader for the TypeLookup_Reply. fastrtps::rtps::StatefulReader* builtin_reply_reader_ = nullptr; - //!Pointer to the Writer History of TypeLookup_Request + //! Pointer to the Writer History of TypeLookup_Request. fastrtps::rtps::WriterHistory* builtin_request_writer_history_ = nullptr; - //!Pointer to the Writer History of TypeLookup_Reply + //! Pointer to the Writer History of TypeLookup_Reply. fastrtps::rtps::WriterHistory* builtin_reply_writer_history_ = nullptr; - //!Pointer to the Reader History of TypeLookup_Request + //! Pointer to the Reader History of TypeLookup_Request. fastrtps::rtps::ReaderHistory* builtin_request_reader_history_ = nullptr; - //!Pointer to the Reader History of TypeLookup_Reply + //! Pointer to the Reader History of TypeLookup_Reply. fastrtps::rtps::ReaderHistory* builtin_reply_reader_history_ = nullptr; - //!Request Listener object. + //! Request Listener object. TypeLookupRequestListener* request_listener_ = nullptr; - //!Reply Listener object. + //! Reply Listener object. TypeLookupReplyListener* reply_listener_ = nullptr; - //!Mutex to protect access to temp_reader_proxy_data_ and temp_writer_proxy_data_ + //! Mutex to protect access to temp_reader_proxy_data_ and temp_writer_proxy_data_. std::mutex temp_data_lock_; - //!Pointer to the temp ReaderProxyData used for assigments + //! Pointer to the temp ReaderProxyData used for assigments. fastrtps::rtps::ReaderProxyData* temp_reader_proxy_data_ = nullptr; - //!Pointer to the temp WriterProxyData used for assigments + //! Pointer to the temp WriterProxyData used for assigments. fastrtps::rtps::WriterProxyData* temp_writer_proxy_data_ = nullptr; mutable fastrtps::rtps::SequenceNumber_t request_seq_number_; mutable TypeLookup_RequestPubSubType request_type_; mutable TypeLookup_ReplyPubSubType reply_type_; - //!Mutex to protect access to async_get_type_callbacks_ and async_get_type_requests_ + //! Mutex to protect access to async_get_type_callbacks_ and async_get_type_requests_. std::mutex async_get_types_mutex_; - //!Collection of all the WriterProxyData and their callbacks related to a TypeIdentfierWithSize, hashed by its TypeIdentfierWithSize. + //! Collection of all the WriterProxyData and their callbacks related to a TypeIdentfierWithSize, hashed by its TypeIdentfierWithSize. std::unordered_map < xtypes::TypeIdentfierWithSize, std::vector::smart_ptr, AsyncGetTypeWriterCallback>>> async_get_type_writer_callbacks_; - //!Collection of all the ReaderProxyData and their callbacks related to a TypeIdentfierWithSize, hashed by its TypeIdentfierWithSize. + //! Collection of all the ReaderProxyData and their callbacks related to a TypeIdentfierWithSize, hashed by its TypeIdentfierWithSize. std::unordered_map < xtypes::TypeIdentfierWithSize, std::vector::smart_ptr, AsyncGetTypeReaderCallback>>> async_get_type_reader_callbacks_; - //!Collection SampleIdentity and the TypeIdentfierWithSize it originated from, hashed by its SampleIdentity. + //! Collection SampleIdentity and the TypeIdentfierWithSize it originated from, hashed by its SampleIdentity. std::unordered_map async_get_type_requests_; void request_cache_change_acked( diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 7c347f2b914..6176fa7016f 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -50,7 +50,7 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa /** * @brief Constructor - * @param manager Pointer to the TypeLookupManager + * @param manager Pointer to the TypeLookupManager. */ TypeLookupReplyListener( TypeLookupManager* manager); @@ -63,8 +63,8 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa /** * @brief Registers TypeIdentifier and TypeObject in TypeObjectRegistry. * Also notifies all callbacks for the type and removes the current SampleIdentity from the list. - * @param request_id[in] The SampleIdentity of the request - * @param reply[in] The reply data + * @param request_id[in] The SampleIdentity of the request. + * @param reply[in] The reply data. */ void check_get_types_reply( const SampleIdentity& request_id, @@ -75,9 +75,9 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa * If they are not, sends next request and adds it to the list. * If they are, sends get_types request and adds it to the list. * Also removes the current SampleIdentity from the list. - * @param request_id[in] The SampleIdentity of the request + * @param request_id[in] The SampleIdentity of the request. * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. - * @param reply[in] The reply data + * @param reply[in] The reply data. */ void check_get_type_dependencies_reply( const SampleIdentity& request_id, @@ -85,9 +85,9 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa const TypeLookup_getTypeDependencies_Out& reply); /** - * @brief Method called when this class is notified of a new cache change - * @param reader The reader receiving the cache change - * @param change The cache change + * @brief Method called when this class is notified of a new cache change. + * @param reader The reader receiving the cache change. + * @param change The cache change. */ void onNewCacheChangeAdded( fastrtps::rtps::RTPSReader* reader, @@ -104,7 +104,7 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa private: - //! A pointer to the typelookup manager + //! A pointer to the typelookup manager. TypeLookupManager* typelookup_manager_; }; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index 967a09503a0..9ed4d74be0a 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -44,14 +44,16 @@ namespace fastdds { namespace dds { namespace builtin { -const int MAX_DEPENDENCIES_PER_REQUEST = 100; +//! Constant that specifies the maximum number of dependent types to be included per reply. +//! This number is calculated considering the MTU. +const int MAX_DEPENDENCIES_PER_REPLY = 75; /** * @brief Calculates the opaque value of continuation point. * @param continuation_point[in] The continuation point. * @return The value of the continuation_point. */ -size_t calculate_continuation_point( +inline size_t calculate_continuation_point( const std::vector& continuation_point) { size_t result = 0; @@ -67,7 +69,7 @@ size_t calculate_continuation_point( * @param value[in] The desired value. * @return The continuation_point. */ -std::vector create_continuation_point( +inline std::vector create_continuation_point( int value) { std::vector continuation_point(32, 0); @@ -106,6 +108,7 @@ void TypeLookupRequestListener::check_get_types_request( const TypeLookup_getTypes_In& request) { TypeLookup_getTypes_Out out; + // Iterate through requested type_ids for (const xtypes::TypeIdentifier& type_id : request.type_ids()) { xtypes::TypeObject obj; @@ -115,9 +118,11 @@ void TypeLookupRequestListener::check_get_types_request( xtypes::TypeIdentifierTypeObjectPair pair; pair.type_identifier(type_id); pair.type_object(obj); + // Add the pair to the result out.types().push_back(std::move(pair)); } } + // Create and send the reply TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); TypeLookup_getTypes_Result result; result.result(out); @@ -133,7 +138,7 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( const TypeLookup_getTypeDependencies_In& request) { std::unordered_set type_dependencies; - ReturnCode_t result; + ReturnCode_t type_dependencies_result; // Check if the received request has been done before and needed a continuation point { std::lock_guard lock(requests_with_continuation_mutex_); @@ -142,27 +147,27 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( { // Get the dependencies without chechking the registry type_dependencies = requests_it->second; - result = RETCODE_OK; + type_dependencies_result = RETCODE_OK; } else { // Get the dependencies from the registry - result = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + type_dependencies_result = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). get_type_dependencies(request.type_ids(), type_dependencies); - // If there are too many dependent types, store the result for future requests - if (result == RETCODE_OK && type_dependencies.size() > MAX_DEPENDENCIES_PER_REQUEST) + // If there are too many dependent types, store the type dependencies for future requests + if (type_dependencies_result == RETCODE_OK && type_dependencies.size() > MAX_DEPENDENCIES_PER_REPLY) { requests_with_continuation_.emplace(request.type_ids(), type_dependencies); } } } - if (RETCODE_OK == result) + if (RETCODE_OK == type_dependencies_result) { - TypeLookup_getTypeDependencies_Out out = - prepare_dependent_types(request.type_ids(), type_dependencies, request.continuation_point()); - + // Prepare and send the reply + TypeLookup_getTypeDependencies_Out out = prepare_get_type_dependencies_response( + request.type_ids(), type_dependencies, request.continuation_point()); TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); TypeLookup_getTypeDependencies_Result result; result.result(out); @@ -174,34 +179,37 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( } } -TypeLookup_getTypeDependencies_Out TypeLookupRequestListener::prepare_dependent_types( +TypeLookup_getTypeDependencies_Out TypeLookupRequestListener::prepare_get_type_dependencies_response( const xtypes::TypeIdentifierSeq& id_seq, const std::unordered_set& type_dependencies, const std::vector& continuation_point) { TypeLookup_getTypeDependencies_Out out; - std::vector dependent_types; - if (type_dependencies.size() < MAX_DEPENDENCIES_PER_REQUEST) + + // Check if all dependencies can be sent in a single response + if (type_dependencies.size() < MAX_DEPENDENCIES_PER_REPLY) { std::copy(type_dependencies.begin(), type_dependencies.end(), std::back_inserter(dependent_types)); } else { size_t start_index = 0; + // Check if a continuation point is provided, and calculate starting point if there is if (!continuation_point.empty()) { - start_index = calculate_continuation_point(continuation_point) * MAX_DEPENDENCIES_PER_REQUEST; + start_index = calculate_continuation_point(continuation_point) * MAX_DEPENDENCIES_PER_REPLY; } + // Copy the dependencies within the specified range auto start_it = std::next(type_dependencies.begin(), start_index); - auto end_it = std::next(start_it, std::min(MAX_DEPENDENCIES_PER_REQUEST, + auto end_it = std::next(start_it, std::min(MAX_DEPENDENCIES_PER_REPLY, type_dependencies.size() - start_index)); std::copy(start_it, end_it, std::back_inserter(dependent_types)); - if ((start_index + MAX_DEPENDENCIES_PER_REQUEST) > type_dependencies.size()) + if ((start_index + MAX_DEPENDENCIES_PER_REPLY) > type_dependencies.size()) { - // Is all dependent types have been sent, remove from map + // If all dependent types have been sent, remove from map std::lock_guard lock(requests_with_continuation_mutex_); auto requests_it = requests_with_continuation_.find(id_seq); if (requests_it != requests_with_continuation_.end()) @@ -211,10 +219,12 @@ TypeLookup_getTypeDependencies_Out TypeLookupRequestListener::prepare_dependent_ } else { + // Set the continuation point for the next request out.continuation_point(create_continuation_point(calculate_continuation_point(continuation_point) + 1)); } } + // Set the dependent types in the reply out.dependent_typeids(dependent_types); return out; @@ -226,13 +236,16 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( { CacheChange_t* change = const_cast(changeIN); + // Check if the data is received from the expected TypeLookup Request writer if (change->writerGUID.entityId != c_EntityId_TypeLookup_request_writer) { + // Log a warning and remove the change from the history EPROSIMA_LOG_WARNING(TL_REQUEST_READER, "Received data from a bad endpoint."); reader->getHistory()->remove_change(change); } - EPROSIMA_LOG_INFO(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "Received new cache change"); + + // Process the received TypeLookup Request and handle different types of requests TypeLookup_Request request; if (typelookup_manager_->receive_request(*change, request)) { @@ -243,7 +256,6 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( std::async(std::launch::async, &TypeLookupRequestListener::check_get_types_request, this, request.header().requestId(), request.data().getTypes()); - break; } case TypeLookup_getDependencies_HashId: @@ -251,13 +263,14 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( std::async(std::launch::async, &TypeLookupRequestListener::check_get_type_dependencies_request, this, request.header().requestId(), request.data().getTypeDependencies()); - break; } default: break; } } + + // Remove the processed cache change from the history reader->getHistory()->remove_change(change); } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index 3c7377ef87b..50f9410b2b0 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -76,50 +76,51 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public public: /** - * @brief Constructor - * @param manager Pointer to the TypeLookupManager + * @brief Constructor. + * @param manager Pointer to the TypeLookupManager. */ TypeLookupRequestListener( TypeLookupManager* manager); /** - * @brief Destructor + * @brief Destructor. */ virtual ~TypeLookupRequestListener() override; /** - * @brief Gets TypeObject from TypeObjectRegistry, creates and sends reply - * @param request_id[in] The SampleIdentity of the request - * @param request[in] The request data + * @brief Gets TypeObject from TypeObjectRegistry, creates and sends reply. + * @param request_id[in] The SampleIdentity of the request. + * @param request[in] The request data. */ void check_get_types_request( SampleIdentity request_id, const TypeLookup_getTypes_In& request); /** - * @brief Gets type dependencies from TypeObjectRegistry, creates and sends reply - * @param request_id[in] The SampleIdentity of the request - * @param request[in] The request data + * @brief Gets type dependencies from TypeObjectRegistry, creates and sends reply. + * @param request_id[in] The SampleIdentity of the request. + * @param request[in] The request data. */ void check_get_type_dependencies_request( SampleIdentity request_id, const TypeLookup_getTypeDependencies_In& request); /** - * @brief Builds a TypeLookup_getTypeDependencies_Out ussing continuation points to manage size + * @brief Creates a TypeLookup_getTypeDependencies_Out using continuation points to manage size. * @param id_seq[in] Sequence of TypeIdentifiers for which dependencies are needed. - * @param type_dependencies[in] The full list of dependencies of the type - * @param continuation_point[in] The continuation point of the previous request + * @param type_dependencies[in] The full list of dependencies of the type. + * @param continuation_point[in] The continuation point of the previous request. + * @return The reply containing the dependent types. */ - TypeLookup_getTypeDependencies_Out prepare_dependent_types( + TypeLookup_getTypeDependencies_Out prepare_get_type_dependencies_response( const xtypes::TypeIdentifierSeq& id_seq, const std::unordered_set& type_dependencies, const std::vector& continuation_point); /** - * @brief Method call when this class is notified of a new cache change - * @param reader The reader receiving the cache change - * @param change The cache change + * @brief Method call when this class is notified of a new cache change. + * @param reader The reader receiving the cache change. + * @param change The cache change. */ void onNewCacheChangeAdded( fastrtps::rtps::RTPSReader* reader, @@ -136,13 +137,13 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public private: - //! A pointer to the typelookup manager + //! A pointer to the typelookup manager. TypeLookupManager* typelookup_manager_; - //!Mutex to protect access to requests_with_continuation_ + //! Mutex to protect access to requests_with_continuation_. std::mutex requests_with_continuation_mutex_; - //!Collection of the requests that needed continuation points. + //! Collection of the requests that needed continuation points. std::unordered_map > requests_with_continuation_; }; From 5c078a9a417c925bc7863593687b8058689fd479 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 18 Jan 2024 11:15:08 +0100 Subject: [PATCH 09/35] Refs #20160: Fixed deadlock, renamed discovery methods. Applied suggestions. Signed-off-by: adriancampo --- .../dds/domain/DomainParticipantListener.hpp | 8 +- .../dds/domain/qos/DomainParticipantQos.hpp | 35 ++ .../attributes/RTPSParticipantAttributes.h | 4 + resources/xsd/fastdds_profiles.xsd | 2 + .../type_lookup_service/TypeLookupManager.cpp | 370 ++++++++---------- .../type_lookup_service/TypeLookupManager.hpp | 134 ++++--- .../TypeLookupReplyListener.cpp | 218 ++++++++--- .../TypeLookupReplyListener.hpp | 56 ++- .../TypeLookupRequestListener.cpp | 289 ++++++++++---- .../TypeLookupRequestListener.hpp | 63 ++- .../detail/TypeLookupTypes.hpp | 94 ++--- .../fastdds/domain/DomainParticipantImpl.cpp | 10 +- src/cpp/fastdds/utils/QosConverters.cpp | 2 + .../TypeObjectRegistry.cpp | 29 ++ .../TypeObjectRegistry.hpp | 10 + .../rtps/builtin/discovery/endpoint/EDP.cpp | 20 +- .../discovery/endpoint/EDPSimpleListeners.cpp | 73 ++-- src/cpp/xmlparser/XMLParserCommon.h | 1 + test/blackbox/api/dds-pim/PubSubReader.hpp | 2 +- test/blackbox/api/dds-pim/PubSubWriter.hpp | 4 +- .../api/dds-pim/PubSubWriterReader.hpp | 4 +- .../attributes/RTPSParticipantAttributes.h | 4 + .../dds/participant/ParticipantTests.cpp | 5 + .../profiles/test_xml_for_string_profile.xml | 8 + .../dds/profiles/test_xml_profile.xml | 8 + .../dds/publisher/DataWriterTests.cpp | 2 +- .../dds/subscriber/DataReaderTests.cpp | 2 +- .../xmlparser/test_xml_deprecated.xml | 6 + test/unittest/xmlparser/test_xml_profile.xml | 6 + .../xmlparser/test_xml_profile_env_var.xml | 6 + .../xmlparser/test_xml_rooted_deprecated.xml | 6 + .../xmlparser/test_xml_rooted_profile.xml | 6 + 32 files changed, 961 insertions(+), 526 deletions(-) diff --git a/include/fastdds/dds/domain/DomainParticipantListener.hpp b/include/fastdds/dds/domain/DomainParticipantListener.hpp index 0aceab58e1f..3e90763ddb9 100644 --- a/include/fastdds/dds/domain/DomainParticipantListener.hpp +++ b/include/fastdds/dds/domain/DomainParticipantListener.hpp @@ -101,7 +101,7 @@ class DomainParticipantListener : * @param[out] participant Pointer to the Participant which discovered the remote DataReader. * @param[out] info Remote DataReader information. User can take ownership of the object. */ - virtual void on_subscriber_discovery( + virtual void on_data_reader_discovery( DomainParticipant* participant, fastrtps::rtps::ReaderDiscoveryInfo&& info) { @@ -119,7 +119,7 @@ class DomainParticipantListener : * @param[out] info Remote DataReader information. User can take ownership of the object. * @param[out] should_be_ignored Flag to indicate the library to automatically ignore the discovered DataReader. */ - virtual void on_subscriber_discovery( + virtual void on_data_reader_discovery( DomainParticipant* participant, fastrtps::rtps::ReaderDiscoveryInfo&& info, bool& should_be_ignored) @@ -136,7 +136,7 @@ class DomainParticipantListener : * @param[out] participant Pointer to the Participant which discovered the remote DataWriter. * @param[out] info Remote DataWriter information. User can take ownership of the object. */ - virtual void on_publisher_discovery( + virtual void on_data_writer_discovery( DomainParticipant* participant, fastrtps::rtps::WriterDiscoveryInfo&& info) { @@ -154,7 +154,7 @@ class DomainParticipantListener : * @param[out] info Remote DataWriter information. User can take ownership of the object. * @param[out] should_be_ignored Flag to indicate the library to automatically ignore the discovered DataWriter. */ - virtual void on_publisher_discovery( + virtual void on_data_writer_discovery( DomainParticipant* participant, fastrtps::rtps::WriterDiscoveryInfo&& info, bool& should_be_ignored) diff --git a/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp b/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp index b463aa03e0c..3481e27f27b 100644 --- a/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp +++ b/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp @@ -86,6 +86,7 @@ class DomainParticipantQos (this->builtin_controllers_sender_thread_ == b.builtin_controllers_sender_thread()) && (this->timed_events_thread_ == b.timed_events_thread()) && (this->discovery_server_thread_ == b.discovery_server_thread()) && + (this->typelookup_service_threads_ == b.typelookup_service_threads()) && #if HAVE_SECURITY (this->security_log_thread_ == b.security_log_thread()) && #endif // if HAVE_SECURITY @@ -433,6 +434,37 @@ class DomainParticipantQos discovery_server_thread_ = value; } + /** + * Getter for TypeLookup service ThreadSettings + * + * @return rtps::ThreadSettings reference + */ + rtps::ThreadSettings& typelookup_service_threads() + { + return typelookup_service_threads_; + } + + /** + * Getter for TypeLookup service ThreadSettings + * + * @return rtps::ThreadSettings reference + */ + const rtps::ThreadSettings& typelookup_service_threads() const + { + return typelookup_service_threads_; + } + + /** + * Setter for the TypeLookup service ThreadSettings + * + * @param value New ThreadSettings to be set + */ + void typelookup_service_threads( + const rtps::ThreadSettings& value) + { + typelookup_service_threads_ = value; + } + #if HAVE_SECURITY /** * Getter for security log ThreadSettings @@ -505,6 +537,9 @@ class DomainParticipantQos //! Thread settings for the discovery server thread rtps::ThreadSettings discovery_server_thread_; + //! Thread settings for the discovery server thread + rtps::ThreadSettings typelookup_service_threads_; + #if HAVE_SECURITY //! Thread settings for the security log thread rtps::ThreadSettings security_log_thread_; diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h index bcc0124b9b5..edf2aa9601c 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -443,6 +443,7 @@ class RTPSParticipantAttributes (this->security_log_thread == b.security_log_thread) && #endif // if HAVE_SECURITY (this->discovery_server_thread == b.discovery_server_thread) && + (this->typelookup_service_threads == b.typelookup_service_threads) && (this->builtin_transports_reception_threads == b.builtin_transports_reception_threads); } @@ -559,6 +560,9 @@ class RTPSParticipantAttributes //! Thread settings for the discovery server thread fastdds::rtps::ThreadSettings discovery_server_thread; + //! Thread settings for the discovery server thread + fastdds::rtps::ThreadSettings typelookup_service_threads; + //! Thread settings for the builtin transports reception threads fastdds::rtps::ThreadSettings builtin_transports_reception_threads; diff --git a/resources/xsd/fastdds_profiles.xsd b/resources/xsd/fastdds_profiles.xsd index e9e5d7d6706..cf862e7000a 100644 --- a/resources/xsd/fastdds_profiles.xsd +++ b/resources/xsd/fastdds_profiles.xsd @@ -142,6 +142,7 @@ ├ builtin_controllers_sender_thread [threadSettingsType], ├ timed_events_thread [threadSettingsType], ├ discovery_server_thread [threadSettingsType], + ├ typelookup_service_threads [threadSettingsType], ├ builtin_transports_reception_threads [threadSettingsType], └ security_log_thread [threadSettingsType]--> @@ -186,6 +187,7 @@ + diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 0efabb3a3f4..41e58489b11 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -259,8 +259,6 @@ SampleIdentity TypeLookupManager::get_type_dependencies( const fastrtps::rtps::GuidPrefix_t& type_server, const std::vector& continuation_point) const { - SampleIdentity id = INVALID_SAMPLE_IDENTITY; - TypeLookup_getTypeDependencies_In in; in.type_ids(id_seq); if (!continuation_point.empty()) @@ -268,14 +266,19 @@ SampleIdentity TypeLookupManager::get_type_dependencies( in.continuation_point(continuation_point); } + // Create a generic TypeLookup_Request TypeLookup_RequestPubSubType type; - TypeLookup_Request* request = static_cast(type.createData()); + TypeLookup_Request* request = create_request(type_server, type); + + // Add the specific data to the request request->data().getTypeDependencies(in); - if (send_request(type_server, *request)) + SampleIdentity id = INVALID_SAMPLE_IDENTITY; + if (send(*request)) { id = request->header().requestId(); } + // Delete request data after sending type.deleteData(request); return id; } @@ -284,82 +287,87 @@ SampleIdentity TypeLookupManager::get_types( const xtypes::TypeIdentifierSeq& id_seq, const fastrtps::rtps::GuidPrefix_t& type_server) const { - SampleIdentity id = INVALID_SAMPLE_IDENTITY; - TypeLookup_getTypes_In in; in.type_ids(id_seq); + + // Create a generic TypeLookup_Request TypeLookup_RequestPubSubType type; - TypeLookup_Request* request = static_cast(type.createData()); + TypeLookup_Request* request = create_request(type_server, type); + + // Add the specific data to the request request->data().getTypes(in); - if (send_request(type_server, *request)) + SampleIdentity id = INVALID_SAMPLE_IDENTITY; + if (send(*request)) { id = request->header().requestId(); } + // Delete request data after sending type.deleteData(request); return id; } ReturnCode_t TypeLookupManager::async_get_type( - eprosima::ProxyPool::smart_ptr&& temp_writer_data, + eprosima::ProxyPool::smart_ptr& temp_writer_data, const AsyncGetTypeWriterCallback& callback) { - ReturnCode_t result = check_type_identifier_received(std::move(temp_writer_data), callback); - if (RETCODE_OK == result) - { - // The type is already known, invoke the callback - callback(std::move(temp_writer_data)); - } - return result; + return check_type_identifier_received( + temp_writer_data, callback, async_get_type_writer_callbacks_); } ReturnCode_t TypeLookupManager::async_get_type( - eprosima::ProxyPool::smart_ptr&& temp_reader_data, + eprosima::ProxyPool::smart_ptr& temp_reader_data, const AsyncGetTypeReaderCallback& callback) { - ReturnCode_t result = check_type_identifier_received(std::move(temp_reader_data), callback); - if (RETCODE_OK == result) - { - // The type is already known, invoke the callback - callback(std::move(temp_reader_data)); - } - return result; + return check_type_identifier_received( + temp_reader_data, callback, async_get_type_reader_callbacks_); } +template ReturnCode_t TypeLookupManager::check_type_identifier_received( - const xtypes::TypeIdentfierWithSize& type_identifier_with_size, - const fastrtps::rtps::GuidPrefix_t& type_server) + typename eprosima::ProxyPool::smart_ptr& temp_proxy_data, + const AsyncCallback& callback, + std::unordered_map::smart_ptr, + AsyncCallback>>>& async_get_type_callbacks) { + xtypes::TypeIdentfierWithSize type_identifier_with_size = + temp_proxy_data->type_information().type_information.complete().typeid_with_size(); + fastrtps::rtps::GuidPrefix_t type_server = temp_proxy_data->guid().guidPrefix; + // Check if the type is known if (fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). is_type_identifier_known(type_identifier_with_size)) { + // The type is already known, invoke the callback + callback(temp_proxy_data); return RETCODE_OK; } - // Check if TypeIdentfierWithSize already exists in the map - auto writer_it = async_get_type_writer_callbacks_.find(type_identifier_with_size); - if (writer_it != async_get_type_writer_callbacks_.end()) - { - // Return without sending new request - return RETCODE_NO_DATA; - } - - // If not found in the writer map, check the reader map - auto reader_it = async_get_type_reader_callbacks_.find(type_identifier_with_size); - if (reader_it != async_get_type_reader_callbacks_.end()) { - // Return without sending new request - return RETCODE_NO_DATA; + // Check if TypeIdentfierWithSize already exists in the map + std::lock_guard lock(async_get_types_mutex_); + auto it = async_get_type_callbacks.find(type_identifier_with_size); + if (it != async_get_type_callbacks.end()) + { + // TypeIdentfierWithSize exists, add the callback + it->second.push_back(std::make_pair(std::move(temp_proxy_data), callback)); + // Return without sending new request + return RETCODE_NO_DATA; + } } // TypeIdentfierWithSize doesn't exist, create a new entry - xtypes::TypeIdentifierSeq unknown_type{type_identifier_with_size.type_id()}; - SampleIdentity get_type_dependencies_request = get_type_dependencies(unknown_type, type_server); + SampleIdentity get_type_dependencies_request = get_type_dependencies( + {type_identifier_with_size.type_id()}, type_server); if (INVALID_SAMPLE_IDENTITY != get_type_dependencies_request) { - // Store the sent request + // Store the sent requests and callback add_async_get_type_request(get_type_dependencies_request, type_identifier_with_size); + std::vector::smart_ptr, AsyncCallback>> types; + types.push_back(std::make_pair(std::move(temp_proxy_data), callback)); + async_get_type_callbacks.emplace(type_identifier_with_size, std::move(types)); + return RETCODE_NO_DATA; } else @@ -370,75 +378,6 @@ ReturnCode_t TypeLookupManager::check_type_identifier_received( } } -ReturnCode_t TypeLookupManager::check_type_identifier_received( - eprosima::ProxyPool::smart_ptr&& temp_writer_data, - const AsyncGetTypeWriterCallback& callback) -{ - return check_type_identifier_received_impl( - std::move(temp_writer_data), callback, async_get_type_writer_callbacks_); -} - -ReturnCode_t TypeLookupManager::check_type_identifier_received( - eprosima::ProxyPool::smart_ptr&& temp_reader_data, - const AsyncGetTypeReaderCallback& callback) -{ - return check_type_identifier_received_impl( - std::move(temp_reader_data), callback, async_get_type_reader_callbacks_); -} - -template -ReturnCode_t TypeLookupManager::check_type_identifier_received_impl( - typename eprosima::ProxyPool::smart_ptr&& temp_proxy_data, - const AsyncCallback& callback, - std::unordered_map::smart_ptr, - AsyncCallback>>>& async_get_type_callbacks) -{ - xtypes::TypeIdentfierWithSize type_identifier_with_size = - temp_proxy_data->type_information().type_information.complete().typeid_with_size(); - fastrtps::rtps::GuidPrefix_t type_server = temp_proxy_data->guid().guidPrefix; - - // Check if the type is known - if (fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). - is_type_identifier_known(type_identifier_with_size)) - { - return RETCODE_OK; - } - - // Check if TypeIdentfierWithSize already exists in the map - std::lock_guard lock(async_get_types_mutex_); - auto it = async_get_type_callbacks.find(type_identifier_with_size); - if (it != async_get_type_callbacks.end()) - { - // TypeIdentfierWithSize exists, add the callback - it->second.push_back(std::make_pair(std::move(temp_proxy_data), callback)); - // Return without sending new request - return RETCODE_NO_DATA; - } - else - { - // TypeIdentfierWithSize doesn't exist, create a new entry - xtypes::TypeIdentifierSeq unknown_type{type_identifier_with_size.type_id()}; - SampleIdentity get_type_dependencies_request = get_type_dependencies(unknown_type, type_server); - if (INVALID_SAMPLE_IDENTITY != get_type_dependencies_request) - { - // Store the sent requests and callback - add_async_get_type_request(get_type_dependencies_request, type_identifier_with_size); - std::vector::smart_ptr, AsyncCallback>> types; - types.push_back(std::make_pair(std::move(temp_proxy_data), callback)); - async_get_type_callbacks.emplace(type_identifier_with_size, std::move(types)); - - return RETCODE_NO_DATA; - } - else - { - // Failed to send request, return error - EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Failed to send get_type_dependencies request"); - return RETCODE_ERROR; - } - } -} - void TypeLookupManager::notify_callbacks( xtypes::TypeIdentfierWithSize type_identifier_with_size) { @@ -448,7 +387,7 @@ void TypeLookupManager::notify_callbacks( { for (auto& proxy_callback_pair : writer_callbacks_it->second) { - proxy_callback_pair.second(std::move(proxy_callback_pair.first)); + proxy_callback_pair.second(proxy_callback_pair.first); } //Erase the solved TypeIdentfierWithSize remove_async_get_type_callback(type_identifier_with_size); @@ -459,7 +398,7 @@ void TypeLookupManager::notify_callbacks( { for (auto& proxy_callback_pair : reader_callbacks_it->second) { - proxy_callback_pair.second(std::move(proxy_callback_pair.first)); + proxy_callback_pair.second(proxy_callback_pair.first); } // Erase the solved TypeIdentfierWithSize remove_async_get_type_callback(type_identifier_with_size); @@ -524,7 +463,7 @@ bool TypeLookupManager::remove_async_get_type_callback( } } -bool TypeLookupManager::remove_async_get_types_request( +bool TypeLookupManager::remove_async_get_type_request( SampleIdentity request) { std::unique_lock lock(async_get_types_mutex_); @@ -536,7 +475,7 @@ bool TypeLookupManager::remove_async_get_types_request( catch (const std::exception& e) { EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, - "Error in TypeLookupManager::remove_async_get_types_request: " << e.what()); + "Error in TypeLookupManager::remove_async_get_type_request: " << e.what()); return false; } } @@ -563,6 +502,7 @@ bool TypeLookupManager::create_endpoints() watt.endpoint.topicKind = fastrtps::rtps::NO_KEY; watt.endpoint.reliabilityKind = fastrtps::rtps::RELIABLE; watt.endpoint.durabilityKind = fastrtps::rtps::VOLATILE; + watt.mode = fastrtps::rtps::ASYNCHRONOUS_WRITER; // Built-in request writer request_listener_ = new TypeLookupRequestListener(this); @@ -716,95 +656,102 @@ bool TypeLookupManager::create_endpoints() return ret; } -bool TypeLookupManager::send_request( +TypeLookup_Request* TypeLookupManager::create_request( const fastrtps::rtps::GuidPrefix_t& type_server, - TypeLookup_Request& request) const + TypeLookup_RequestPubSubType& pupsubtype) const { - request.header().instanceName() = get_instance_name(type_server); - request.header().requestId().writer_guid(guid_rtps_2_dds(builtin_request_writer_->getGuid())); - request.header().requestId().sequence_number(sequence_number_rtps_2_dds(request_seq_number_)); + TypeLookup_Request* request = static_cast(pupsubtype.createData()); + request->header().instanceName() = get_instance_name(type_server); + request->header().requestId().writer_guid(guid_rtps_2_dds(builtin_request_writer_->getGuid())); + request->header().requestId().sequence_number(sequence_number_rtps_2_dds(request_seq_number_)); request_seq_number_++; + return request; +} - CacheChange_t* change = builtin_request_writer_->new_change( - [&request]() - { - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size(request, current_alignment) + 4); - }, - ALIVE); - - if (change != nullptr) - { - CDRMessage_t msg(change->serializedPayload); - - bool valid = CDRMessage::addOctet(&msg, 0); - change->serializedPayload.encapsulation = static_cast(PL_DEFAULT_ENCAPSULATION); - msg.msg_endian = DEFAULT_ENDIAN; - valid &= CDRMessage::addOctet(&msg, PL_DEFAULT_ENCAPSULATION); - valid &= CDRMessage::addUInt16(&msg, 0); - - change->serializedPayload.pos = msg.pos; - change->serializedPayload.length = msg.length; +bool TypeLookupManager::prepare_send_payload( + fastrtps::rtps::CacheChange_t* change, + fastrtps::rtps::SerializedPayload_t& payload) const +{ + CDRMessage_t msg(change->serializedPayload); + bool valid = CDRMessage::addOctet(&msg, 0); + change->serializedPayload.encapsulation = static_cast(PL_DEFAULT_ENCAPSULATION); + msg.msg_endian = DEFAULT_ENDIAN; + valid &= CDRMessage::addOctet(&msg, PL_DEFAULT_ENCAPSULATION); + valid &= CDRMessage::addUInt16(&msg, 0); + change->serializedPayload.pos = msg.pos; + change->serializedPayload.length = msg.length; + payload.max_size = change->serializedPayload.max_size - 4; + payload.data = change->serializedPayload.data + 4; + return valid; +} - SerializedPayload_t payload; - payload.max_size = change->serializedPayload.max_size - 4; - payload.data = change->serializedPayload.data + 4; - if (valid && request_type_.serialize(&request, &payload, DataRepresentationId_t::XCDR2_DATA_REPRESENTATION)) - { - change->serializedPayload.length += payload.length; - change->serializedPayload.pos += payload.pos; - payload.data = nullptr; - return builtin_request_writer_history_->add_change(change); - } - } - builtin_request_writer_history_->remove_change(change); - return false; +bool TypeLookupManager::send( + TypeLookup_Request& request) const +{ + return send_impl(request, &request_type_, builtin_request_writer_, builtin_request_writer_history_); } -bool TypeLookupManager::send_reply( +bool TypeLookupManager::send( TypeLookup_Reply& reply) const { - CacheChange_t* change = builtin_reply_writer_->new_change( - [&reply]() + return send_impl(reply, &reply_type_, builtin_reply_writer_, builtin_reply_writer_history_); +} + +template +bool TypeLookupManager::send_impl( + Type& msg, + PubSubType* pubsubtype, + fastrtps::rtps::StatefulWriter* writer, + fastrtps::rtps::WriterHistory* writer_history) const +{ + // Create a new CacheChange_t using the provided StatefulWriter + CacheChange_t* change = writer->new_change( + [&msg]() { + // Calculate the serialized size of the message using a CdrSizeCalculator eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size(reply, current_alignment) + 4); + return static_cast(calculator.calculate_serialized_size(msg, current_alignment) + 4); }, ALIVE); - if (change != nullptr) + // Check if the creation of CacheChange_t was successful + if (!change) { - CDRMessage_t msg(change->serializedPayload); + return false; + } - bool valid = CDRMessage::addOctet(&msg, 0); - change->serializedPayload.encapsulation = static_cast(PL_DEFAULT_ENCAPSULATION); - msg.msg_endian = DEFAULT_ENDIAN; - valid &= CDRMessage::addOctet(&msg, PL_DEFAULT_ENCAPSULATION); - valid &= CDRMessage::addUInt16(&msg, 0); + // Prepare the payload for sending the message + SerializedPayload_t payload; + if (!prepare_send_payload(change, payload)) + { + return false; + } - change->serializedPayload.pos = msg.pos; - change->serializedPayload.length = msg.length; + // Serialize the message using the provided PubSubType + bool result = pubsubtype->serialize(&msg, &payload, DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); + // If serialization was successful, update the change and add it to the WriterHistory + if (result) + { + change->serializedPayload.length += payload.length; + change->serializedPayload.pos += payload.pos; + result = writer_history->add_change(change); + } + // Release the payload data + payload.data = nullptr; - SerializedPayload_t payload; - payload.max_size = change->serializedPayload.max_size - 4; - payload.data = change->serializedPayload.data + 4; - if (valid && reply_type_.serialize(&reply, &payload, DataRepresentationId_t::XCDR2_DATA_REPRESENTATION)) - { - change->serializedPayload.length += payload.length; - change->serializedPayload.pos += payload.pos; - payload.data = nullptr; - return builtin_reply_writer_history_->add_change(change); - } + // If adding the change to WriterHistory failed, remove the change + if (!result) + { + writer_history->remove_change(change); } - builtin_request_writer_history_->remove_change(change); - return false; + + return result; } -bool TypeLookupManager::receive_request( +bool TypeLookupManager::prepare_receive_payload( fastrtps::rtps::CacheChange_t& change, - TypeLookup_Request& request) const + SerializedPayload_t& payload) const { CDRMessage_t msg(change.serializedPayload); msg.pos += 1; @@ -825,55 +772,54 @@ bool TypeLookupManager::receive_request( change.serializedPayload.encapsulation = static_cast(encapsulation); msg.pos += 2; // Skip encapsulation options. - SerializedPayload_t payload; + //SerializedPayload_t payload; payload.max_size = change.serializedPayload.max_size - 4; payload.length = change.serializedPayload.length - 4; payload.data = change.serializedPayload.data + 4; - bool result = request_type_.deserialize(&payload, &request); - payload.data = nullptr; - if (result && request.header().instanceName() != local_instance_name_) + return true; +} + +bool TypeLookupManager::receive( + fastrtps::rtps::CacheChange_t& change, + TypeLookup_Request& request) const +{ + if (receive_impl(change, request, &request_type_) && + request.header().instanceName() != local_instance_name_) { // Ignore request - result = false; + return false; } - return result; + return true; } -bool TypeLookupManager::receive_reply( +bool TypeLookupManager::receive( fastrtps::rtps::CacheChange_t& change, TypeLookup_Reply& reply) const { - CDRMessage_t msg(change.serializedPayload); - msg.pos += 1; - octet encapsulation = 0; - CDRMessage::readOctet(&msg, &encapsulation); - if (encapsulation == PL_CDR_BE) - { - msg.msg_endian = BIGEND; - } - else if (encapsulation == PL_CDR_LE) - { - msg.msg_endian = LITTLEEND; - } - else + if (receive_impl(change, reply, &reply_type_) && + guid_dds_2_rtps(reply.header().relatedRequestId().writer_guid()) != builtin_request_writer_->getGuid()) { + // Ignore reply return false; } - change.serializedPayload.encapsulation = static_cast(encapsulation); - msg.pos += 2; // Skip encapsulation options. + return true; +} +template +bool TypeLookupManager::receive_impl( + fastrtps::rtps::CacheChange_t& change, + Type& msg, + PubSubType* pubsubtype) const +{ SerializedPayload_t payload; - payload.max_size = change.serializedPayload.max_size - 4; - payload.length = change.serializedPayload.length - 4; - payload.data = change.serializedPayload.data + 4; - bool result = reply_type_.deserialize(&payload, &reply); - payload.data = nullptr; - if (result && - guid_dds_2_rtps(reply.header().relatedRequestId().writer_guid()) != builtin_request_writer_->getGuid()) + if (!prepare_receive_payload(change, payload)) { - // Ignore reply - result = false; + return false; } + + bool result = pubsubtype->deserialize(&payload, &msg); + payload.data = nullptr; + return result; } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index 46f47d1bdd2..b37328072e6 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP -#define _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP +#ifndef _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_SERVICE_MANAGER_HPP_ +#define _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_SERVICE_MANAGER_HPP_ #include #include @@ -104,9 +104,9 @@ namespace builtin { const SampleIdentity INVALID_SAMPLE_IDENTITY; using AsyncGetTypeWriterCallback = std::function< - void (eprosima::ProxyPool::smart_ptr && temp_writer_data)>; + void (eprosima::ProxyPool::smart_ptr&)>; using AsyncGetTypeReaderCallback = std::function< - void (eprosima::ProxyPool::smart_ptr && temp_reader_data)>; + void (eprosima::ProxyPool::smart_ptr&)>; /** * Class TypeLookupManager that implements the TypeLookup Service described in the DDS-XTYPES 1.3 specification. @@ -153,7 +153,7 @@ class TypeLookupManager * Create and send a request using the builtin TypeLookup Service to retrieve all the type dependencies * associated with a sequence of TypeIdentifiers. * @param id_seq[in] Sequence of TypeIdentifiers for which dependencies are needed. - * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. + * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being resolved. * @param continuation_point[in] Continuation point for a previous partially answered request. * @return The SampleIdentity of the sent request. */ @@ -183,48 +183,15 @@ class TypeLookupManager * RETCODE_ERROR if any request was not sent correctly. */ ReturnCode_t async_get_type( - eprosima::ProxyPool::smart_ptr&& temp_proxy_data, + eprosima::ProxyPool::smart_ptr& temp_proxy_data, const AsyncGetTypeWriterCallback& callback); ReturnCode_t async_get_type( - eprosima::ProxyPool::smart_ptr&& temp_proxy_data, + eprosima::ProxyPool::smart_ptr& temp_proxy_data, const AsyncGetTypeReaderCallback& callback); private: /** - * Checks if the given TypeIdentfierWithSize is known by the TypeObjectRegistry. - * Uses get_type_dependencies() and get_types() to get those that are not known. - * Adds a callback to the async_get_type_callbacks_ entry of the TypeIdentfierWithSize, or creates a new one if - * TypeIdentfierWithSize was not in the map before. - * @param type_identifier_with_size[in] TypeIdentfierWithSize to check. - * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. - * @return ReturnCode_t RETCODE_OK if type is known. - * RETCODE_NO_DATA if the type is being discovered. - * RETCODE_ERROR if the request was not sent or the callback was not added correctly. - */ - ReturnCode_t check_type_identifier_received( - const xtypes::TypeIdentfierWithSize& type_identifier_with_size, - const fastrtps::rtps::GuidPrefix_t& type_server); - /** - * Checks if the given TypeIdentfierWithSize is known by the TypeObjectRegistry. - * Uses get_type_dependencies() and get_types() to get those that are not known. - * Adds a callback to the async_get_type_callbacks_ entry of the TypeIdentfierWithSize, or creates a new one if - * TypeIdentfierWithSize was not in the map before. - * @param temp_proxy_data[in] Temporary Writer/Reader ProxyData that originated the request. - * @param callback[in] Callback to add. - * @return ReturnCode_t RETCODE_OK if type is known. - * RETCODE_NO_DATA if the type is being discovered. - * RETCODE_ERROR if the request was not sent or the callback was not added correctly. - */ - ReturnCode_t check_type_identifier_received( - eprosima::ProxyPool::smart_ptr&& temp_writer_data, - const AsyncGetTypeWriterCallback& callback); - ReturnCode_t check_type_identifier_received( - eprosima::ProxyPool::smart_ptr&& temp_reader_data, - const AsyncGetTypeReaderCallback& callback); - - /** - * Implementation for check_type_identifier_received method. * Checks if the given TypeIdentfierWithSize is known by the TypeObjectRegistry. * Uses get_type_dependencies() and get_types() to get those that are not known. * Adds a callback to the async_get_type_callbacks_ entry of the TypeIdentfierWithSize, or creates a new one if @@ -237,8 +204,8 @@ class TypeLookupManager * RETCODE_ERROR if the request was not sent or the callback was not added correctly. */ template - ReturnCode_t check_type_identifier_received_impl( - typename eprosima::ProxyPool::smart_ptr&& temp_proxy_data, + ReturnCode_t check_type_identifier_received( + typename eprosima::ProxyPool::smart_ptr& temp_proxy_data, const AsyncCallback& callback, std::unordered_map::smart_ptr, @@ -275,47 +242,104 @@ class TypeLookupManager * @param request[in] SampleIdentity to be removed. * @return true if removed, false otherwise. */ - bool remove_async_get_types_request( + bool remove_async_get_type_request( SampleIdentity request); /** - * Complete requests common fields, create CacheChange, serialize request and add change to writer history. - * @param type_id[in] TypeIdentfierWithSize that originated the request. + * Creates a TypeLookup_Request with for the choosen type_server. + * @param type_server[in] GuidPrefix_t corresponding to the remote participant. + * @param pupsubtype[out] PubSubType in charge of TypeLookup_Request . + * @return the TypeLookup_Request created. + */ + TypeLookup_Request* create_request( + const fastrtps::rtps::GuidPrefix_t& type_server, + TypeLookup_RequestPubSubType& pupsubtype) const; + + /** + * Prepares the the payload for sending a CacheChange before serializing. + * @param change[in] CacheChange_t received. + * @param payload[out] SerializedPayload_t prepared. + * @return true if received payload is prepared, false otherwise. + */ + bool prepare_send_payload( + fastrtps::rtps::CacheChange_t* change, + fastrtps::rtps::SerializedPayload_t& payload) const; + + /** + * Uses the send_impl with the appropriate parameters. * @param request[in] TypeLookup_Request to be sent. * @return true if request was sent, false otherwise. */ - bool send_request( - const fastrtps::rtps::GuidPrefix_t& type_server, + bool send( TypeLookup_Request& request) const; - /** - * Complete reply common fields, create CacheChange, serialize reply and add change to writer history. + * Uses the send_impl with the appropriate parameters. * @param reply[in] TypeLookup_Reply to be sent. * @return true if reply was sent, false otherwise. */ - bool send_reply( + bool send( TypeLookup_Reply& reply) const; /** - * Used for request reception. Deserialize the request and check if it is directed to the local DomainParticipant. + * Implementation for the send methods. + * Creates CacheChange, serializes the message and adds change to writer history. + * @param msg[in] Message to be sent. + * @param pubsubtype[in] PubSubType of the msg. + * @param writer[in]Pointer to the RTPSWriter. + * @param writer_history[in] Pointer to the Writer History. + * @return true if message was sent, false otherwise. + */ + template + bool send_impl( + Type& msg, + PubSubType* pubsubtype, + fastrtps::rtps::StatefulWriter* writer, + fastrtps::rtps::WriterHistory* writer_history) const; + + /** + * Prepares the the received payload of a CacheChange before deserializing. + * @param change[in] CacheChange_t received. + * @param payload[out] SerializedPayload_t prepared. + * @return true if received payload is prepared, false otherwise. + */ + bool prepare_receive_payload( + fastrtps::rtps::CacheChange_t& change, + fastrtps::rtps::SerializedPayload_t& payload) const; + + /** + * Uses the send_impl with the appropriate parameters and checks if it is directed to the local DomainParticipant. * @param change[in] CacheChange_t of the request. * @param request[out] TypeLookup_Request after deserialization. * @return true if the request is deserialized and directed to the local participant, false otherwise. */ - bool receive_request( + bool receive( fastrtps::rtps::CacheChange_t& change, TypeLookup_Request& request) const; /** - * Used for reply reception. Deserialize and check that the reply's recipient is the local participant. + * Uses the send_impl with the appropriate parameters and checks if that the reply's recipient is the local participant. * @param change[in] CacheChange_t of the reply. * @param reply[out] TypeLookup_Reply after deserialize. * @return true if the request is deserialized and the reply's recipient is us, false otherwise. */ - bool receive_reply( + bool receive( fastrtps::rtps::CacheChange_t& change, TypeLookup_Reply& reply) const; + /** + * Implementation for the receive methods. + * Derializes the message received. + * @param change[in] CacheChange_t of the message. + * @param msg[in] Message to be sent. + * @param pubsubtype[in] PubSubType of the msg. + * @return true if message is correct, false otherwise. + */ + template + bool receive_impl( + fastrtps::rtps::CacheChange_t& change, + Type& msg, + PubSubType* pubsubtype) const; + /** * Get the RTPS participant * @return RTPS participant @@ -418,4 +442,4 @@ class TypeLookupManager } /* namespace dds */ } /* namespace fastdds */ } /* namespace eprosima */ -#endif /* _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP */ +#endif /* _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_SERVICE_MANAGER_HPP_ */ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index a65c113b136..48ad324c7e2 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -21,23 +21,16 @@ #include #include -#include -#include -#include -#include -#include #include #include #include - using eprosima::fastrtps::rtps::RTPSReader; using eprosima::fastrtps::rtps::CacheChange_t; using eprosima::fastdds::dds::Log; using eprosima::fastrtps::rtps::c_EntityId_TypeLookup_reply_writer; - namespace eprosima { namespace fastdds { namespace dds { @@ -47,10 +40,96 @@ TypeLookupReplyListener::TypeLookupReplyListener( TypeLookupManager* manager) : typelookup_manager_(manager) { + start_reply_processor_thread(); } TypeLookupReplyListener::~TypeLookupReplyListener() { + stop_reply_processor_thread(); +} + +void TypeLookupReplyListener::start_reply_processor_thread() +{ + std::unique_lock guard(replies_processor_cv_mutex_); + // Check if is not already in progress and the thread is not joinable + if (!processing_ && !replies_processor_thread.joinable()) + { + processing_ = true; + // Lambda function to be executed by the thread + auto thread_func = [this]() + { + process_reply(); + }; + // Create and start the processing thread + replies_processor_thread = eprosima::create_thread(thread_func, + typelookup_manager_->participant_->getAttributes().typelookup_service_threads, + "dds.tls.replies.%u"); + } +} + +void TypeLookupReplyListener::stop_reply_processor_thread() +{ + { + // Set processing_ to false to signal the processing thread to stop + std::unique_lock guard(replies_processor_cv_mutex_); + processing_ = false; + } + + if (replies_processor_thread.joinable()) + { + // Notify the processing thread to wake up and check the exit condition + replies_processor_cv_.notify_all(); + // Check if the calling thread is not the processing thread and join it + if (!replies_processor_thread.is_calling_thread()) + { + replies_processor_thread.join(); + } + } +} + +void TypeLookupReplyListener::process_reply() +{ + std::unique_lock guard(replies_processor_cv_mutex_); + + while (processing_) + { + // Wait until either processing is done or there are replies in the queue + replies_processor_cv_.wait(guard, + [&]() + { + return !processing_ || !replies_queue_.empty(); + }); + + if (!replies_queue_.empty()) + { + TypeLookup_Reply& reply = replies_queue_.front().reply; + { + // Process the TypeLookup_Reply based on its type + switch (reply.return_value()._d()) + { + case TypeLookup_getTypes_HashId: + { + check_get_types_reply(reply.header().relatedRequestId(), + reply.return_value().getType().result()); + break; + } + case TypeLookup_getDependencies_HashId: + { + check_get_type_dependencies_reply( + reply.header().relatedRequestId(), replies_queue_.front().type_server, + reply.return_value().getTypeDependencies().result()); + break; + } + default: + // If the type of request is not known, log an error + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REPLY_LISTENER, "Received uknown reply type."); + break; + } + } + // Remove the requests from the queue + replies_queue_.pop(); + } + } } void TypeLookupReplyListener::check_get_types_reply( @@ -61,17 +140,31 @@ void TypeLookupReplyListener::check_get_types_reply( auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); if (requests_it != typelookup_manager_->async_get_type_requests_.end()) { + ReturnCode_t register_result = RETCODE_ERROR; for (xtypes::TypeIdentifierTypeObjectPair pair : reply.types()) { - if (RETCODE_OK == fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + if (RETCODE_OK != fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). register_type_object(pair.type_identifier(), pair.type_object())) { - // Notify the callbacks associated with the request - typelookup_manager_->notify_callbacks(requests_it->second); + // If registration fails for any type, break out of the loop + register_result = RETCODE_PRECONDITION_NOT_MET; + break; } } + + if (RETCODE_OK == register_result) + { + // Notify the callbacks associated with the request + typelookup_manager_->notify_callbacks(requests_it->second); + } + else + { + // If any of the types is not registered, log error + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REPLY_LISTENER, "Error registering type."); + } + // Remove the processed SampleIdentity from the outstanding requests - typelookup_manager_->remove_async_get_types_request(request_id); + typelookup_manager_->remove_async_get_type_request(request_id); } } @@ -88,22 +181,37 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( return; } - // Check each dependent TypeIdentifierWithSize to ensure all dependencies are known - bool all_dependencies_known = std::all_of( - reply.dependent_typeids().begin(), reply.dependent_typeids().end(), - [&](const xtypes::TypeIdentfierWithSize& type_id) + // Add the dependent types to the list for the get_type request + xtypes::TypeIdentifierSeq needed_types; + std::unordered_set unique_types; + + for (xtypes::TypeIdentfierWithSize type : reply.dependent_typeids()) + { + // Check if the type is known + if (!fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + is_type_identifier_known(type)) { - // Check if the dependent TypeIdentifierWithSize is known; creating a new request if it is not - return RETCODE_OK == typelookup_manager_->check_type_identifier_received(type_id, type_server); - }); + // Insert the type into the unordered_set and check if the insertion was successful + if (unique_types.insert(type.type_id()).second) + { + // If the insertion was successful, it means the type was not already in the set + needed_types.push_back(type.type_id()); + } + // If the insertion was not successful, the type is a duplicate and can be ignored + } + } - // If the received reply has continuation point, send next request - if (!reply.continuation_point().empty()) + // If there is no continuation point, add the parent type + if (reply.continuation_point().empty()) + { + needed_types.push_back(requests_it->second.type_id()); + } + // Make a new request with the continuation point + else { - // Make a new request with the continuation point - xtypes::TypeIdentifierSeq unknown_type{requests_it->second.type_id()}; SampleIdentity next_request_id = typelookup_manager_-> - get_type_dependencies(unknown_type, type_server, reply.continuation_point()); + get_type_dependencies({requests_it->second.type_id()}, type_server, + reply.continuation_point()); if (INVALID_SAMPLE_IDENTITY != next_request_id) { // Store the sent requests and associated TypeIdentfierWithSize @@ -112,31 +220,26 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( else { // Failed to send request - EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Failed to send get_type_dependencies request"); + EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE_REPLY_LISTENER, "Failed to send get_type_dependencies request"); } } - // If all dependencies are known and there is no continuation point, request the parent type - else if (all_dependencies_known) - { - xtypes::TypeIdentifierSeq unknown_type{requests_it->second.type_id()}; - // Initiate a type request to obtain the parent type - SampleIdentity get_types_request = typelookup_manager_->get_types(unknown_type, type_server); + // Send the type request + SampleIdentity get_types_request = typelookup_manager_->get_types(needed_types, type_server); - if (INVALID_SAMPLE_IDENTITY != get_types_request) - { - // Store the type request - typelookup_manager_->add_async_get_type_request(get_types_request, requests_it->second); - } - else - { - // Failed to send request - EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Failed to send get_types request"); - } + if (INVALID_SAMPLE_IDENTITY != get_types_request) + { + // Store the type request + typelookup_manager_->add_async_get_type_request(get_types_request, requests_it->second); + } + else + { + // Failed to send request + EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE_REPLY_LISTENER, "Failed to send get_types request"); } // Remove the processed SampleIdentity from the outstanding requests - typelookup_manager_->remove_async_get_types_request(request_id); + typelookup_manager_->remove_async_get_type_request(request_id); } void TypeLookupReplyListener::onNewCacheChangeAdded( @@ -152,27 +255,27 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( EPROSIMA_LOG_WARNING(TL_REPLY_READER, "Received data from a bad endpoint."); reader->getHistory()->remove_change(change); } - EPROSIMA_LOG_INFO(TYPELOOKUP_SERVICE_REPLY_LISTENER, "Received new cache change"); // Process the received TypeLookup Reply and handle different types of replies TypeLookup_Reply reply; - if (typelookup_manager_->receive_reply(*change, reply)) + if (typelookup_manager_->receive(*change, reply)) { - switch (reply.return_value()._d()) + // Check if the reply has any exceptions + if (reply.header().remoteEx() != rpc::RemoteExceptionCode_t::REMOTE_EX_OK) { - case TypeLookup_getTypes_HashId: - { - check_get_types_reply(reply.header().relatedRequestId(), reply.return_value().getType().result()); - break; - } - case TypeLookup_getDependencies_HashId: - { - check_get_type_dependencies_reply(reply.header().relatedRequestId(), change->writerGUID.guidPrefix, - reply.return_value().getTypeDependencies().result()); - break; - } - default: - break; + // TODO: Implement specific handling for each exception + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REPLY_LISTENER, + "Received reply with exception code: " << static_cast(reply.header().remoteEx())); + // If the reply was not ok, ignore it + return; + } + + // Add reply to the processing queue + replies_queue_.push(ReplyWithServerGUID{reply, change->writerGUID.guidPrefix}); + { + // Notify processor + std::unique_lock guard(replies_processor_cv_mutex_); + replies_processor_cv_.notify_all(); } } @@ -188,6 +291,7 @@ void TypeLookupReplyListener::onWriterChangeReceivedByAll( } } // namespace builtin + } // namespace dds } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 6176fa7016f..c50697d460b 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -17,12 +17,20 @@ * */ -#ifndef _FASTDDS_TYPELOOKUP_SERVICE_REPLY_LISTENER_HPP_ -#define _FASTDDS_TYPELOOKUP_SERVICE_REPLY_LISTENER_HPP_ +#ifndef _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REPLY_LISTENER_HPP_ +#define _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REPLY_LISTENER_HPP_ + +#include +#include +#include +#include +#include #include #include +#include +#include namespace eprosima { namespace fastrtps { @@ -40,6 +48,12 @@ namespace builtin { class TypeLookupManager; +struct ReplyWithServerGUID +{ + TypeLookup_Reply reply; + fastrtps::rtps::GuidPrefix_t type_server; +}; + /** * Class TypeLookupReplyListener that receives the typelookup request messages of remote endpoints. * @ingroup TYPES_MODULE @@ -60,9 +74,26 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa */ virtual ~TypeLookupReplyListener() override; +private: + + /** + * @brief Starts the thread that process the received replies. + */ + void start_reply_processor_thread(); + + /** + * @brief Stops the thread that process the received replies. + */ + void stop_reply_processor_thread(); + + /** + * @brief Process the replies in the queue. + */ + void process_reply(); + /** * @brief Registers TypeIdentifier and TypeObject in TypeObjectRegistry. - * Also notifies all callbacks for the type and removes the current SampleIdentity from the list. + * This method also notifies all type related callbacks and removes the current SampleIdentity from the pending request list. * @param request_id[in] The SampleIdentity of the request. * @param reply[in] The reply data. */ @@ -93,23 +124,20 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; - /** - * @brief This method is called when all the readers matched with this Writer acknowledge that a cache - * change has been received. - * @param change The cache change - */ - void onWriterChangeReceivedByAll( - fastrtps::rtps::RTPSWriter*, - fastrtps::rtps::CacheChange_t* change) override; - -private: //! A pointer to the typelookup manager. TypeLookupManager* typelookup_manager_; + + eprosima::thread replies_processor_thread; + std::queue replies_queue_; + std::mutex replies_processor_cv_mutex_; + std::condition_variable replies_processor_cv_; + bool processing_; + rtps::ThreadSettings replies_processor_thread_settings_; }; } /* namespace builtin */ } /* namespace dds */ } /* namespace fastdds */ } /* namespace eprosima */ -#endif /* _FASTDDS_TYPELOOKUP_SERVICE_REPLY_LISTENER_HPP_*/ +#endif /* _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REPLY_LISTENER_HPP_*/ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index 9ed4d74be0a..fe84416bd14 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -19,18 +19,10 @@ #include -#include -#include -#include - -#include -#include #include -#include -#include -#include #include +#include #include using eprosima::fastrtps::rtps::RTPSReader; @@ -70,13 +62,13 @@ inline size_t calculate_continuation_point( * @return The continuation_point. */ inline std::vector create_continuation_point( - int value) + size_t value) { std::vector continuation_point(32, 0); - for (int value_i = 0; value_i < value; value_i++) + for (size_t value_i = 0; value_i < value; value_i++) { - for (int i = continuation_point.size() - 1; i >= 0; --i) + for (size_t i = continuation_point.size() - 1; i != SIZE_MAX; --i) { if (continuation_point[i] < 255) { @@ -97,40 +89,158 @@ TypeLookupRequestListener::TypeLookupRequestListener( TypeLookupManager* manager) : typelookup_manager_(manager) { + start_request_processor_thread(); } TypeLookupRequestListener::~TypeLookupRequestListener() { + stop_request_processor_thread(); +} + +void TypeLookupRequestListener::start_request_processor_thread() +{ + std::unique_lock guard(request_processor_cv_mutex_); + // Check if is not already in progress and the thread is not joinable + if (!processing_ && !request_processor_thread.joinable()) + { + processing_ = true; + // Lambda function to be executed by the thread + auto thread_func = [this]() + { + process_requests(); + }; + // Create and start the processing thread + request_processor_thread = eprosima::create_thread(thread_func, + typelookup_manager_->participant_->getAttributes().typelookup_service_threads, + "dds.tls.requests.%u"); + } +} + +void TypeLookupRequestListener::stop_request_processor_thread() +{ + { + // Set processing_ to false to signal the processing thread to stop + std::unique_lock guard(request_processor_cv_mutex_); + processing_ = false; + } + + if (request_processor_thread.joinable()) + { + // Notify the processing thread to wake up and check the exit condition + request_processor_cv_.notify_all(); + // Check if the calling thread is not the processing thread and join it + if (!request_processor_thread.is_calling_thread()) + { + request_processor_thread.join(); + } + } +} + +void TypeLookupRequestListener::process_requests() +{ + std::unique_lock guard(request_processor_cv_mutex_); + + while (processing_) + { + // Wait until either processing is done or there are requests in the queue + request_processor_cv_.wait(guard, + [&]() + { + return !processing_ || !requests_queue_.empty(); + }); + + if (!requests_queue_.empty()) + { + TypeLookup_Request& request = requests_queue_.front(); + { + // Process the TypeLookup_Request based on its type + switch (request.data()._d()) + { + case TypeLookup_getTypes_HashId: + { + check_get_types_request(request.header().requestId(), request.data().getTypes()); + break; + } + case TypeLookup_getDependencies_HashId: + { + check_get_type_dependencies_request(request.header().requestId(), + request.data().getTypeDependencies()); + break; + } + default: + // If the type of request is not known, log an error and answer with an exception + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "Received unknown request type."); + answer_request( + request.header().requestId(), + rpc::RemoteExceptionCode_t::REMOTE_EX_UNSUPPORTED); + break; + } + } + // Remove the requests from the queue + requests_queue_.pop(); + } + } } void TypeLookupRequestListener::check_get_types_request( SampleIdentity request_id, const TypeLookup_getTypes_In& request) { + // Always Sends EK_COMPLETE + // TODO: Add a property to the participant to configure this behavior. Allowing it to respond with EK_MINIMAL when possible. TypeLookup_getTypes_Out out; + ReturnCode_t type_result = RETCODE_ERROR; + xtypes::TypeObject obj; + xtypes::TypeIdentifier complete_id; + xtypes::TypeIdentifier minimal_id; // Iterate through requested type_ids for (const xtypes::TypeIdentifier& type_id : request.type_ids()) { - xtypes::TypeObject obj; - if (RETCODE_OK == fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). - get_type_object(type_id, obj)) + // If TypeIdentifier is EK_MINIMAL add complete_to_minimal to answer + if (type_id._d() == xtypes::EK_MINIMAL) + { + minimal_id = type_id; + // Get complete TypeIdentifier from registry + complete_id = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + complete_from_minimal_type_identifier(minimal_id); + + xtypes::TypeIdentifierPair id_pair; + id_pair.type_identifier1(complete_id); + id_pair.type_identifier2(minimal_id); + // Add the id pair to the result + out.complete_to_minimal().push_back(std::move(id_pair)); + } + else { - xtypes::TypeIdentifierTypeObjectPair pair; - pair.type_identifier(type_id); - pair.type_object(obj); - // Add the pair to the result - out.types().push_back(std::move(pair)); + complete_id = type_id; } + + type_result = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + get_type_object(complete_id, obj); + if (RETCODE_OK != type_result) + { + // If any object is unknown, abort and answer with exception + break; + } + + xtypes::TypeIdentifierTypeObjectPair id_obj_pair; + id_obj_pair.type_identifier(complete_id); + id_obj_pair.type_object(obj); + // Add the id/obj pair to the result + out.types().push_back(std::move(id_obj_pair)); } - // Create and send the reply - TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); - TypeLookup_getTypes_Result result; - result.result(out); - reply->return_value().getType(result); - reply->header().relatedRequestId() = request_id; - typelookup_manager_->send_reply(*reply); - typelookup_manager_->reply_type_.deleteData(reply); + if (RETCODE_OK == type_result) + { + // Prepare and send the reply + answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_OK, out); + } + else + { + // If any of the types is not found, log error + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "Error getting type."); + answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT); + } } void TypeLookupRequestListener::check_get_type_dependencies_request( @@ -138,21 +248,25 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( const TypeLookup_getTypeDependencies_In& request) { std::unordered_set type_dependencies; - ReturnCode_t type_dependencies_result; + ReturnCode_t type_dependencies_result = RETCODE_ERROR; // Check if the received request has been done before and needed a continuation point { std::lock_guard lock(requests_with_continuation_mutex_); - auto requests_it = requests_with_continuation_.find(request.type_ids()); - if (requests_it != requests_with_continuation_.end()) + if (!request.continuation_point().empty()) { - // Get the dependencies without chechking the registry - type_dependencies = requests_it->second; - type_dependencies_result = RETCODE_OK; + auto requests_it = requests_with_continuation_.find(request.type_ids()); + if (requests_it != requests_with_continuation_.end()) + { + // Get the dependencies without chechking the registry + type_dependencies = requests_it->second; + type_dependencies_result = RETCODE_OK; + } } else { // Get the dependencies from the registry - type_dependencies_result = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + type_dependencies_result = + fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). get_type_dependencies(request.type_ids(), type_dependencies); // If there are too many dependent types, store the type dependencies for future requests @@ -168,14 +282,13 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( // Prepare and send the reply TypeLookup_getTypeDependencies_Out out = prepare_get_type_dependencies_response( request.type_ids(), type_dependencies, request.continuation_point()); - TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); - TypeLookup_getTypeDependencies_Result result; - result.result(out); - reply->return_value().getTypeDependencies(result); - reply->header().relatedRequestId() = request_id; - - typelookup_manager_->send_reply(*reply); - typelookup_manager_->reply_type_.deleteData(reply); + answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_OK, out); + } + else + { + // If the type dependencies are not found, log error + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "Error getting type dependencies."); + answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT); } } @@ -185,12 +298,14 @@ TypeLookup_getTypeDependencies_Out TypeLookupRequestListener::prepare_get_type_d const std::vector& continuation_point) { TypeLookup_getTypeDependencies_Out out; - std::vector dependent_types; // Check if all dependencies can be sent in a single response if (type_dependencies.size() < MAX_DEPENDENCIES_PER_REPLY) { - std::copy(type_dependencies.begin(), type_dependencies.end(), std::back_inserter(dependent_types)); + for (const auto& type_identifier : type_dependencies) + { + out.dependent_typeids().emplace_back(type_identifier); + } } else { @@ -201,11 +316,14 @@ TypeLookup_getTypeDependencies_Out TypeLookupRequestListener::prepare_get_type_d start_index = calculate_continuation_point(continuation_point) * MAX_DEPENDENCIES_PER_REPLY; } - // Copy the dependencies within the specified range + // Copy the dependencies within the specified range directly to out auto start_it = std::next(type_dependencies.begin(), start_index); auto end_it = std::next(start_it, std::min(MAX_DEPENDENCIES_PER_REPLY, type_dependencies.size() - start_index)); - std::copy(start_it, end_it, std::back_inserter(dependent_types)); + for (auto it = start_it; it != end_it; ++it) + { + out.dependent_typeids().emplace_back(*it); + } if ((start_index + MAX_DEPENDENCIES_PER_REPLY) > type_dependencies.size()) { @@ -224,12 +342,58 @@ TypeLookup_getTypeDependencies_Out TypeLookupRequestListener::prepare_get_type_d } } - // Set the dependent types in the reply - out.dependent_typeids(dependent_types); - return out; } +void TypeLookupRequestListener::answer_request( + SampleIdentity request_id, + rpc::RemoteExceptionCode_t exception_code, + TypeLookup_getTypeDependencies_Out& out) +{ + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); + + TypeLookup_getTypeDependencies_Result result; + result.result(out); + reply->return_value().getTypeDependencies(result); + + reply->header().relatedRequestId(request_id); + reply->header().remoteEx(exception_code); + + typelookup_manager_->send(*reply); + typelookup_manager_->reply_type_.deleteData(reply); +} + +void TypeLookupRequestListener::answer_request( + SampleIdentity request_id, + rpc::RemoteExceptionCode_t exception_code, + TypeLookup_getTypes_Out& out) +{ + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); + + TypeLookup_getTypes_Result result; + result.result(out); + reply->return_value().getType(result); + + reply->header().relatedRequestId(request_id); + reply->header().remoteEx(exception_code); + + typelookup_manager_->send(*reply); + typelookup_manager_->reply_type_.deleteData(reply); +} + +void TypeLookupRequestListener::answer_request( + SampleIdentity request_id, + rpc::RemoteExceptionCode_t exception_code) +{ + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); + + reply->header().relatedRequestId(request_id); + reply->header().remoteEx(exception_code); + + typelookup_manager_->send(*reply); + typelookup_manager_->reply_type_.deleteData(reply); +} + void TypeLookupRequestListener::onNewCacheChangeAdded( RTPSReader* reader, const CacheChange_t* const changeIN) @@ -243,30 +407,17 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( EPROSIMA_LOG_WARNING(TL_REQUEST_READER, "Received data from a bad endpoint."); reader->getHistory()->remove_change(change); } - EPROSIMA_LOG_INFO(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "Received new cache change"); // Process the received TypeLookup Request and handle different types of requests TypeLookup_Request request; - if (typelookup_manager_->receive_request(*change, request)) + if (typelookup_manager_->receive(*change, request)) { - switch (request.data()._d()) + // Add request to the processing queue + requests_queue_.push(request); { - case TypeLookup_getTypes_HashId: - { - std::async(std::launch::async, - &TypeLookupRequestListener::check_get_types_request, this, - request.header().requestId(), request.data().getTypes()); - break; - } - case TypeLookup_getDependencies_HashId: - { - std::async(std::launch::async, - &TypeLookupRequestListener::check_get_type_dependencies_request, this, - request.header().requestId(), request.data().getTypeDependencies()); - break; - } - default: - break; + // Notify processor + std::unique_lock guard(request_processor_cv_mutex_); + request_processor_cv_.notify_all(); } } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index 50f9410b2b0..f77b9e3f5d2 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -17,17 +17,21 @@ * */ -#ifndef _FASTDDS_TYPELOOKUP_SERVICE_REQUEST_LISTENER_HPP_ -#define _FASTDDS_TYPELOOKUP_SERVICE_REQUEST_LISTENER_HPP_ +#ifndef _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REQUEST_LISTENER_HPP_ +#define _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REQUEST_LISTENER_HPP_ #include +#include #include #include +#include #include #include #include +#include +#include namespace std { @@ -87,6 +91,23 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public */ virtual ~TypeLookupRequestListener() override; +private: + + /** + * @brief Starts the thread that process the received requests. + */ + void start_request_processor_thread(); + + /** + * @brief Stops the thread that process the received requests. + */ + void stop_request_processor_thread(); + + /** + * @brief Process the requests in the queue. + */ + void process_requests(); + /** * @brief Gets TypeObject from TypeObjectRegistry, creates and sends reply. * @param request_id[in] The SampleIdentity of the request. @@ -117,6 +138,24 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public const std::unordered_set& type_dependencies, const std::vector& continuation_point); + /** + * @brief Creates a sends TypeLookup_Reply. + * @param request_id[in] The SampleIdentity of the request. + * @param exception_code[in] The RemoteExceptionCode_t used in the header. + * @param out[in] The result of the request being answered. + */ + void answer_request( + SampleIdentity request_id, + rpc::RemoteExceptionCode_t exception_code, + TypeLookup_getTypeDependencies_Out& out); + void answer_request( + SampleIdentity request_id, + rpc::RemoteExceptionCode_t exception_code, + TypeLookup_getTypes_Out& out); + void answer_request( + SampleIdentity request_id, + rpc::RemoteExceptionCode_t exception_code); + /** * @brief Method call when this class is notified of a new cache change. * @param reader The reader receiving the cache change. @@ -126,17 +165,6 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; - /** - * @brief This method is called when all the readers matched with this Writer acknowledge that a cache - * change has been received. - * @param change The cache change - */ - void onWriterChangeReceivedByAll( - fastrtps::rtps::RTPSWriter*, - fastrtps::rtps::CacheChange_t* change) override; - -private: - //! A pointer to the typelookup manager. TypeLookupManager* typelookup_manager_; @@ -146,10 +174,17 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public //! Collection of the requests that needed continuation points. std::unordered_map > requests_with_continuation_; + + eprosima::thread request_processor_thread; + std::queue requests_queue_; + std::mutex request_processor_cv_mutex_; + std::condition_variable request_processor_cv_; + bool processing_; + rtps::ThreadSettings request_processor_thread_settings_; }; } /* namespace builtin */ } /* namespace dds */ } /* namespace fastdds */ } /* namespace eprosima */ -#endif /* _FASTDDS_TYPELOOKUP_SERVICE_REQUEST_LISTENER_HPP_*/ +#endif /* _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REQUEST_LISTENER_HPP_*/ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp b/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp index 8d0ed3172fb..3df22d734ed 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp @@ -97,7 +97,7 @@ class TypeLookup_getTypes_In eProsima_user_DllExport TypeLookup_getTypes_In( const TypeLookup_getTypes_In& x) { - m_type_ids = x.m_type_ids; + m_type_ids = x.m_type_ids; } @@ -119,7 +119,7 @@ class TypeLookup_getTypes_In const TypeLookup_getTypes_In& x) { - m_type_ids = x.m_type_ids; + m_type_ids = x.m_type_ids; return *this; } @@ -194,8 +194,6 @@ class TypeLookup_getTypes_In return m_type_ids; } - - private: std::vector m_type_ids; @@ -230,9 +228,9 @@ class TypeLookup_getTypes_Out eProsima_user_DllExport TypeLookup_getTypes_Out( const TypeLookup_getTypes_Out& x) { - m_types = x.m_types; + m_types = x.m_types; - m_complete_to_minimal = x.m_complete_to_minimal; + m_complete_to_minimal = x.m_complete_to_minimal; } @@ -255,9 +253,9 @@ class TypeLookup_getTypes_Out const TypeLookup_getTypes_Out& x) { - m_types = x.m_types; + m_types = x.m_types; - m_complete_to_minimal = x.m_complete_to_minimal; + m_complete_to_minimal = x.m_complete_to_minimal; return *this; } @@ -283,7 +281,7 @@ class TypeLookup_getTypes_Out const TypeLookup_getTypes_Out& x) const { return (m_types == x.m_types && - m_complete_to_minimal == x.m_complete_to_minimal); + m_complete_to_minimal == x.m_complete_to_minimal); } /*! @@ -320,7 +318,8 @@ class TypeLookup_getTypes_Out * @brief This function returns a constant reference to member types * @return Constant reference to member types */ - eProsima_user_DllExport const std::vector& types() const + eProsima_user_DllExport const std::vector& types() + const { return m_types; } @@ -334,7 +333,6 @@ class TypeLookup_getTypes_Out return m_types; } - /*! * @brief This function copies the value in member complete_to_minimal * @param _complete_to_minimal New value to be copied in member complete_to_minimal @@ -359,7 +357,8 @@ class TypeLookup_getTypes_Out * @brief This function returns a constant reference to member complete_to_minimal * @return Constant reference to member complete_to_minimal */ - eProsima_user_DllExport const std::vector& complete_to_minimal() const + eProsima_user_DllExport const std::vector& complete_to_minimal() + const { return m_complete_to_minimal; } @@ -373,8 +372,6 @@ class TypeLookup_getTypes_Out return m_complete_to_minimal; } - - private: std::vector m_types; @@ -540,7 +537,8 @@ class TypeLookup_getTypes_Result if (!valid_discriminator) { - throw eprosima::fastcdr::exception::BadParamException("Discriminator doesn't correspond with the selected union member"); + throw eprosima::fastcdr::exception::BadParamException( + "Discriminator doesn't correspond with the selected union member"); } m__d = __d; @@ -680,9 +678,9 @@ class TypeLookup_getTypeDependencies_In eProsima_user_DllExport TypeLookup_getTypeDependencies_In( const TypeLookup_getTypeDependencies_In& x) { - m_type_ids = x.m_type_ids; + m_type_ids = x.m_type_ids; - m_continuation_point = x.m_continuation_point; + m_continuation_point = x.m_continuation_point; } @@ -705,9 +703,9 @@ class TypeLookup_getTypeDependencies_In const TypeLookup_getTypeDependencies_In& x) { - m_type_ids = x.m_type_ids; + m_type_ids = x.m_type_ids; - m_continuation_point = x.m_continuation_point; + m_continuation_point = x.m_continuation_point; return *this; } @@ -733,7 +731,7 @@ class TypeLookup_getTypeDependencies_In const TypeLookup_getTypeDependencies_In& x) const { return (m_type_ids == x.m_type_ids && - m_continuation_point == x.m_continuation_point); + m_continuation_point == x.m_continuation_point); } /*! @@ -784,7 +782,6 @@ class TypeLookup_getTypeDependencies_In return m_type_ids; } - /*! * @brief This function copies the value in member continuation_point * @param _continuation_point New value to be copied in member continuation_point @@ -823,8 +820,6 @@ class TypeLookup_getTypeDependencies_In return m_continuation_point; } - - private: std::vector m_type_ids; @@ -860,9 +855,9 @@ class TypeLookup_getTypeDependencies_Out eProsima_user_DllExport TypeLookup_getTypeDependencies_Out( const TypeLookup_getTypeDependencies_Out& x) { - m_dependent_typeids = x.m_dependent_typeids; + m_dependent_typeids = x.m_dependent_typeids; - m_continuation_point = x.m_continuation_point; + m_continuation_point = x.m_continuation_point; } @@ -885,9 +880,9 @@ class TypeLookup_getTypeDependencies_Out const TypeLookup_getTypeDependencies_Out& x) { - m_dependent_typeids = x.m_dependent_typeids; + m_dependent_typeids = x.m_dependent_typeids; - m_continuation_point = x.m_continuation_point; + m_continuation_point = x.m_continuation_point; return *this; } @@ -913,7 +908,7 @@ class TypeLookup_getTypeDependencies_Out const TypeLookup_getTypeDependencies_Out& x) const { return (m_dependent_typeids == x.m_dependent_typeids && - m_continuation_point == x.m_continuation_point); + m_continuation_point == x.m_continuation_point); } /*! @@ -950,7 +945,8 @@ class TypeLookup_getTypeDependencies_Out * @brief This function returns a constant reference to member dependent_typeids * @return Constant reference to member dependent_typeids */ - eProsima_user_DllExport const std::vector& dependent_typeids() const + eProsima_user_DllExport const std::vector& dependent_typeids() + const { return m_dependent_typeids; } @@ -964,7 +960,6 @@ class TypeLookup_getTypeDependencies_Out return m_dependent_typeids; } - /*! * @brief This function copies the value in member continuation_point * @param _continuation_point New value to be copied in member continuation_point @@ -1003,8 +998,6 @@ class TypeLookup_getTypeDependencies_Out return m_continuation_point; } - - private: std::vector m_dependent_typeids; @@ -1170,7 +1163,8 @@ class TypeLookup_getTypeDependencies_Result if (!valid_discriminator) { - throw eprosima::fastcdr::exception::BadParamException("Discriminator doesn't correspond with the selected union member"); + throw eprosima::fastcdr::exception::BadParamException( + "Discriminator doesn't correspond with the selected union member"); } m__d = __d; @@ -1467,7 +1461,8 @@ class TypeLookup_Call if (!valid_discriminator) { - throw eprosima::fastcdr::exception::BadParamException("Discriminator doesn't correspond with the selected union member"); + throw eprosima::fastcdr::exception::BadParamException( + "Discriminator doesn't correspond with the selected union member"); } m__d = __d; @@ -1534,7 +1529,6 @@ class TypeLookup_Call return m_getTypes; } - /*! * @brief This function copies the value in member getTypeDependencies * @param _getTypeDependencies New value to be copied in member getTypeDependencies @@ -1679,9 +1673,9 @@ class TypeLookup_Request eProsima_user_DllExport TypeLookup_Request( const TypeLookup_Request& x) { - m_header = x.m_header; + m_header = x.m_header; - m_data = x.m_data; + m_data = x.m_data; } @@ -1704,9 +1698,9 @@ class TypeLookup_Request const TypeLookup_Request& x) { - m_header = x.m_header; + m_header = x.m_header; - m_data = x.m_data; + m_data = x.m_data; return *this; } @@ -1732,7 +1726,7 @@ class TypeLookup_Request const TypeLookup_Request& x) const { return (m_header == x.m_header && - m_data == x.m_data); + m_data == x.m_data); } /*! @@ -1783,7 +1777,6 @@ class TypeLookup_Request return m_header; } - /*! * @brief This function copies the value in member data * @param _data New value to be copied in member data @@ -1822,8 +1815,6 @@ class TypeLookup_Request return m_data; } - - private: eprosima::fastdds::dds::rpc::RequestHeader m_header; @@ -2016,7 +2007,8 @@ class TypeLookup_Return if (!valid_discriminator) { - throw eprosima::fastcdr::exception::BadParamException("Discriminator doesn't correspond with the selected union member"); + throw eprosima::fastcdr::exception::BadParamException( + "Discriminator doesn't correspond with the selected union member"); } m__d = __d; @@ -2083,7 +2075,6 @@ class TypeLookup_Return return m_getType; } - /*! * @brief This function copies the value in member getTypeDependencies * @param _getTypeDependencies New value to be copied in member getTypeDependencies @@ -2228,9 +2219,9 @@ class TypeLookup_Reply eProsima_user_DllExport TypeLookup_Reply( const TypeLookup_Reply& x) { - m_header = x.m_header; + m_header = x.m_header; - m_return_value = x.m_return_value; + m_return_value = x.m_return_value; } @@ -2253,9 +2244,9 @@ class TypeLookup_Reply const TypeLookup_Reply& x) { - m_header = x.m_header; + m_header = x.m_header; - m_return_value = x.m_return_value; + m_return_value = x.m_return_value; return *this; } @@ -2281,7 +2272,7 @@ class TypeLookup_Reply const TypeLookup_Reply& x) const { return (m_header == x.m_header && - m_return_value == x.m_return_value); + m_return_value == x.m_return_value); } /*! @@ -2332,7 +2323,6 @@ class TypeLookup_Reply return m_header; } - /*! * @brief This function copies the value in member return_value * @param _return_value New value to be copied in member return_value @@ -2371,8 +2361,6 @@ class TypeLookup_Reply return m_return_value; } - - private: eprosima::fastdds::dds::rpc::ReplyHeader m_header; diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index daf990f0e08..20d5d540f58 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1563,7 +1563,7 @@ void DomainParticipantImpl::MyRTPSParticipantListener::onReaderDiscovery( Sentry sentinel(this); if (sentinel) { - participant_->listener_->on_subscriber_discovery(participant_->participant_, std::move(info)); + participant_->listener_->on_data_reader_discovery(participant_->participant_, std::move(info)); } } @@ -1574,7 +1574,7 @@ void DomainParticipantImpl::MyRTPSParticipantListener::onWriterDiscovery( Sentry sentinel(this); if (sentinel) { - participant_->listener_->on_publisher_discovery(participant_->participant_, std::move(info)); + participant_->listener_->on_data_writer_discovery(participant_->participant_, std::move(info)); } } @@ -1825,6 +1825,12 @@ bool DomainParticipantImpl::can_qos_be_updated( EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "Participant discovery_server_thread cannot be changed after the participant is enabled"); } + if (!(to.typelookup_service_threads() == from.typelookup_service_threads())) + { + updatable = false; + EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, + "Participant typelookup_service_threads cannot be changed after the participant is enabled"); + } #if HAVE_SECURITY if (!(to.security_log_thread() == from.security_log_thread())) { diff --git a/src/cpp/fastdds/utils/QosConverters.cpp b/src/cpp/fastdds/utils/QosConverters.cpp index 038c39f5e61..61d7499356a 100644 --- a/src/cpp/fastdds/utils/QosConverters.cpp +++ b/src/cpp/fastdds/utils/QosConverters.cpp @@ -161,6 +161,7 @@ void set_qos_from_attributes( qos.builtin_controllers_sender_thread() = attr.builtin_controllers_sender_thread; qos.timed_events_thread() = attr.timed_events_thread; qos.discovery_server_thread() = attr.discovery_server_thread; + qos.typelookup_service_threads() = attr.typelookup_service_threads; #if HAVE_SECURITY qos.security_log_thread() = attr.security_log_thread; #endif // if HAVE_SECURITY @@ -209,6 +210,7 @@ void set_attributes_from_qos( attr.builtin_controllers_sender_thread = qos.builtin_controllers_sender_thread(); attr.timed_events_thread = qos.timed_events_thread(); attr.discovery_server_thread = qos.discovery_server_thread(); + attr.typelookup_service_threads = qos.typelookup_service_threads(); #if HAVE_SECURITY attr.security_log_thread = qos.security_log_thread(); #endif // if HAVE_SECURITY diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp index cc41f40bac7..73422ae52f7 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp @@ -750,6 +750,35 @@ ReturnCode_t TypeObjectRegistry::get_type_dependencies_impl( return ret_code; } +const TypeIdentifier TypeObjectRegistry::complete_from_minimal_type_identifier( + const TypeIdentifier& type_id) +{ + if (EK_MINIMAL == type_id._d() || + (TI_PLAIN_SEQUENCE_SMALL == type_id._d() && type_id.seq_sdefn().header().equiv_kind() == EK_MINIMAL) || + (TI_PLAIN_SEQUENCE_LARGE == type_id._d() && type_id.seq_ldefn().header().equiv_kind() == EK_MINIMAL) || + (TI_PLAIN_ARRAY_SMALL == type_id._d() && type_id.array_sdefn().header().equiv_kind() == EK_MINIMAL) || + (TI_PLAIN_ARRAY_LARGE == type_id._d() && type_id.array_ldefn().header().equiv_kind() == EK_MINIMAL) || + (TI_PLAIN_MAP_SMALL == type_id._d() && (type_id.map_sdefn().header().equiv_kind() == EK_MINIMAL || + type_id.map_sdefn().key_identifier()->_d() == EK_MINIMAL)) || + (TI_PLAIN_MAP_LARGE == type_id._d() && (type_id.map_ldefn().header().equiv_kind() == EK_MINIMAL || + type_id.map_ldefn().key_identifier()->_d() == EK_MINIMAL))) + { + std::lock_guard data_guard(type_object_registry_mutex_); + for (const auto& it : local_type_identifiers_) + { + if (it.second.type_identifier1() == type_id) + { + return it.second.type_identifier2(); + } + else if (it.second.type_identifier2() == type_id) + { + return it.second.type_identifier1(); + } + } + } + return type_id; +} + void TypeObjectRegistry::add_dependency( const TypeIdentifier& type_id, std::unordered_set& type_dependencies) diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp index e0c8b4c869c..08e6f57a2dc 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp @@ -269,6 +269,16 @@ class TypeObjectRegistry : public ITypeObjectRegistry const TypeObject& type_object, std::unordered_set& type_dependencies); + /** + * @brief Get Complete TypeIdentifier from Minimal TypeIdentifier. + * + * @param minimal_type_id Direct hash minimal TypeIdentifier + * @return TypeIdentifier Complete TypeIdentifier related to the given Minimal TypeIdentifier. + * Same TypeIdentifier if the given TypeIdentifier is not a direct hash minimal TypeIdentifier. + */ + const TypeIdentifier complete_from_minimal_type_identifier( + const TypeIdentifier& minimal_type_id); + // Only DomainParticipantFactory is allowed to instantiate the TypeObjectRegistry class. // It cannot be protected as the standard library needs to access the constructor to allocate the resources. // Rule of zero: resource managing types. diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 9dc7c837e89..d50f8be9da5 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -163,7 +163,7 @@ bool EDP::newLocalReaderProxyData( #endif // if HAVE_SECURITY if (att.auto_fill_type_information) { - // TypeInformation, TypeObject and TypeIdentifier + // TypeInformation if (!att.type_information.assigned()) { fastdds::dds::xtypes::TypeInformation type_info; @@ -171,8 +171,7 @@ bool EDP::newLocalReaderProxyData( eprosima::fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer() .get_type_information(rpd->typeName().c_str(), type_info)) { - // TODO (adelcampo) Change to xtypes - // rpd->type_information() = type_info; + rpd->type_information() = type_info; } } } @@ -271,7 +270,7 @@ bool EDP::newLocalWriterProxyData( if (att.auto_fill_type_information) { - // TypeInformation, TypeObject and TypeIdentifier + // TypeInformation if (!att.type_information.assigned()) { fastdds::dds::xtypes::TypeInformation type_info; @@ -279,8 +278,7 @@ bool EDP::newLocalWriterProxyData( eprosima::fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer() .get_type_information(wpd->typeName().c_str(), type_info)) { - // TODO (adelcampo) Change to xtypes - // wpd->type_information() = type_info; + wpd->type_information() = type_info; } } } @@ -366,7 +364,7 @@ bool EDP::updatedLocalReader( if (att.auto_fill_type_information) { - // TypeInformation, TypeObject and TypeIdentifier + // TypeInformation if (!rdata->type_information().assigned()) { fastdds::dds::xtypes::TypeInformation type_info; @@ -374,8 +372,7 @@ bool EDP::updatedLocalReader( eprosima::fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer() .get_type_information(rdata->typeName().c_str(), type_info)) { - // TODO (adelcampo) Change to xtypes - // rdata->type_information() = type_info; + rdata->type_information() = type_info; } } } @@ -434,7 +431,7 @@ bool EDP::updatedLocalWriter( if (att.auto_fill_type_information) { - // TypeInformation, TypeObject and TypeIdentifier + // TypeInformation if (!wdata->type_information().assigned()) { fastdds::dds::xtypes::TypeInformation type_info; @@ -442,8 +439,7 @@ bool EDP::updatedLocalWriter( eprosima::fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer() .get_type_information(wdata->typeName().c_str(), type_info)) { - // TODO (adelcampo) Change to xtypes - // wdata->type_information() = *type_info; + wdata->type_information() = type_info; } } } diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index 5cece62baf8..a72410f8745 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -83,8 +83,8 @@ void EDPBasePUBListener::add_writer_from_change( // Callback function to continue after typelookup is complete fastdds::dds::builtin::AsyncGetTypeWriterCallback after_typelookup_callback = - [reader, reader_history, change, edp, release_change, &network] - (eprosima::ProxyPool::smart_ptr&& temp_writer_data) + [change, edp, release_change, &network] + (eprosima::ProxyPool::smart_ptr& temp_writer_data) { //LOAD INFORMATION IN DESTINATION WRITER PROXY DATA auto copy_data_fun = [&temp_writer_data, &network]( @@ -115,11 +115,6 @@ void EDPBasePUBListener::add_writer_from_change( // release temporary proxy temp_writer_data.reset(); - reader_history->remove_change(reader_history->find_change(change), release_change); - - // At this point, we can release the reader lock because the change is not used - reader->getMutex().unlock(); - if (writer_data != nullptr) { edp->pairing_writer_proxy_with_any_local_reader(participant_guid, writer_data); @@ -128,14 +123,29 @@ void EDPBasePUBListener::add_writer_from_change( { EPROSIMA_LOG_WARNING(RTPS_EDP, "Received message from UNKNOWN RTPSParticipant, removing"); } - - // Take the reader lock again if needed. - reader->getMutex().lock(); }; - edp->mp_RTPSParticipant->typelookup_manager()->async_get_type( - std::move(temp_writer_data), - after_typelookup_callback); + // Remove change from history. + reader_history->remove_change(reader_history->find_change(change), release_change); + + // Check if TypeInformation exists to start the typelookup service + if (temp_writer_data->type_information().assigned()) + { + // At this point, we can release the reader lock because the change is not used + reader->getMutex().unlock(); + + edp->mp_RTPSParticipant->typelookup_manager()->async_get_type( + temp_writer_data, + after_typelookup_callback); + + // Take the reader lock again if needed. + reader->getMutex().lock(); + } + else + { + // Check if TypeInformation does not exists, log error + EPROSIMA_LOG_ERROR(RTPS_EDP, "EDPBasePUBListener::add_writer_from_change: No TypeInformation"); + } } } @@ -207,8 +217,8 @@ void EDPBaseSUBListener::add_reader_from_change( // Callback function to continue after typelookup is complete fastdds::dds::builtin::AsyncGetTypeReaderCallback after_typelookup_callback = - [reader, reader_history, change, edp, release_change, &network] - (eprosima::ProxyPool::smart_ptr&& temp_reader_data) + [change, edp, release_change, &network] + (eprosima::ProxyPool::smart_ptr& temp_reader_data) { auto copy_data_fun = [&temp_reader_data, &network]( ReaderProxyData* data, @@ -239,12 +249,6 @@ void EDPBaseSUBListener::add_reader_from_change( // Release the temporary proxy temp_reader_data.reset(); - // Remove change from history. - reader_history->remove_change(reader_history->find_change(change), release_change); - - // At this point we can release reader lock, cause change is not used - reader->getMutex().unlock(); - if (reader_data != nullptr) //ADDED NEW DATA { edp->pairing_reader_proxy_with_any_local_writer(participant_guid, reader_data); @@ -253,14 +257,29 @@ void EDPBaseSUBListener::add_reader_from_change( { EPROSIMA_LOG_WARNING(RTPS_EDP, "From UNKNOWN RTPSParticipant, removing"); } - - // Take again the reader lock. - reader->getMutex().lock(); }; - edp->mp_RTPSParticipant->typelookup_manager()->async_get_type( - std::move(temp_reader_data), - after_typelookup_callback); + // Remove change from history. + reader_history->remove_change(reader_history->find_change(change), release_change); + + // Check if TypeInformation exists to start the typelookup service + if (temp_reader_data->type_information().assigned()) + { + // At this point, we can release the reader lock because the change is not used + reader->getMutex().unlock(); + + edp->mp_RTPSParticipant->typelookup_manager()->async_get_type( + temp_reader_data, + after_typelookup_callback); + + // Take the reader lock again if needed. + reader->getMutex().lock(); + } + else + { + // Check if TypeInformation does not exists, log error + EPROSIMA_LOG_ERROR(RTPS_EDP, "EDPBasePUBListener::add_reader_from_change: No TypeInformation"); + } } } diff --git a/src/cpp/xmlparser/XMLParserCommon.h b/src/cpp/xmlparser/XMLParserCommon.h index 9b7c18e34a2..e2995ba5731 100644 --- a/src/cpp/xmlparser/XMLParserCommon.h +++ b/src/cpp/xmlparser/XMLParserCommon.h @@ -162,6 +162,7 @@ extern const char* MAX_USER_DATA; extern const char* MAX_PARTITIONS; extern const char* TIMED_EVENTS_THREAD; extern const char* DISCOVERY_SERVER_THREAD; +extern const char* TYPELOOKUP_SERVICE_THREADS; extern const char* SECURITY_LOG_THREAD; extern const char* BUILTIN_TRANSPORTS_RECEPTION_THREADS; extern const char* BUILTIN_CONTROLLERS_SENDER_THREAD; diff --git a/test/blackbox/api/dds-pim/PubSubReader.hpp b/test/blackbox/api/dds-pim/PubSubReader.hpp index 5c1e62ccce4..759a5b673d4 100644 --- a/test/blackbox/api/dds-pim/PubSubReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubReader.hpp @@ -113,7 +113,7 @@ class PubSubReader } } - void on_publisher_discovery( + void on_data_writer_discovery( eprosima::fastdds::dds::DomainParticipant*, eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override { diff --git a/test/blackbox/api/dds-pim/PubSubWriter.hpp b/test/blackbox/api/dds-pim/PubSubWriter.hpp index 81e21ba9ab9..f521da1a95b 100644 --- a/test/blackbox/api/dds-pim/PubSubWriter.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriter.hpp @@ -115,7 +115,7 @@ class PubSubWriter #endif // if HAVE_SECURITY - void on_subscriber_discovery( + void on_data_reader_discovery( eprosima::fastdds::dds::DomainParticipant*, eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override { @@ -134,7 +134,7 @@ class PubSubWriter } } - void on_publisher_discovery( + void on_data_writer_discovery( eprosima::fastdds::dds::DomainParticipant*, eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override { diff --git a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp index 59cc3c6f4d7..3ac30141980 100644 --- a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp @@ -108,7 +108,7 @@ class PubSubWriterReader } } - void on_subscriber_discovery( + void on_data_reader_discovery( eprosima::fastdds::dds::DomainParticipant* participant, eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override { @@ -129,7 +129,7 @@ class PubSubWriterReader } } - void on_publisher_discovery( + void on_data_writer_discovery( eprosima::fastdds::dds::DomainParticipant* participant, eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override { diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h index fcc6ab17f96..005abd075ac 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -464,6 +464,7 @@ class RTPSParticipantAttributes (this->security_log_thread == b.security_log_thread) && #endif // if HAVE_SECURITY (this->discovery_server_thread == b.discovery_server_thread) && + (this->typelookup_service_threads == b.typelookup_service_threads) && (this->builtin_transports_reception_threads == b.builtin_transports_reception_threads); } @@ -617,6 +618,9 @@ class RTPSParticipantAttributes //! Thread settings for the discovery server thread fastdds::rtps::ThreadSettings discovery_server_thread; + //! Thread settings for the builtin TypeLookup service threads + fastdds::rtps::ThreadSettings typelookup_service_threads; + //! Thread settings for the builtin transports reception threads fastdds::rtps::ThreadSettings builtin_transports_reception_threads; diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 3cb4fd2acf4..baaa5dbc831 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -3159,6 +3159,11 @@ TEST(ParticipantTests, UpdatableDomainParticipantQos) pqos.discovery_server_thread().affinity = 1; ASSERT_EQ(participant->set_qos(pqos), RETCODE_IMMUTABLE_POLICY); + // Check that the typelookup_service_threads can not be changed in an enabled participant + participant->get_qos(pqos); + pqos.typelookup_service_threads().affinity = 1; + ASSERT_EQ(participant->set_qos(pqos), RETCODE_IMMUTABLE_POLICY); + #if HAVE_SECURITY // Check that the security_log_thread can not be changed in an enabled participant participant->get_qos(pqos); diff --git a/test/unittest/dds/profiles/test_xml_for_string_profile.xml b/test/unittest/dds/profiles/test_xml_for_string_profile.xml index 50c0a6bcbc8..169c6fdae19 100644 --- a/test/unittest/dds/profiles/test_xml_for_string_profile.xml +++ b/test/unittest/dds/profiles/test_xml_for_string_profile.xml @@ -138,6 +138,10 @@ 15 1048576 + + 15 + 1048576 + 15 1048576 @@ -283,6 +287,10 @@ 15 1048576 + + 15 + 1048576 + 15 1048576 diff --git a/test/unittest/dds/profiles/test_xml_profile.xml b/test/unittest/dds/profiles/test_xml_profile.xml index 7b7f8ded7f4..620fe5655cf 100644 --- a/test/unittest/dds/profiles/test_xml_profile.xml +++ b/test/unittest/dds/profiles/test_xml_profile.xml @@ -135,6 +135,10 @@ 15 1048576 + + 15 + 1048576 + 15 1048576 @@ -280,6 +284,10 @@ 15 1048576 + + 15 + 1048576 + 15 1048576 diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index b146de83b52..22c441415ed 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -372,7 +372,7 @@ TEST(DataWriterTests, get_guid) { public: - void on_publisher_discovery( + void on_data_writer_discovery( DomainParticipant*, fastrtps::rtps::WriterDiscoveryInfo&& info) { diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index 231dc9e3268..c83cbef8242 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -578,7 +578,7 @@ TEST_F(DataReaderTests, get_guid) { public: - void on_subscriber_discovery( + void on_data_reader_discovery( DomainParticipant*, ReaderDiscoveryInfo&& info) { diff --git a/test/unittest/xmlparser/test_xml_deprecated.xml b/test/unittest/xmlparser/test_xml_deprecated.xml index 742ffad487a..d21c3a8e32c 100644 --- a/test/unittest/xmlparser/test_xml_deprecated.xml +++ b/test/unittest/xmlparser/test_xml_deprecated.xml @@ -165,6 +165,12 @@ 12 12 + + 12 + 12 + 12 + 12 + 12 12 diff --git a/test/unittest/xmlparser/test_xml_profile.xml b/test/unittest/xmlparser/test_xml_profile.xml index 7e850567d7d..81490cd6ee8 100644 --- a/test/unittest/xmlparser/test_xml_profile.xml +++ b/test/unittest/xmlparser/test_xml_profile.xml @@ -181,6 +181,12 @@ 12 12 + + 12 + 12 + 12 + 12 + 12 12 diff --git a/test/unittest/xmlparser/test_xml_profile_env_var.xml b/test/unittest/xmlparser/test_xml_profile_env_var.xml index 8ecf1c12cd8..a1df6f4bbac 100644 --- a/test/unittest/xmlparser/test_xml_profile_env_var.xml +++ b/test/unittest/xmlparser/test_xml_profile_env_var.xml @@ -162,6 +162,12 @@ ${XML_PROFILES_ENV_VAR_160} ${XML_PROFILES_ENV_VAR_161} + + ${XML_PROFILES_ENV_VAR_158} + ${XML_PROFILES_ENV_VAR_159} + ${XML_PROFILES_ENV_VAR_160} + ${XML_PROFILES_ENV_VAR_161} + ${XML_PROFILES_ENV_VAR_158} ${XML_PROFILES_ENV_VAR_159} diff --git a/test/unittest/xmlparser/test_xml_rooted_deprecated.xml b/test/unittest/xmlparser/test_xml_rooted_deprecated.xml index 48e6926cab8..ae184a94039 100644 --- a/test/unittest/xmlparser/test_xml_rooted_deprecated.xml +++ b/test/unittest/xmlparser/test_xml_rooted_deprecated.xml @@ -140,6 +140,12 @@ 12 12 + + 12 + 12 + 12 + 12 + 12 12 diff --git a/test/unittest/xmlparser/test_xml_rooted_profile.xml b/test/unittest/xmlparser/test_xml_rooted_profile.xml index a8fb6503d6d..c0e43194bfd 100644 --- a/test/unittest/xmlparser/test_xml_rooted_profile.xml +++ b/test/unittest/xmlparser/test_xml_rooted_profile.xml @@ -155,6 +155,12 @@ 12 12 + + 12 + 12 + 12 + 12 + 12 12 From f614319c9f1e973da24bf7767dc39112481113e7 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Tue, 23 Jan 2024 07:50:22 +0100 Subject: [PATCH 10/35] Refs #20160: Small fix in reply error check. Signed-off-by: adriancampo --- .../builtin/type_lookup_service/TypeLookupReplyListener.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 48ad324c7e2..a2c442436b5 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -143,11 +143,11 @@ void TypeLookupReplyListener::check_get_types_reply( ReturnCode_t register_result = RETCODE_ERROR; for (xtypes::TypeIdentifierTypeObjectPair pair : reply.types()) { - if (RETCODE_OK != fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). - register_type_object(pair.type_identifier(), pair.type_object())) + register_result = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + register_type_object(pair.type_identifier(), pair.type_object()); + if (RETCODE_OK != register_result) { // If registration fails for any type, break out of the loop - register_result = RETCODE_PRECONDITION_NOT_MET; break; } } From 19a92ac90f06d9366fbb8ff45ae117c4843a0324 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Tue, 23 Jan 2024 09:12:57 +0100 Subject: [PATCH 11/35] Refs #20160: Created get_complementary_type_identifier method. Signed-off-by: adriancampo --- .../TypeLookupRequestListener.cpp | 2 +- .../TypeObjectRegistry.cpp | 36 ++++---- .../TypeObjectRegistry.hpp | 20 +--- .../type_lookup_service/TypeLookupManager.hpp | 91 ------------------- 4 files changed, 24 insertions(+), 125 deletions(-) delete mode 100644 test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index fe84416bd14..c18991f1f8e 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -202,7 +202,7 @@ void TypeLookupRequestListener::check_get_types_request( minimal_id = type_id; // Get complete TypeIdentifier from registry complete_id = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). - complete_from_minimal_type_identifier(minimal_id); + get_complementary_type_identifier(minimal_id); xtypes::TypeIdentifierPair id_pair; id_pair.type_identifier1(complete_id); diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp index 73422ae52f7..3a25873ff02 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp @@ -128,7 +128,7 @@ ReturnCode_t TypeObjectRegistry::register_type_identifier( type_identifiers.type_identifier2(type_identifier); type_identifiers.type_identifier1().seq_sdefn().header().equiv_kind(EK_MINIMAL); type_identifiers.type_identifier1().seq_sdefn().element_identifier(new TypeIdentifier( - minimal_from_complete_type_identifier( + get_complementary_type_identifier( *type_identifiers.type_identifier2().seq_sdefn().element_identifier()))); } break; @@ -138,7 +138,7 @@ ReturnCode_t TypeObjectRegistry::register_type_identifier( type_identifiers.type_identifier2(type_identifier); type_identifiers.type_identifier1().seq_ldefn().header().equiv_kind(EK_MINIMAL); type_identifiers.type_identifier1().seq_ldefn().element_identifier(new TypeIdentifier( - minimal_from_complete_type_identifier( + get_complementary_type_identifier( *type_identifiers.type_identifier2().seq_ldefn().element_identifier()))); } break; @@ -148,7 +148,7 @@ ReturnCode_t TypeObjectRegistry::register_type_identifier( type_identifiers.type_identifier2(type_identifier); type_identifiers.type_identifier1().array_sdefn().header().equiv_kind(EK_MINIMAL); type_identifiers.type_identifier1().array_sdefn().element_identifier(new TypeIdentifier( - minimal_from_complete_type_identifier( + get_complementary_type_identifier( *type_identifiers.type_identifier2().array_sdefn().element_identifier()))); } break; @@ -158,7 +158,7 @@ ReturnCode_t TypeObjectRegistry::register_type_identifier( type_identifiers.type_identifier2(type_identifier); type_identifiers.type_identifier1().array_ldefn().header().equiv_kind(EK_MINIMAL); type_identifiers.type_identifier1().array_ldefn().element_identifier(new TypeIdentifier( - minimal_from_complete_type_identifier( + get_complementary_type_identifier( *type_identifiers.type_identifier2().array_ldefn().element_identifier()))); } break; @@ -168,7 +168,7 @@ ReturnCode_t TypeObjectRegistry::register_type_identifier( type_identifiers.type_identifier2(type_identifier); type_identifiers.type_identifier1().map_sdefn().header().equiv_kind(EK_MINIMAL); type_identifiers.type_identifier1().map_sdefn().element_identifier(new TypeIdentifier( - minimal_from_complete_type_identifier( + get_complementary_type_identifier( *type_identifiers.type_identifier2().map_sdefn().element_identifier()))); } if (TypeObjectUtils::is_direct_hash_type_identifier(*type_identifier.map_sdefn().key_identifier())) @@ -178,7 +178,7 @@ ReturnCode_t TypeObjectRegistry::register_type_identifier( type_identifiers.type_identifier2(type_identifier); } type_identifiers.type_identifier1().map_sdefn().key_identifier(new TypeIdentifier( - minimal_from_complete_type_identifier( + get_complementary_type_identifier( *type_identifiers.type_identifier2().map_sdefn().key_identifier()))); } break; @@ -188,7 +188,7 @@ ReturnCode_t TypeObjectRegistry::register_type_identifier( type_identifiers.type_identifier2(type_identifier); type_identifiers.type_identifier1().map_ldefn().header().equiv_kind(EK_MINIMAL); type_identifiers.type_identifier1().map_ldefn().element_identifier(new TypeIdentifier( - minimal_from_complete_type_identifier( + get_complementary_type_identifier( *type_identifiers.type_identifier2().map_ldefn().element_identifier()))); } if (TypeObjectUtils::is_direct_hash_type_identifier(*type_identifier.map_ldefn().key_identifier())) @@ -198,7 +198,7 @@ ReturnCode_t TypeObjectRegistry::register_type_identifier( type_identifiers.type_identifier2(type_identifier); } type_identifiers.type_identifier1().map_ldefn().key_identifier(new TypeIdentifier( - minimal_from_complete_type_identifier( + get_complementary_type_identifier( *type_identifiers.type_identifier2().map_ldefn().key_identifier()))); } break; @@ -929,7 +929,7 @@ const MinimalAliasType TypeObjectRegistry::build_minimal_from_complete_alias_typ // alias_flags: unused. No flags apply. // header: empty. Available for future extension. minimal_alias_type.body().common(complete_alias_type.body().common()); - minimal_alias_type.body().common().related_type(minimal_from_complete_type_identifier( + minimal_alias_type.body().common().related_type(get_complementary_type_identifier( complete_alias_type.body().common().related_type())); return minimal_alias_type; } @@ -945,7 +945,7 @@ const MinimalAnnotationType TypeObjectRegistry::build_minimal_from_complete_anno { MinimalAnnotationParameter minimal_annotation_parameter; minimal_annotation_parameter.common(complete_annotation_parameter.common()); - minimal_annotation_parameter.common().member_type_id(minimal_from_complete_type_identifier( + minimal_annotation_parameter.common().member_type_id(get_complementary_type_identifier( complete_annotation_parameter.common().member_type_id())); minimal_annotation_parameter.name_hash(TypeObjectUtils::name_hash( complete_annotation_parameter.name().c_str())); @@ -969,7 +969,7 @@ const MinimalStructType TypeObjectRegistry::build_minimal_from_complete_struct_t { MinimalStructType minimal_struct_type; minimal_struct_type.struct_flags(complete_struct_type.struct_flags()); - minimal_struct_type.header().base_type(minimal_from_complete_type_identifier( + minimal_struct_type.header().base_type(get_complementary_type_identifier( complete_struct_type.header().base_type())); // header().detail: empty. Available for future extension. MinimalStructMemberSeq minimal_struct_member_sequence; @@ -977,7 +977,7 @@ const MinimalStructType TypeObjectRegistry::build_minimal_from_complete_struct_t { MinimalStructMember minimal_struct_member; minimal_struct_member.common(complete_struct_member.common()); - minimal_struct_member.common().member_type_id(minimal_from_complete_type_identifier( + minimal_struct_member.common().member_type_id(get_complementary_type_identifier( complete_struct_member.common().member_type_id())); minimal_struct_member.detail().name_hash(TypeObjectUtils::name_hash( complete_struct_member.detail().name().c_str())); @@ -994,14 +994,14 @@ const MinimalUnionType TypeObjectRegistry::build_minimal_from_complete_union_typ minimal_union_type.union_flags(complete_union_type.union_flags()); // header: empty. Available for future extension. minimal_union_type.discriminator().common(complete_union_type.discriminator().common()); - minimal_union_type.discriminator().common().type_id(minimal_from_complete_type_identifier( + minimal_union_type.discriminator().common().type_id(get_complementary_type_identifier( complete_union_type.discriminator().common().type_id())); MinimalUnionMemberSeq minimal_union_member_sequence; for (const CompleteUnionMember& complete_union_member : complete_union_type.member_seq()) { MinimalUnionMember minimal_union_member; minimal_union_member.common(complete_union_member.common()); - minimal_union_member.common().type_id(minimal_from_complete_type_identifier( + minimal_union_member.common().type_id(get_complementary_type_identifier( minimal_union_member.common().type_id())); minimal_union_member.detail().name_hash(TypeObjectUtils::name_hash( complete_union_member.detail().name().c_str())); @@ -1037,7 +1037,7 @@ const MinimalSequenceType TypeObjectRegistry::build_minimal_from_complete_sequen // collection_flag: unused. No flags apply. minimal_sequence_type.header().common(complete_sequence_type.header().common()); minimal_sequence_type.element().common(complete_sequence_type.element().common()); - minimal_sequence_type.element().common().type(minimal_from_complete_type_identifier( + minimal_sequence_type.element().common().type(get_complementary_type_identifier( complete_sequence_type.element().common().type())); return minimal_sequence_type; } @@ -1049,7 +1049,7 @@ const MinimalArrayType TypeObjectRegistry::build_minimal_from_complete_array_typ // collection_flag: unused. No flags apply. minimal_array_type.header().common(complete_array_type.header().common()); minimal_array_type.element().common(complete_array_type.element().common()); - minimal_array_type.element().common().type(minimal_from_complete_type_identifier( + minimal_array_type.element().common().type(get_complementary_type_identifier( complete_array_type.element().common().type())); return minimal_array_type; } @@ -1061,10 +1061,10 @@ const MinimalMapType TypeObjectRegistry::build_minimal_from_complete_map_type( // collection_flag: unused. No flags apply. minimal_map_type.header().common(complete_map_type.header().common()); minimal_map_type.key().common(complete_map_type.key().common()); - minimal_map_type.key().common().type(minimal_from_complete_type_identifier( + minimal_map_type.key().common().type(get_complementary_type_identifier( complete_map_type.key().common().type())); minimal_map_type.element().common(complete_map_type.element().common()); - minimal_map_type.element().common().type(minimal_from_complete_type_identifier( + minimal_map_type.element().common().type(get_complementary_type_identifier( complete_map_type.element().common().type())); return minimal_map_type; } diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp index 08e6f57a2dc..1ece6d33a6c 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp @@ -270,13 +270,13 @@ class TypeObjectRegistry : public ITypeObjectRegistry std::unordered_set& type_dependencies); /** - * @brief Get Complete TypeIdentifier from Minimal TypeIdentifier. + * @brief Get Complementary TypeIdentifier. * - * @param minimal_type_id Direct hash minimal TypeIdentifier - * @return TypeIdentifier Complete TypeIdentifier related to the given Minimal TypeIdentifier. - * Same TypeIdentifier if the given TypeIdentifier is not a direct hash minimal TypeIdentifier. + * @param type_id Direct hash TypeIdentifier + * @return TypeIdentifier complementary to the given type_id. + * Same TypeIdentifier if the given TypeIdentifier is not a direct hash TypeIdentifier. */ - const TypeIdentifier complete_from_minimal_type_identifier( + const TypeIdentifier get_complementary_type_identifier( const TypeIdentifier& minimal_type_id); // Only DomainParticipantFactory is allowed to instantiate the TypeObjectRegistry class. @@ -735,16 +735,6 @@ class TypeObjectRegistry : public ITypeObjectRegistry */ void register_primitive_type_identifiers(); - /** - * @brief Get Minimal TypeIdentifier from Complete TypeIdentifier. - * - * @param complete_type_id Direct hash complete TypeIdentifier - * @return TypeIdentifier Minimal TypeIdentifier related to the given Complete TypeIdentifier. - * Same TypeIdentifier if the given TypeIdentifier is not a direct hash complete TypeIdentifier. - */ - const TypeIdentifier minimal_from_complete_type_identifier( - const TypeIdentifier& complete_type_id); - // Collection of local TypeIdentifiers hashed by type_name. // TypeIdentifierPair contains both the minimal and complete TypeObject TypeIdentifiers. // In case of indirect hash TypeIdentifiers, type_identifier_2 would be uninitialized (TK_NONE). diff --git a/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp deleted file mode 100644 index 983af2d0fe2..00000000000 --- a/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2020 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -#ifndef _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP -#define _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP - -#include - -#include - -#include - -#include -#include - -namespace eprosima { - -namespace fastrtps { -namespace rtps { - -class BuiltinProtocols; -class ReaderHistory; -class RTPSParticipantImpl; -class StatefulReader; -class StatefulWriter; -class ParticipantProxyData; -class WriterHistory; - -} // namespace rtps -} // namespace fastrtps - -namespace fastdds { -namespace dds { -namespace builtin { - -const fastrtps::rtps::SampleIdentity INVALID_SAMPLE_IDENTITY; - -/** - * Class TypeLookupManager that implements the TypeLookup Service described in the DDS-XTYPES 1.2 specification. - * @ingroup XTYPES - */ -class TypeLookupManager -{ - -public: - - /** - * Constructor - */ - TypeLookupManager() - { - } - - virtual ~TypeLookupManager() - { - } - - MOCK_CONST_METHOD3(get_type_dependencies, SampleIdentity( - const eprosima::fastdds::dds::xtypes::TypeIdentifierSeq&, - const fastrtps::rtps::GuidPrefix_t&, - const std::vector&)); - - MOCK_CONST_METHOD2(get_types, SampleIdentity( - const eprosima::fastdds::dds::xtypes::TypeIdentifierSeq&, - const fastrtps::rtps::GuidPrefix_t&)); - - void remove_remote_endpoints( - fastrtps::rtps::ParticipantProxyData* pdata) - { - static_cast(pdata); - } - -}; - -} /* namespace builtin */ -} /* namespace dds */ -} /* namespace fastdds */ -} /* namespace eprosima */ -#endif /* _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP */ From a797a5e0dcc414d1a88aa22bfe7e51ed2aa62230 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Tue, 23 Jan 2024 11:55:40 +0100 Subject: [PATCH 12/35] Refs #20160: Added valid_matching check for TypeInformation. Signed-off-by: adriancampo --- src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 15 +--- src/cpp/rtps/builtin/data/WriterProxyData.cpp | 15 +--- .../rtps/builtin/discovery/endpoint/EDP.cpp | 9 ++ src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 3 + .../discovery/endpoint/EDPSimpleListeners.cpp | 34 ++++---- .../type_lookup_service/TypeLookupManager.hpp | 87 +++++++++++++++++++ 6 files changed, 123 insertions(+), 40 deletions(-) create mode 100644 test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index a7e663f8f34..d629125f36b 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -974,27 +974,18 @@ bool ReaderProxyData::readFromCDRMessage( } case fastdds::dds::PID_TYPE_IDV1: { - if (!fastdds::dds::QosPoliciesSerializer::read_from_cdr_message(type_id(), msg, - plength)) - { - return false; - } + EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, "PID_TYPE_IDV1 not supported"); break; } case fastdds::dds::PID_TYPE_OBJECTV1: { - if (!fastdds::dds::QosPoliciesSerializer::read_from_cdr_message(type(), msg, - plength)) - { - return false; - } + EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, "PID_TYPE_OBJECTV1 not supported"); break; } case fastdds::dds::PID_TYPE_INFORMATION: { if (!fastdds::dds::QosPoliciesSerializer:: - read_from_cdr_message( - type_information(), msg, plength)) + read_from_cdr_message(type_information(), msg, plength)) { return false; } diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index 74e0c07c5b1..d11f02a360b 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -963,27 +963,18 @@ bool WriterProxyData::readFromCDRMessage( } case fastdds::dds::PID_TYPE_IDV1: { - if (!fastdds::dds::QosPoliciesSerializer::read_from_cdr_message(type_id(), msg, - plength)) - { - return false; - } + EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, "PID_TYPE_IDV1 not supported"); break; } case fastdds::dds::PID_TYPE_OBJECTV1: { - if (!fastdds::dds::QosPoliciesSerializer::read_from_cdr_message(type(), msg, - plength)) - { - return false; - } + EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, "PID_TYPE_OBJECTV1 not supported"); break; } case fastdds::dds::PID_TYPE_INFORMATION: { if (!fastdds::dds::QosPoliciesSerializer:: - read_from_cdr_message( - type_information(), msg, plength)) + read_from_cdr_message(type_information(), msg, plength)) { return false; } diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index d50f8be9da5..15a8f5d5171 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -575,6 +575,15 @@ bool EDP::valid_matching( return false; } + if (wdata->type_information().assigned() && rdata->type_information().assigned()) + { + if (wdata->type_information().type_information != rdata->type_information().type_information) + { + reason.set(MatchingFailureMask::different_typeinfo); + return false; + } + } + if (wdata->topicKind() != rdata->topicKind()) { EPROSIMA_LOG_WARNING(RTPS_EDP, "INCOMPATIBLE QOS:Remote Reader " << rdata->guid() << " is publishing in topic " diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index 17de21eb38f..a279d342011 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -88,6 +88,9 @@ class EDP //! Bit index for matching failing due to inconsistent partitions static const uint32_t partitions = (0x00000001 << 3u); + + //! Bit index for matching failing due to inconsistent TypeInformation + static const uint32_t different_typeinfo = (0x00000001 << 4u); }; /** diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index a72410f8745..b6d2deb738b 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -128,24 +128,25 @@ void EDPBasePUBListener::add_writer_from_change( // Remove change from history. reader_history->remove_change(reader_history->find_change(change), release_change); + // At this point, we can release the reader lock because the change is not used + reader->getMutex().unlock(); + // Check if TypeInformation exists to start the typelookup service if (temp_writer_data->type_information().assigned()) { - // At this point, we can release the reader lock because the change is not used - reader->getMutex().unlock(); - edp->mp_RTPSParticipant->typelookup_manager()->async_get_type( temp_writer_data, after_typelookup_callback); - - // Take the reader lock again if needed. - reader->getMutex().lock(); } + // If TypeInformation does not exists, try fallbacks else { - // Check if TypeInformation does not exists, log error - EPROSIMA_LOG_ERROR(RTPS_EDP, "EDPBasePUBListener::add_writer_from_change: No TypeInformation"); + EPROSIMA_LOG_WARNING(RTPS_EDP, "EDPBasePUBListener: No TypeInformation. Using fallbacks"); + after_typelookup_callback(temp_writer_data); } + + // Take the reader lock again if needed. + reader->getMutex().lock(); } } @@ -262,24 +263,25 @@ void EDPBaseSUBListener::add_reader_from_change( // Remove change from history. reader_history->remove_change(reader_history->find_change(change), release_change); + // At this point, we can release the reader lock because the change is not used + reader->getMutex().unlock(); + // Check if TypeInformation exists to start the typelookup service if (temp_reader_data->type_information().assigned()) { - // At this point, we can release the reader lock because the change is not used - reader->getMutex().unlock(); - edp->mp_RTPSParticipant->typelookup_manager()->async_get_type( temp_reader_data, after_typelookup_callback); - - // Take the reader lock again if needed. - reader->getMutex().lock(); } + // If TypeInformation does not exists, try fallbacks else { - // Check if TypeInformation does not exists, log error - EPROSIMA_LOG_ERROR(RTPS_EDP, "EDPBasePUBListener::add_reader_from_change: No TypeInformation"); + EPROSIMA_LOG_WARNING(RTPS_EDP, "EDPBasePUBListener: No TypeInformation. Using fallbacks"); + after_typelookup_callback(temp_reader_data); } + + // Take the reader lock again if needed. + reader->getMutex().lock(); } } diff --git a/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp new file mode 100644 index 00000000000..a6c6da79944 --- /dev/null +++ b/test/mock/rtps/TypeLookupManager/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -0,0 +1,87 @@ +// Copyright 2020 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +#ifndef _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP +#define _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP + +#include + +#include + +#include + +#include + +namespace eprosima { + +namespace fastrtps { +namespace rtps { + +class BuiltinProtocols; +class ReaderHistory; +class RTPSParticipantImpl; +class StatefulReader; +class StatefulWriter; +class ParticipantProxyData; +class WriterHistory; + +} // namespace rtps +} // namespace fastrtps + +namespace fastdds { +namespace dds { +namespace builtin { + +extern const fastrtps::rtps::SampleIdentity INVALID_SAMPLE_IDENTITY; + +/** + * Class TypeLookupManager that implements the TypeLookup Service described in the DDS-XTYPES 1.2 specification. + * @ingroup XTYPES + */ +class TypeLookupManager +{ + +public: + + /** + * Constructor + */ + TypeLookupManager() + { + } + + virtual ~TypeLookupManager() + { + } + + MOCK_CONST_METHOD1(get_type_dependencies, fastrtps::rtps::SampleIdentity( + const fastdds::dds::xtypes::TypeIdentifierSeq&)); + + MOCK_CONST_METHOD1(get_types, fastrtps::rtps::SampleIdentity( + const fastdds::dds::xtypes::TypeIdentifierSeq&)); + + void remove_remote_endpoints( + fastrtps::rtps::ParticipantProxyData* pdata) + { + static_cast(pdata); + } + +}; + +} /* namespace builtin */ +} /* namespace dds */ +} /* namespace fastdds */ +} /* namespace eprosima */ +#endif /* _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP */ From 0a928e02ec641e1aa266727cd9cbae9ecf371025 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 24 Jan 2024 08:42:51 +0100 Subject: [PATCH 13/35] Refs #20160: Added send and receive error logs. Added missing continuation_point reply management Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.cpp | 32 +++++++++++++++---- .../TypeLookupReplyListener.cpp | 28 +++++++++++++--- .../TypeLookupReplyListener.hpp | 10 +++++- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 41e58489b11..91aff8da58c 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -688,13 +688,23 @@ bool TypeLookupManager::prepare_send_payload( bool TypeLookupManager::send( TypeLookup_Request& request) const { - return send_impl(request, &request_type_, builtin_request_writer_, builtin_request_writer_history_); + if (!send_impl(request, &request_type_, builtin_request_writer_, builtin_request_writer_history_)) + { + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE, "Error sending request."); + return false; + } + return true; } bool TypeLookupManager::send( TypeLookup_Reply& reply) const { - return send_impl(reply, &reply_type_, builtin_reply_writer_, builtin_reply_writer_history_); + if (!send_impl(reply, &reply_type_, builtin_reply_writer_, builtin_reply_writer_history_)) + { + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE, "Error sending reply."); + return false; + } + return true; } template @@ -783,8 +793,13 @@ bool TypeLookupManager::receive( fastrtps::rtps::CacheChange_t& change, TypeLookup_Request& request) const { - if (receive_impl(change, request, &request_type_) && - request.header().instanceName() != local_instance_name_) + if (!receive_impl(change, request, &request_type_)) + { + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE, "Error receiving request."); + return false; + } + + if (request.header().instanceName() != local_instance_name_) { // Ignore request return false; @@ -796,8 +811,13 @@ bool TypeLookupManager::receive( fastrtps::rtps::CacheChange_t& change, TypeLookup_Reply& reply) const { - if (receive_impl(change, reply, &reply_type_) && - guid_dds_2_rtps(reply.header().relatedRequestId().writer_guid()) != builtin_request_writer_->getGuid()) + if (!receive_impl(change, reply, &reply_type_)) + { + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE, "Error receiving reply."); + return false; + } + + if (guid_dds_2_rtps(reply.header().relatedRequestId().writer_guid()) != builtin_request_writer_->getGuid()) { // Ignore reply return false; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index a2c442436b5..4b790318caf 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -110,7 +110,7 @@ void TypeLookupReplyListener::process_reply() case TypeLookup_getTypes_HashId: { check_get_types_reply(reply.header().relatedRequestId(), - reply.return_value().getType().result()); + reply.return_value().getType().result(), reply.header().relatedRequestId()); break; } case TypeLookup_getDependencies_HashId: @@ -134,7 +134,9 @@ void TypeLookupReplyListener::process_reply() void TypeLookupReplyListener::check_get_types_reply( const SampleIdentity& request_id, - const TypeLookup_getTypes_Out& reply) + const TypeLookup_getTypes_Out& reply, + SampleIdentity related_request + ) { // Check if the received reply SampleIdentity corresponds to an outstanding request auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); @@ -154,8 +156,19 @@ void TypeLookupReplyListener::check_get_types_reply( if (RETCODE_OK == register_result) { - // Notify the callbacks associated with the request - typelookup_manager_->notify_callbacks(requests_it->second); + // Check if this reply has a continuation_point + std::unique_lock guard(replies_with_continuation_mutex_); + auto it = std::find(replies_with_continuation_.begin(), replies_with_continuation_.end(), related_request); + if (it != replies_with_continuation_.end()) + { + // If it is, remove it from the list and continue + replies_with_continuation_.erase(it); + } + else + { + // If it is not, notify the callbacks associated with the request + typelookup_manager_->notify_callbacks(requests_it->second); + } } else { @@ -231,6 +244,13 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( { // Store the type request typelookup_manager_->add_async_get_type_request(get_types_request, requests_it->second); + + // If this get_types request has a continuation_point, store it in the list + if (!reply.continuation_point().empty()) + { + std::unique_lock guard(replies_with_continuation_mutex_); + replies_with_continuation_.push_back(get_types_request); + } } else { diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index c50697d460b..16187022766 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -96,10 +96,12 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa * This method also notifies all type related callbacks and removes the current SampleIdentity from the pending request list. * @param request_id[in] The SampleIdentity of the request. * @param reply[in] The reply data. + * @param related_request[in] The request that this reply answers. */ void check_get_types_reply( const SampleIdentity& request_id, - const TypeLookup_getTypes_Out& reply); + const TypeLookup_getTypes_Out& reply, + SampleIdentity related_request); /** * @brief Checks if all dependencies are solved. @@ -128,6 +130,12 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa //! A pointer to the typelookup manager. TypeLookupManager* typelookup_manager_; + //! Mutex to protect access to replies_with_continuation_. + std::mutex replies_with_continuation_mutex_; + + //! Collection of the replies that needed continuation points. + std::vector replies_with_continuation_; + eprosima::thread replies_processor_thread; std::queue replies_queue_; std::mutex replies_processor_cv_mutex_; From 3c1f4271c7764504d91e9463a8dbe335aa76b29e Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 25 Jan 2024 15:27:56 +0100 Subject: [PATCH 14/35] Refs #20160: Added check for requests with no TypeIdentifiers and small fixes. Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.hpp | 2 +- .../TypeLookupReplyListener.cpp | 4 +-- .../TypeLookupReplyListener.hpp | 2 +- .../TypeLookupRequestListener.cpp | 4 ++- .../TypeLookupRequestListener.hpp | 2 +- src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 32 ++----------------- src/cpp/rtps/builtin/data/WriterProxyData.cpp | 32 +++---------------- .../rtps/builtin/discovery/endpoint/EDP.cpp | 3 +- 8 files changed, 17 insertions(+), 64 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index b37328072e6..c0c84bfdc53 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -189,7 +189,7 @@ class TypeLookupManager eprosima::ProxyPool::smart_ptr& temp_proxy_data, const AsyncGetTypeReaderCallback& callback); -private: +protected: /** * Checks if the given TypeIdentfierWithSize is known by the TypeObjectRegistry. diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 4b790318caf..c6992b6419c 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -135,8 +135,7 @@ void TypeLookupReplyListener::process_reply() void TypeLookupReplyListener::check_get_types_reply( const SampleIdentity& request_id, const TypeLookup_getTypes_Out& reply, - SampleIdentity related_request - ) + SampleIdentity related_request) { // Check if the received reply SampleIdentity corresponds to an outstanding request auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); @@ -274,6 +273,7 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( // Log a warning and remove the change from the history EPROSIMA_LOG_WARNING(TL_REPLY_READER, "Received data from a bad endpoint."); reader->getHistory()->remove_change(change); + return; } // Process the received TypeLookup Reply and handle different types of replies diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 16187022766..8a4b4eaa569 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -74,7 +74,7 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa */ virtual ~TypeLookupReplyListener() override; -private: +protected: /** * @brief Starts the thread that process the received replies. diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index c18991f1f8e..3d93ec8a9b5 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -249,8 +249,9 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( { std::unordered_set type_dependencies; ReturnCode_t type_dependencies_result = RETCODE_ERROR; - // Check if the received request has been done before and needed a continuation point + if (!request.type_ids().empty()) { + // Check if the received request has been done before and needed a continuation point std::lock_guard lock(requests_with_continuation_mutex_); if (!request.continuation_point().empty()) { @@ -406,6 +407,7 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( // Log a warning and remove the change from the history EPROSIMA_LOG_WARNING(TL_REQUEST_READER, "Received data from a bad endpoint."); reader->getHistory()->remove_change(change); + return; } // Process the received TypeLookup Request and handle different types of requests diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index f77b9e3f5d2..951c564e055 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -91,7 +91,7 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public */ virtual ~TypeLookupRequestListener() override; -private: +protected: /** * @brief Starts the thread that process the received requests. diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index d629125f36b..eed0b729ad2 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -288,14 +288,6 @@ uint32_t ReaderProxyData::get_serialized_size( ret_val += fastdds::dds::QosPoliciesSerializer::cdr_serialized_size( m_qos.m_disablePositiveACKs); } - if (m_type_id && m_type_id->m_type_identifier._d() != fastdds::dds::xtypes::TK_NONE) - { - ret_val += fastdds::dds::QosPoliciesSerializer::cdr_serialized_size(*m_type_id); - } - if (m_type && m_type->m_type_object._d() != fastdds::dds::xtypes::TK_NONE) - { - ret_val += fastdds::dds::QosPoliciesSerializer::cdr_serialized_size(*m_type); - } if (m_type_information && m_type_information->assigned()) { ret_val += @@ -550,23 +542,14 @@ bool ReaderProxyData::writeToCDRMessage( return false; } } - - if (m_type_id && m_type_id->m_type_identifier._d() != fastdds::dds::xtypes::TK_NONE) - { - if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(*m_type_id, msg)) - { - return false; - } - } - - if (m_type && m_type->m_type_object._d() != fastdds::dds::xtypes::TK_NONE) + if (m_type_information && m_type_information->assigned()) { - if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(*m_type, msg)) + if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(* + m_type_information, msg)) { return false; } } - if (m_properties.size() > 0) { if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(m_properties, msg)) @@ -615,15 +598,6 @@ bool ReaderProxyData::writeToCDRMessage( } } - if (m_type_information && m_type_information->assigned()) - { - if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(* - m_type_information, msg)) - { - return false; - } - } - if ((m_qos.data_sharing.send_always() || m_qos.data_sharing.hasChanged) && m_qos.data_sharing.kind() != fastdds::dds::OFF) { diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index d11f02a360b..8da276e7fd2 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -296,14 +296,6 @@ uint32_t WriterProxyData::get_serialized_size( { ret_val += fastdds::dds::QosPoliciesSerializer::cdr_serialized_size(m_qos.m_groupData); } - if (m_type_id && m_type_id->m_type_identifier._d() != fastdds::dds::xtypes::TK_NONE) - { - ret_val += fastdds::dds::QosPoliciesSerializer::cdr_serialized_size(*m_type_id); - } - if (m_type && m_type->m_type_object._d() != fastdds::dds::xtypes::TK_NONE) - { - ret_val += fastdds::dds::QosPoliciesSerializer::cdr_serialized_size(*m_type); - } if (m_type_information && m_type_information->assigned()) { ret_val += @@ -564,23 +556,14 @@ bool WriterProxyData::writeToCDRMessage( return false; } } - - if (m_type_id && m_type_id->m_type_identifier._d() != fastdds::dds::xtypes::TK_NONE) - { - if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(*m_type_id, msg)) - { - return false; - } - } - - if (m_type && m_type->m_type_object._d() != fastdds::dds::xtypes::TK_NONE) + if (m_type_information && m_type_information->assigned()) { - if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(*m_type, msg)) + if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(* + m_type_information, msg)) { return false; } } - if (m_properties.size() > 0) { if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(m_properties, msg)) @@ -611,14 +594,7 @@ bool WriterProxyData::writeToCDRMessage( } } - if (m_type_information && m_type_information->assigned()) - { - if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(* - m_type_information, msg)) - { - return false; - } - } + return fastdds::dds::ParameterSerializer::add_parameter_sentinel(msg); } diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 15a8f5d5171..714b7f51f81 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -575,7 +575,8 @@ bool EDP::valid_matching( return false; } - if (wdata->type_information().assigned() && rdata->type_information().assigned()) + if ((wdata->has_type_information() && wdata->type_information().assigned()) && + (rdata->has_type_information() && rdata->type_information().assigned())) { if (wdata->type_information().type_information != rdata->type_information().type_information) { From 9f3a1e3baa8b1aac6e8fde84bd2c6b220227acd4 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 31 Jan 2024 10:04:02 +0100 Subject: [PATCH 15/35] Refs #20160: Added listener classes to handle change acks Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.cpp | 14 ++++++-- .../type_lookup_service/TypeLookupManager.hpp | 18 +++++++++++ .../TypeLookupReplyListener.cpp | 4 +-- .../TypeLookupReplyListener.hpp | 32 +++++++++++++++++++ .../TypeLookupRequestListener.cpp | 4 +-- .../TypeLookupRequestListener.hpp | 32 +++++++++++++++++++ 6 files changed, 97 insertions(+), 7 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 91aff8da58c..fa25cd6f1b5 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -97,7 +97,9 @@ TypeLookupManager::~TypeLookupManager() delete builtin_reply_reader_history_; delete reply_listener_; + delete reply_wlistener_; delete request_listener_; + delete request_wlistener_; delete temp_reader_proxy_data_; delete temp_writer_proxy_data_; @@ -507,6 +509,7 @@ bool TypeLookupManager::create_endpoints() // Built-in request writer request_listener_ = new TypeLookupRequestListener(this); builtin_request_writer_history_ = new WriterHistory(hatt); + request_wlistener_ = new TypeLookupRequestWListener(this); RTPSWriter* req_writer; if (participant_->createWriter( @@ -525,12 +528,15 @@ bool TypeLookupManager::create_endpoints() EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup request writer creation failed."); delete builtin_request_writer_history_; builtin_request_writer_history_ = nullptr; + delete request_wlistener_; + request_wlistener_ = nullptr; return false; } // Built-in reply writer reply_listener_ = new TypeLookupReplyListener(this); builtin_reply_writer_history_ = new WriterHistory(hatt); + reply_wlistener_ = new TypeLookupReplyWListener(this); RTPSWriter* rep_writer; if (participant_->createWriter( @@ -549,6 +555,8 @@ bool TypeLookupManager::create_endpoints() EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup reply writer creation failed."); delete builtin_reply_writer_history_; builtin_reply_writer_history_ = nullptr; + delete reply_wlistener_; + reply_wlistener_ = nullptr; return false; } @@ -739,7 +747,7 @@ bool TypeLookupManager::send_impl( } // Serialize the message using the provided PubSubType - bool result = pubsubtype->serialize(&msg, &payload, DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); + bool result = pubsubtype->serialize(&msg, &payload, DataRepresentationId_t::XCDR_DATA_REPRESENTATION); // If serialization was successful, update the change and add it to the WriterHistory if (result) { @@ -858,13 +866,13 @@ std::string TypeLookupManager::get_instance_name( return "dds.builtin.TOS." + str; } -void TypeLookupManager::request_cache_change_acked( +void TypeLookupManager::remove_builtin_request_writer_history_change( fastrtps::rtps::CacheChange_t* change) { builtin_request_writer_history_->remove_change(change); } -void TypeLookupManager::reply_cache_change_acked( +void TypeLookupManager::remove_builtin_reply_writer_history_change( fastrtps::rtps::CacheChange_t* change) { builtin_reply_writer_history_->remove_change(change); diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index c0c84bfdc53..bd0911e5553 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -115,7 +115,9 @@ using AsyncGetTypeReaderCallback = std::function< class TypeLookupManager { friend class TypeLookupRequestListener; + friend class TypeLookupRequestWListener; friend class TypeLookupReplyListener; + friend class TypeLookupReplyWListener; public: @@ -363,6 +365,20 @@ class TypeLookupManager */ bool create_endpoints(); + /** + * Removes a change from the builtin_request_writer_history_. + * @param change[in] CacheChange_t to be removed. + */ + void remove_builtin_request_writer_history_change( + fastrtps::rtps::CacheChange_t* change); + + /** + * Removes a change from the builtin_reply_writer_history_. + * @param change[in] CacheChange_t to be removed. + */ + void remove_builtin_reply_writer_history_change( + fastrtps::rtps::CacheChange_t* change); + //! Pointer to the local RTPSParticipant. fastrtps::rtps::RTPSParticipantImpl* participant_ = nullptr; @@ -398,9 +414,11 @@ class TypeLookupManager //! Request Listener object. TypeLookupRequestListener* request_listener_ = nullptr; + TypeLookupRequestWListener* request_wlistener_ = nullptr; //! Reply Listener object. TypeLookupReplyListener* reply_listener_ = nullptr; + TypeLookupReplyWListener* reply_wlistener_ = nullptr; //! Mutex to protect access to temp_reader_proxy_data_ and temp_writer_proxy_data_. std::mutex temp_data_lock_; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index c6992b6419c..9f06acd0082 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -303,11 +303,11 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( reader->getHistory()->remove_change(change); } -void TypeLookupReplyListener::onWriterChangeReceivedByAll( +void TypeLookupReplyWListener::onWriterChangeReceivedByAll( fastrtps::rtps::RTPSWriter*, fastrtps::rtps::CacheChange_t* change) { - typelookup_manager_->reply_cache_change_acked(change); + typelookup_manager_->remove_builtin_reply_writer_history_change(change); } } // namespace builtin diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 8a4b4eaa569..505f4fef9a2 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -144,6 +145,37 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa rtps::ThreadSettings replies_processor_thread_settings_; }; +class TypeLookupReplyWListener : public fastrtps::rtps::WriterListener +{ +public: + + /** + * @brief Constructor + * @param manager Pointer to the TypeLookupManager + */ + TypeLookupReplyWListener( + TypeLookupManager* manager) + : typelookup_manager_(manager) + { + } + + /** + * @brief Destructor + */ + virtual ~TypeLookupReplyWListener() override + { + } + + void onWriterChangeReceivedByAll( + fastrtps::rtps::RTPSWriter*, + fastrtps::rtps::CacheChange_t* change) override; + +private: + + //! A pointer to the typelookup manager + TypeLookupManager* typelookup_manager_; +}; + } /* namespace builtin */ } /* namespace dds */ } /* namespace fastdds */ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index 3d93ec8a9b5..d0d75975274 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -427,11 +427,11 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( reader->getHistory()->remove_change(change); } -void TypeLookupRequestListener::onWriterChangeReceivedByAll( +void TypeLookupRequestWListener::onWriterChangeReceivedByAll( fastrtps::rtps::RTPSWriter*, fastrtps::rtps::CacheChange_t* change) { - typelookup_manager_->request_cache_change_acked(change); + typelookup_manager_->remove_builtin_request_writer_history_change(change); } } // namespace builtin diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index 951c564e055..cdb660351b6 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -183,6 +184,37 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public rtps::ThreadSettings request_processor_thread_settings_; }; +class TypeLookupRequestWListener : public fastrtps::rtps::WriterListener +{ +public: + + /** + * @brief Constructor + * @param pwlp Pointer to the TypeLookupManager + */ + TypeLookupRequestWListener( + TypeLookupManager* manager) + : typelookup_manager_(manager) + { + } + + /** + * @brief Destructor + */ + virtual ~TypeLookupRequestWListener() override + { + } + + void onWriterChangeReceivedByAll( + fastrtps::rtps::RTPSWriter*, + fastrtps::rtps::CacheChange_t* change) override; + +private: + + //! A pointer to the typelookup manager + TypeLookupManager* typelookup_manager_; +}; + } /* namespace builtin */ } /* namespace dds */ } /* namespace fastdds */ From cdd0a4b86c3bc609e226e35298b915b72577dc06 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 1 Feb 2024 10:27:39 +0100 Subject: [PATCH 16/35] Refs #20160: Restored minimal_from_complete_type_identifier method from TypeObjectRegistry Signed-off-by: adriancampo --- .../TypeObjectRegistry.cpp | 49 +++++++++++++++---- .../TypeObjectRegistry.hpp | 10 ++++ 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp index 3a25873ff02..803d71ed238 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp @@ -929,7 +929,7 @@ const MinimalAliasType TypeObjectRegistry::build_minimal_from_complete_alias_typ // alias_flags: unused. No flags apply. // header: empty. Available for future extension. minimal_alias_type.body().common(complete_alias_type.body().common()); - minimal_alias_type.body().common().related_type(get_complementary_type_identifier( + minimal_alias_type.body().common().related_type(minimal_from_complete_type_identifier( complete_alias_type.body().common().related_type())); return minimal_alias_type; } @@ -945,7 +945,7 @@ const MinimalAnnotationType TypeObjectRegistry::build_minimal_from_complete_anno { MinimalAnnotationParameter minimal_annotation_parameter; minimal_annotation_parameter.common(complete_annotation_parameter.common()); - minimal_annotation_parameter.common().member_type_id(get_complementary_type_identifier( + minimal_annotation_parameter.common().member_type_id(minimal_from_complete_type_identifier( complete_annotation_parameter.common().member_type_id())); minimal_annotation_parameter.name_hash(TypeObjectUtils::name_hash( complete_annotation_parameter.name().c_str())); @@ -969,7 +969,7 @@ const MinimalStructType TypeObjectRegistry::build_minimal_from_complete_struct_t { MinimalStructType minimal_struct_type; minimal_struct_type.struct_flags(complete_struct_type.struct_flags()); - minimal_struct_type.header().base_type(get_complementary_type_identifier( + minimal_struct_type.header().base_type(minimal_from_complete_type_identifier( complete_struct_type.header().base_type())); // header().detail: empty. Available for future extension. MinimalStructMemberSeq minimal_struct_member_sequence; @@ -977,7 +977,7 @@ const MinimalStructType TypeObjectRegistry::build_minimal_from_complete_struct_t { MinimalStructMember minimal_struct_member; minimal_struct_member.common(complete_struct_member.common()); - minimal_struct_member.common().member_type_id(get_complementary_type_identifier( + minimal_struct_member.common().member_type_id(minimal_from_complete_type_identifier( complete_struct_member.common().member_type_id())); minimal_struct_member.detail().name_hash(TypeObjectUtils::name_hash( complete_struct_member.detail().name().c_str())); @@ -994,14 +994,14 @@ const MinimalUnionType TypeObjectRegistry::build_minimal_from_complete_union_typ minimal_union_type.union_flags(complete_union_type.union_flags()); // header: empty. Available for future extension. minimal_union_type.discriminator().common(complete_union_type.discriminator().common()); - minimal_union_type.discriminator().common().type_id(get_complementary_type_identifier( + minimal_union_type.discriminator().common().type_id(minimal_from_complete_type_identifier( complete_union_type.discriminator().common().type_id())); MinimalUnionMemberSeq minimal_union_member_sequence; for (const CompleteUnionMember& complete_union_member : complete_union_type.member_seq()) { MinimalUnionMember minimal_union_member; minimal_union_member.common(complete_union_member.common()); - minimal_union_member.common().type_id(get_complementary_type_identifier( + minimal_union_member.common().type_id(minimal_from_complete_type_identifier( minimal_union_member.common().type_id())); minimal_union_member.detail().name_hash(TypeObjectUtils::name_hash( complete_union_member.detail().name().c_str())); @@ -1037,7 +1037,7 @@ const MinimalSequenceType TypeObjectRegistry::build_minimal_from_complete_sequen // collection_flag: unused. No flags apply. minimal_sequence_type.header().common(complete_sequence_type.header().common()); minimal_sequence_type.element().common(complete_sequence_type.element().common()); - minimal_sequence_type.element().common().type(get_complementary_type_identifier( + minimal_sequence_type.element().common().type(minimal_from_complete_type_identifier( complete_sequence_type.element().common().type())); return minimal_sequence_type; } @@ -1049,7 +1049,7 @@ const MinimalArrayType TypeObjectRegistry::build_minimal_from_complete_array_typ // collection_flag: unused. No flags apply. minimal_array_type.header().common(complete_array_type.header().common()); minimal_array_type.element().common(complete_array_type.element().common()); - minimal_array_type.element().common().type(get_complementary_type_identifier( + minimal_array_type.element().common().type(minimal_from_complete_type_identifier( complete_array_type.element().common().type())); return minimal_array_type; } @@ -1061,14 +1061,43 @@ const MinimalMapType TypeObjectRegistry::build_minimal_from_complete_map_type( // collection_flag: unused. No flags apply. minimal_map_type.header().common(complete_map_type.header().common()); minimal_map_type.key().common(complete_map_type.key().common()); - minimal_map_type.key().common().type(get_complementary_type_identifier( + minimal_map_type.key().common().type(minimal_from_complete_type_identifier( complete_map_type.key().common().type())); minimal_map_type.element().common(complete_map_type.element().common()); - minimal_map_type.element().common().type(get_complementary_type_identifier( + minimal_map_type.element().common().type(minimal_from_complete_type_identifier( complete_map_type.element().common().type())); return minimal_map_type; } +const TypeIdentifier TypeObjectRegistry::minimal_from_complete_type_identifier( + const TypeIdentifier& type_id) +{ + if (EK_COMPLETE == type_id._d() || + (TI_PLAIN_SEQUENCE_SMALL == type_id._d() && type_id.seq_sdefn().header().equiv_kind() == EK_COMPLETE) || + (TI_PLAIN_SEQUENCE_LARGE == type_id._d() && type_id.seq_ldefn().header().equiv_kind() == EK_COMPLETE) || + (TI_PLAIN_ARRAY_SMALL == type_id._d() && type_id.array_sdefn().header().equiv_kind() == EK_COMPLETE) || + (TI_PLAIN_ARRAY_LARGE == type_id._d() && type_id.array_ldefn().header().equiv_kind() == EK_COMPLETE) || + (TI_PLAIN_MAP_SMALL == type_id._d() && (type_id.map_sdefn().header().equiv_kind() == EK_COMPLETE || + type_id.map_sdefn().key_identifier()->_d() == EK_COMPLETE)) || + (TI_PLAIN_MAP_LARGE == type_id._d() && (type_id.map_ldefn().header().equiv_kind() == EK_COMPLETE || + type_id.map_ldefn().key_identifier()->_d() == EK_COMPLETE))) + { + std::lock_guard data_guard(type_object_registry_mutex_); + for (const auto& it : local_type_identifiers_) + { + if (it.second.type_identifier1() == type_id) + { + return it.second.type_identifier2(); + } + else if (it.second.type_identifier2() == type_id) + { + return it.second.type_identifier1(); + } + } + } + return type_id; +} + const MinimalEnumeratedType TypeObjectRegistry::build_minimal_from_complete_enumerated_type( const CompleteEnumeratedType& complete_enumerated_type) { diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp index 1ece6d33a6c..f8608dfcdb6 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp @@ -735,6 +735,16 @@ class TypeObjectRegistry : public ITypeObjectRegistry */ void register_primitive_type_identifiers(); + /** + * @brief Get Minimal TypeIdentifier from Complete TypeIdentifier. + * + * @param complete_type_id Direct hash complete TypeIdentifier + * @return TypeIdentifier Minimal TypeIdentifier related to the given Complete TypeIdentifier. + * Same TypeIdentifier if the given TypeIdentifier is not a direct hash complete TypeIdentifier. + */ + const TypeIdentifier minimal_from_complete_type_identifier( + const TypeIdentifier& complete_type_id); + // Collection of local TypeIdentifiers hashed by type_name. // TypeIdentifierPair contains both the minimal and complete TypeObject TypeIdentifiers. // In case of indirect hash TypeIdentifiers, type_identifier_2 would be uninitialized (TK_NONE). From 1e9bb2866ff1dc947017ac6bc6e121808e52ab3a Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 1 Feb 2024 21:00:06 +0100 Subject: [PATCH 17/35] Refs #20160: Fixes for TypeInformation serializer Signed-off-by: adriancampo --- .../core/policy/QosPoliciesSerializer.hpp | 20 ++++--------- .../TypeObjectRegistry.cpp | 29 ------------------- 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp b/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp index d8a15a752a4..a7f7e478e72 100644 --- a/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp +++ b/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp @@ -1045,7 +1045,7 @@ template<> inline uint32_t QosPoliciesSerializer::cdr_serialized_size( const xtypes::TypeInformationParameter& qos_policy) { - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; size_t size = calculator.calculate_serialized_size(qos_policy.type_information, current_alignment) + 4; return 2 + 2 + static_cast(size); @@ -1056,7 +1056,7 @@ inline bool QosPoliciesSerializer::add_to_cdr_ const xtypes::TypeInformationParameter& qos_policy, fastrtps::rtps::CDRMessage_t* cdr_message) { - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; size_t size = calculator.calculate_serialized_size(qos_policy.type_information, @@ -1065,10 +1065,10 @@ inline bool QosPoliciesSerializer::add_to_cdr_ eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. + eprosima::fastcdr::CdrVersion::XCDRv2); // Object that serializes the data. payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - ser.serialize_encapsulation(); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR); ser << qos_policy.type_information; #if FASTCDR_VERSION_MAJOR == 1 @@ -1102,18 +1102,10 @@ inline bool QosPoliciesSerializer::read_conten fastrtps::rtps::CDRMessage::readData(cdr_message, payload.data, parameter_length); // Object that manages the raw buffer. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::CdrVersion::XCDRv2); try { - // Deserialize encapsulation. - deser.read_encapsulation(); - payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - deser >> qos_policy.type_information; qos_policy.assigned(true); } diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp index 803d71ed238..1a4754f075c 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp @@ -1069,35 +1069,6 @@ const MinimalMapType TypeObjectRegistry::build_minimal_from_complete_map_type( return minimal_map_type; } -const TypeIdentifier TypeObjectRegistry::minimal_from_complete_type_identifier( - const TypeIdentifier& type_id) -{ - if (EK_COMPLETE == type_id._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_id._d() && type_id.seq_sdefn().header().equiv_kind() == EK_COMPLETE) || - (TI_PLAIN_SEQUENCE_LARGE == type_id._d() && type_id.seq_ldefn().header().equiv_kind() == EK_COMPLETE) || - (TI_PLAIN_ARRAY_SMALL == type_id._d() && type_id.array_sdefn().header().equiv_kind() == EK_COMPLETE) || - (TI_PLAIN_ARRAY_LARGE == type_id._d() && type_id.array_ldefn().header().equiv_kind() == EK_COMPLETE) || - (TI_PLAIN_MAP_SMALL == type_id._d() && (type_id.map_sdefn().header().equiv_kind() == EK_COMPLETE || - type_id.map_sdefn().key_identifier()->_d() == EK_COMPLETE)) || - (TI_PLAIN_MAP_LARGE == type_id._d() && (type_id.map_ldefn().header().equiv_kind() == EK_COMPLETE || - type_id.map_ldefn().key_identifier()->_d() == EK_COMPLETE))) - { - std::lock_guard data_guard(type_object_registry_mutex_); - for (const auto& it : local_type_identifiers_) - { - if (it.second.type_identifier1() == type_id) - { - return it.second.type_identifier2(); - } - else if (it.second.type_identifier2() == type_id) - { - return it.second.type_identifier1(); - } - } - } - return type_id; -} - const MinimalEnumeratedType TypeObjectRegistry::build_minimal_from_complete_enumerated_type( const CompleteEnumeratedType& complete_enumerated_type) { From 50ef6b0e99d3f80750035ab56b598c01c817d37a Mon Sep 17 00:00:00 2001 From: adriancampo Date: Sun, 4 Feb 2024 18:37:42 +0100 Subject: [PATCH 18/35] Refs #20160: Added typelookup_service_threads to XMLParser Signed-off-by: adriancampo --- src/cpp/xmlparser/XMLParser.cpp | 8 ++++++++ src/cpp/xmlparser/XMLParserCommon.cpp | 1 + 2 files changed, 9 insertions(+) diff --git a/src/cpp/xmlparser/XMLParser.cpp b/src/cpp/xmlparser/XMLParser.cpp index 3ce84a22815..20a6cf1a575 100644 --- a/src/cpp/xmlparser/XMLParser.cpp +++ b/src/cpp/xmlparser/XMLParser.cpp @@ -2486,6 +2486,14 @@ XMLP_ret XMLParser::fillDataNode( return XMLP_ret::XML_ERROR; } } + else if (strcmp(name, TYPELOOKUP_SERVICE_THREADS) == 0) + { + if (XMLP_ret::XML_OK != + getXMLThreadSettings(*p_aux0, participant_node.get()->rtps.typelookup_service_threads)) + { + return XMLP_ret::XML_ERROR; + } + } else if (strcmp(name, BUILTIN_TRANSPORTS_RECEPTION_THREADS) == 0) { if (XMLP_ret::XML_OK != diff --git a/src/cpp/xmlparser/XMLParserCommon.cpp b/src/cpp/xmlparser/XMLParserCommon.cpp index a165d102853..a57f288ff61 100644 --- a/src/cpp/xmlparser/XMLParserCommon.cpp +++ b/src/cpp/xmlparser/XMLParserCommon.cpp @@ -146,6 +146,7 @@ const char* MAX_USER_DATA = "max_user_data"; const char* MAX_PARTITIONS = "max_partitions"; const char* TIMED_EVENTS_THREAD = "timed_events_thread"; const char* DISCOVERY_SERVER_THREAD = "discovery_server_thread"; +const char* TYPELOOKUP_SERVICE_THREADS = "typelookup_service_threads"; const char* SECURITY_LOG_THREAD = "security_log_thread"; const char* BUILTIN_TRANSPORTS_RECEPTION_THREADS = "builtin_transports_reception_threads"; const char* BUILTIN_CONTROLLERS_SENDER_THREAD = "builtin_controllers_sender_thread"; From 9556352d2d6886bc816d2c52eba0c1c41e325cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 6 Feb 2024 10:50:10 +0100 Subject: [PATCH 19/35] Refs #20160. Remove old function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../type_lookup_service/TypeLookupManager.cpp | 25 ++----------------- .../type_lookup_service/TypeLookupManager.hpp | 10 -------- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index fa25cd6f1b5..ebfbdc31102 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -676,23 +676,6 @@ TypeLookup_Request* TypeLookupManager::create_request( return request; } -bool TypeLookupManager::prepare_send_payload( - fastrtps::rtps::CacheChange_t* change, - fastrtps::rtps::SerializedPayload_t& payload) const -{ - CDRMessage_t msg(change->serializedPayload); - bool valid = CDRMessage::addOctet(&msg, 0); - change->serializedPayload.encapsulation = static_cast(PL_DEFAULT_ENCAPSULATION); - msg.msg_endian = DEFAULT_ENDIAN; - valid &= CDRMessage::addOctet(&msg, PL_DEFAULT_ENCAPSULATION); - valid &= CDRMessage::addUInt16(&msg, 0); - change->serializedPayload.pos = msg.pos; - change->serializedPayload.length = msg.length; - payload.max_size = change->serializedPayload.max_size - 4; - payload.data = change->serializedPayload.data + 4; - return valid; -} - bool TypeLookupManager::send( TypeLookup_Request& request) const { @@ -727,7 +710,7 @@ bool TypeLookupManager::send_impl( [&msg]() { // Calculate the serialized size of the message using a CdrSizeCalculator - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size(msg, current_alignment) + 4); }, @@ -741,13 +724,9 @@ bool TypeLookupManager::send_impl( // Prepare the payload for sending the message SerializedPayload_t payload; - if (!prepare_send_payload(change, payload)) - { - return false; - } // Serialize the message using the provided PubSubType - bool result = pubsubtype->serialize(&msg, &payload, DataRepresentationId_t::XCDR_DATA_REPRESENTATION); + bool result = pubsubtype->serialize(&msg, &payload, DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); // If serialization was successful, update the change and add it to the WriterHistory if (result) { diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index bd0911e5553..c9d0c9ea00b 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -257,16 +257,6 @@ class TypeLookupManager const fastrtps::rtps::GuidPrefix_t& type_server, TypeLookup_RequestPubSubType& pupsubtype) const; - /** - * Prepares the the payload for sending a CacheChange before serializing. - * @param change[in] CacheChange_t received. - * @param payload[out] SerializedPayload_t prepared. - * @return true if received payload is prepared, false otherwise. - */ - bool prepare_send_payload( - fastrtps::rtps::CacheChange_t* change, - fastrtps::rtps::SerializedPayload_t& payload) const; - /** * Uses the send_impl with the appropriate parameters. * @param request[in] TypeLookup_Request to be sent. From 343475d361e07803b75f5ac83bf537bab7f9a1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 6 Feb 2024 11:27:27 +0100 Subject: [PATCH 20/35] Refs #20160. Fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../fastdds/builtin/type_lookup_service/TypeLookupManager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index ebfbdc31102..56379ca5daf 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -724,6 +724,8 @@ bool TypeLookupManager::send_impl( // Prepare the payload for sending the message SerializedPayload_t payload; + payload.max_size = change->serializedPayload.max_size; + payload.data = change->serializedPayload.data; // Serialize the message using the provided PubSubType bool result = pubsubtype->serialize(&msg, &payload, DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); From 129f7ea617e2f95f8bfb0ab61301c19fbd933650 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Tue, 6 Feb 2024 13:03:00 +0100 Subject: [PATCH 21/35] Refs #20160: Fixes for TypeLookupManager destruction with pending callbacks. Signed-off-by: adriancampo --- src/cpp/rtps/builtin/BuiltinProtocols.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index 2d3072dac63..420fc946da1 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -52,6 +52,9 @@ BuiltinProtocols::BuiltinProtocols() BuiltinProtocols::~BuiltinProtocols() { + // This needs to be done first because of the WriterProxydata and ReaderProxyData smart_ptr + delete typelookup_manager_; + // Send participant is disposed if (mp_PDP != nullptr) { @@ -61,7 +64,7 @@ BuiltinProtocols::~BuiltinProtocols() // TODO Auto-generated destructor stub delete mp_WLP; delete mp_PDP; - delete typelookup_manager_; + } bool BuiltinProtocols::initBuiltinProtocols( From 45f94b559a4146ec04b6badc3fce77409e890deb Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 7 Feb 2024 09:02:20 +0100 Subject: [PATCH 22/35] Refs #20160: Changes for instance_names to use the full GUID. Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.cpp | 26 ++++++++++++------- .../type_lookup_service/TypeLookupManager.hpp | 16 ++++++------ .../TypeLookupReplyListener.cpp | 4 +-- .../TypeLookupReplyListener.hpp | 6 ++--- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 56379ca5daf..26ebf26bcd9 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -111,7 +111,7 @@ bool TypeLookupManager::init( participant_ = protocols->mp_participantImpl; builtin_protocols_ = protocols; - local_instance_name_ = get_instance_name(participant_->getGuid().guidPrefix); + local_instance_name_ = get_instance_name(participant_->getGuid()); temp_reader_proxy_data_ = new fastrtps::rtps::ReaderProxyData( protocols->mp_participantImpl->getRTPSParticipantAttributes().allocation.locators.max_unicast_locators, @@ -258,7 +258,7 @@ void TypeLookupManager::remove_remote_endpoints( SampleIdentity TypeLookupManager::get_type_dependencies( const xtypes::TypeIdentifierSeq& id_seq, - const fastrtps::rtps::GuidPrefix_t& type_server, + const fastrtps::rtps::GUID_t& type_server, const std::vector& continuation_point) const { TypeLookup_getTypeDependencies_In in; @@ -287,7 +287,7 @@ SampleIdentity TypeLookupManager::get_type_dependencies( SampleIdentity TypeLookupManager::get_types( const xtypes::TypeIdentifierSeq& id_seq, - const fastrtps::rtps::GuidPrefix_t& type_server) const + const fastrtps::rtps::GUID_t& type_server) const { TypeLookup_getTypes_In in; in.type_ids(id_seq); @@ -335,7 +335,7 @@ ReturnCode_t TypeLookupManager::check_type_identifier_received( { xtypes::TypeIdentfierWithSize type_identifier_with_size = temp_proxy_data->type_information().type_information.complete().typeid_with_size(); - fastrtps::rtps::GuidPrefix_t type_server = temp_proxy_data->guid().guidPrefix; + fastrtps::rtps::GUID_t type_server = temp_proxy_data->guid(); // Check if the type is known if (fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). @@ -665,7 +665,7 @@ bool TypeLookupManager::create_endpoints() } TypeLookup_Request* TypeLookupManager::create_request( - const fastrtps::rtps::GuidPrefix_t& type_server, + const fastrtps::rtps::GUID_t& type_server, TypeLookup_RequestPubSubType& pupsubtype) const { TypeLookup_Request* request = static_cast(pupsubtype.createData()); @@ -833,17 +833,25 @@ bool TypeLookupManager::receive_impl( } std::string TypeLookupManager::get_instance_name( - const fastrtps::rtps::GuidPrefix_t guid) const + const fastrtps::rtps::GUID_t guid) const { std::stringstream ss; - ss << guid; + ss << std::hex; + for (const auto& elem : guid.guidPrefix.value) + { + ss << std::setw(2) << std::setfill('0') << static_cast(elem); + } + for (const auto& elem : guid.entityId.value) + { + ss << std::setw(2) << std::setfill('0') << static_cast(elem); + } + std::string str = ss.str(); std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c) { - return static_cast(std::tolower(c)); + return std::tolower(c); }); - str.erase(std::remove(str.begin(), str.end(), '.'), str.end()); return "dds.builtin.TOS." + str; } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index c9d0c9ea00b..33833f4f54a 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -155,25 +155,25 @@ class TypeLookupManager * Create and send a request using the builtin TypeLookup Service to retrieve all the type dependencies * associated with a sequence of TypeIdentifiers. * @param id_seq[in] Sequence of TypeIdentifiers for which dependencies are needed. - * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being resolved. + * @param type_server[in] GUID corresponding to the remote participant which TypeInformation is being resolved. * @param continuation_point[in] Continuation point for a previous partially answered request. * @return The SampleIdentity of the sent request. */ SampleIdentity get_type_dependencies( const xtypes::TypeIdentifierSeq& id_seq, - const fastrtps::rtps::GuidPrefix_t& type_server, + const fastrtps::rtps::GUID_t& type_server, const std::vector& continuation_point = std::vector()) const; /** * Create and send a request using the built-in TypeLookup Service to retrieve TypeObjects associated with a * sequence of TypeIdentifiers. * @param id_seq[in] Sequence of TypeIdentifiers for which TypeObjects are to be retrieved. - * @param type_server[in] GuidPrefix corresponding to the remote participant whose TypeInformation is being resolved. + * @param type_server[in] GUID corresponding to the remote participant whose TypeInformation is being resolved. * @return The SampleIdentity of the sent request. */ SampleIdentity get_types( const xtypes::TypeIdentifierSeq& id_seq, - const fastrtps::rtps::GuidPrefix_t& type_server) const; + const fastrtps::rtps::GUID_t& type_server) const; /** * Use builtin TypeLookup service to solve the type and dependencies of a given TypeInformation. @@ -249,12 +249,12 @@ class TypeLookupManager /** * Creates a TypeLookup_Request with for the choosen type_server. - * @param type_server[in] GuidPrefix_t corresponding to the remote participant. + * @param type_server[in] GUID corresponding to the remote participant. * @param pupsubtype[out] PubSubType in charge of TypeLookup_Request . * @return the TypeLookup_Request created. */ TypeLookup_Request* create_request( - const fastrtps::rtps::GuidPrefix_t& type_server, + const fastrtps::rtps::GUID_t& type_server, TypeLookup_RequestPubSubType& pupsubtype) const; /** @@ -343,11 +343,11 @@ class TypeLookupManager /** * Create instance name as defined in section 7.6.3.3.4 XTypes 1.3 specification. - * @param guid[in] GuidPrefix_t to be included in the instance name. + * @param guid[in] GUID to be included in the instance name. * @return The instance name. */ std::string get_instance_name( - const fastrtps::rtps::GuidPrefix_t guid) const; + const fastrtps::rtps::GUID_t guid) const; /** * Create the builtin endpoints used in the TypeLookupManager. diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 9f06acd0082..6a00f4358d2 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -182,7 +182,7 @@ void TypeLookupReplyListener::check_get_types_reply( void TypeLookupReplyListener::check_get_type_dependencies_reply( const SampleIdentity& request_id, - const fastrtps::rtps::GuidPrefix_t type_server, + const fastrtps::rtps::GUID_t type_server, const TypeLookup_getTypeDependencies_Out& reply) { // Check if the received reply SampleIdentity corresponds to an outstanding request @@ -291,7 +291,7 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( } // Add reply to the processing queue - replies_queue_.push(ReplyWithServerGUID{reply, change->writerGUID.guidPrefix}); + replies_queue_.push(ReplyWithServerGUID{reply, change->writerGUID}); { // Notify processor std::unique_lock guard(replies_processor_cv_mutex_); diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 505f4fef9a2..eca9ece8f0d 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -52,7 +52,7 @@ class TypeLookupManager; struct ReplyWithServerGUID { TypeLookup_Reply reply; - fastrtps::rtps::GuidPrefix_t type_server; + fastrtps::rtps::GUID_t type_server; }; /** @@ -110,12 +110,12 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa * If they are, sends get_types request and adds it to the list. * Also removes the current SampleIdentity from the list. * @param request_id[in] The SampleIdentity of the request. - * @param type_server[in] GuidPrefix corresponding to the remote participant which TypeInformation is being solved. + * @param type_server[in] GUID corresponding to the remote participant which TypeInformation is being solved. * @param reply[in] The reply data. */ void check_get_type_dependencies_reply( const SampleIdentity& request_id, - const fastrtps::rtps::GuidPrefix_t type_server, + const fastrtps::rtps::GUID_t type_server, const TypeLookup_getTypeDependencies_Out& reply); /** From f3f812188fd7dac864c40041d6cf5651d864d1a3 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Sun, 18 Feb 2024 11:32:32 +0100 Subject: [PATCH 23/35] Refs #20160: Applied suggestions. Removed overloaded discovery methods. Signed-off-by: adriancampo --- .../dds/domain/DomainParticipantListener.hpp | 34 ---- .../dds/domain/qos/DomainParticipantQos.hpp | 18 +- .../type_representation/TypeObjectUtils.hpp | 21 ++- .../attributes/RTPSParticipantAttributes.h | 6 +- resources/xsd/fastdds_profiles.xsd | 4 +- .../type_lookup_service/TypeLookupManager.cpp | 161 ++++++------------ .../type_lookup_service/TypeLookupManager.hpp | 20 +-- .../TypeLookupReplyListener.cpp | 50 +++--- .../TypeLookupReplyListener.hpp | 39 +---- .../TypeLookupRequestListener.cpp | 56 +++--- .../TypeLookupRequestListener.hpp | 43 +---- .../detail/TypeLookupTypes.hpp | 94 +++++----- .../core/policy/QosPoliciesSerializer.hpp | 2 +- .../fastdds/domain/DomainParticipantImpl.cpp | 12 +- src/cpp/fastdds/utils/QosConverters.cpp | 4 +- .../TypeObjectRegistry.cpp | 47 ++--- .../TypeObjectRegistry.hpp | 8 +- .../type_representation/TypeObjectUtils.cpp | 32 ++-- src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 6 +- src/cpp/rtps/builtin/data/WriterProxyData.cpp | 6 +- src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 2 +- .../discovery/endpoint/EDPSimpleListeners.cpp | 8 +- src/cpp/xmlparser/XMLParser.cpp | 4 +- src/cpp/xmlparser/XMLParserCommon.cpp | 2 +- src/cpp/xmlparser/XMLParserCommon.h | 2 +- test/blackbox/api/dds-pim/PubSubReader.hpp | 3 +- test/blackbox/api/dds-pim/PubSubWriter.hpp | 6 +- .../api/dds-pim/PubSubWriterReader.hpp | 6 +- .../attributes/RTPSParticipantAttributes.h | 6 +- .../dds/participant/ParticipantTests.cpp | 4 +- .../profiles/test_xml_for_string_profile.xml | 8 +- .../dds/profiles/test_xml_profile.xml | 8 +- .../dds/publisher/DataWriterTests.cpp | 3 +- .../dds/subscriber/DataReaderTests.cpp | 3 +- .../xmlparser/test_xml_deprecated.xml | 4 +- test/unittest/xmlparser/test_xml_profile.xml | 4 +- .../xmlparser/test_xml_profile_env_var.xml | 4 +- .../xmlparser/test_xml_rooted_deprecated.xml | 4 +- .../xmlparser/test_xml_rooted_profile.xml | 4 +- 39 files changed, 316 insertions(+), 432 deletions(-) diff --git a/include/fastdds/dds/domain/DomainParticipantListener.hpp b/include/fastdds/dds/domain/DomainParticipantListener.hpp index 3e90763ddb9..9455729d6e5 100644 --- a/include/fastdds/dds/domain/DomainParticipantListener.hpp +++ b/include/fastdds/dds/domain/DomainParticipantListener.hpp @@ -100,23 +100,6 @@ class DomainParticipantListener : * * @param[out] participant Pointer to the Participant which discovered the remote DataReader. * @param[out] info Remote DataReader information. User can take ownership of the object. - */ - virtual void on_data_reader_discovery( - DomainParticipant* participant, - fastrtps::rtps::ReaderDiscoveryInfo&& info) - { - static_cast(participant); - static_cast(info); - } - - /*! - * This method is called when a new DataReader is discovered, or a previously discovered DataReader changes - * its QOS or is removed. - * - * @warning Not Supported. This callback will never be called in the current version. - * - * @param[out] participant Pointer to the Participant which discovered the remote DataReader. - * @param[out] info Remote DataReader information. User can take ownership of the object. * @param[out] should_be_ignored Flag to indicate the library to automatically ignore the discovered DataReader. */ virtual void on_data_reader_discovery( @@ -135,23 +118,6 @@ class DomainParticipantListener : * * @param[out] participant Pointer to the Participant which discovered the remote DataWriter. * @param[out] info Remote DataWriter information. User can take ownership of the object. - */ - virtual void on_data_writer_discovery( - DomainParticipant* participant, - fastrtps::rtps::WriterDiscoveryInfo&& info) - { - static_cast(participant); - static_cast(info); - } - - /*! - * This method is called when a new DataWriter is discovered, or a previously discovered DataWriter changes - * its QOS or is removed. - * - * @warning Not Supported. This callback will never be called in the current version. - * - * @param[out] participant Pointer to the Participant which discovered the remote DataWriter. - * @param[out] info Remote DataWriter information. User can take ownership of the object. * @param[out] should_be_ignored Flag to indicate the library to automatically ignore the discovered DataWriter. */ virtual void on_data_writer_discovery( diff --git a/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp b/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp index 3481e27f27b..9fdb758501a 100644 --- a/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp +++ b/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp @@ -86,7 +86,7 @@ class DomainParticipantQos (this->builtin_controllers_sender_thread_ == b.builtin_controllers_sender_thread()) && (this->timed_events_thread_ == b.timed_events_thread()) && (this->discovery_server_thread_ == b.discovery_server_thread()) && - (this->typelookup_service_threads_ == b.typelookup_service_threads()) && + (this->typelookup_service_thread_ == b.typelookup_service_thread()) && #if HAVE_SECURITY (this->security_log_thread_ == b.security_log_thread()) && #endif // if HAVE_SECURITY @@ -439,9 +439,9 @@ class DomainParticipantQos * * @return rtps::ThreadSettings reference */ - rtps::ThreadSettings& typelookup_service_threads() + rtps::ThreadSettings& typelookup_service_thread() { - return typelookup_service_threads_; + return typelookup_service_thread_; } /** @@ -449,9 +449,9 @@ class DomainParticipantQos * * @return rtps::ThreadSettings reference */ - const rtps::ThreadSettings& typelookup_service_threads() const + const rtps::ThreadSettings& typelookup_service_thread() const { - return typelookup_service_threads_; + return typelookup_service_thread_; } /** @@ -459,10 +459,10 @@ class DomainParticipantQos * * @param value New ThreadSettings to be set */ - void typelookup_service_threads( + void typelookup_service_thread( const rtps::ThreadSettings& value) { - typelookup_service_threads_ = value; + typelookup_service_thread_ = value; } #if HAVE_SECURITY @@ -537,8 +537,8 @@ class DomainParticipantQos //! Thread settings for the discovery server thread rtps::ThreadSettings discovery_server_thread_; - //! Thread settings for the discovery server thread - rtps::ThreadSettings typelookup_service_threads_; + //! Thread settings for the builtin TypeLookup service requests and replies threads + rtps::ThreadSettings typelookup_service_thread_; #if HAVE_SECURITY //! Thread settings for the security log thread diff --git a/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp b/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp index ebc37899b0d..84e4c7c8d81 100644 --- a/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp +++ b/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp @@ -1867,6 +1867,16 @@ class TypeObjectUtils FASTDDS_EXPORTED_API static const NameHash name_hash( const std::string& name); + /** + * @brief Check TypeObject consistency. + * + * @param[in] type_object Instance to be checked. + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given + * TypeObject is not consistent. + */ + static void type_object_consistency( + const TypeObject& type_object); + private: friend class TypeObjectRegistry; @@ -3036,17 +3046,6 @@ class TypeObjectUtils */ static void minimal_type_object_consistency( const MinimalTypeObject& minimal_type_object); - - /** - * @brief Check TypeObject consistency. - * - * @param[in] type_object Instance to be checked. - * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given - * TypeObject is not consistent. - */ - static void type_object_consistency( - const TypeObject& type_object); - }; } // xtypes diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h index edf2aa9601c..307f8f6d4d0 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -443,7 +443,7 @@ class RTPSParticipantAttributes (this->security_log_thread == b.security_log_thread) && #endif // if HAVE_SECURITY (this->discovery_server_thread == b.discovery_server_thread) && - (this->typelookup_service_threads == b.typelookup_service_threads) && + (this->typelookup_service_thread == b.typelookup_service_thread) && (this->builtin_transports_reception_threads == b.builtin_transports_reception_threads); } @@ -560,8 +560,8 @@ class RTPSParticipantAttributes //! Thread settings for the discovery server thread fastdds::rtps::ThreadSettings discovery_server_thread; - //! Thread settings for the discovery server thread - fastdds::rtps::ThreadSettings typelookup_service_threads; + //! 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; diff --git a/resources/xsd/fastdds_profiles.xsd b/resources/xsd/fastdds_profiles.xsd index cf862e7000a..84b8a6fa5f2 100644 --- a/resources/xsd/fastdds_profiles.xsd +++ b/resources/xsd/fastdds_profiles.xsd @@ -142,7 +142,7 @@ ├ builtin_controllers_sender_thread [threadSettingsType], ├ timed_events_thread [threadSettingsType], ├ discovery_server_thread [threadSettingsType], - ├ typelookup_service_threads [threadSettingsType], + ├ typelookup_service_thread [threadSettingsType], ├ builtin_transports_reception_threads [threadSettingsType], └ security_log_thread [threadSettingsType]--> @@ -187,7 +187,7 @@ - + diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 26ebf26bcd9..8427d0a1f5f 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -97,9 +97,7 @@ TypeLookupManager::~TypeLookupManager() delete builtin_reply_reader_history_; delete reply_listener_; - delete reply_wlistener_; delete request_listener_; - delete request_wlistener_; delete temp_reader_proxy_data_; delete temp_writer_proxy_data_; @@ -383,7 +381,7 @@ ReturnCode_t TypeLookupManager::check_type_identifier_received( void TypeLookupManager::notify_callbacks( xtypes::TypeIdentfierWithSize type_identifier_with_size) { - // Check that type is not solved + // Check that type is pending to be resolved auto writer_callbacks_it = async_get_type_writer_callbacks_.find(type_identifier_with_size); if (writer_callbacks_it != async_get_type_writer_callbacks_.end()) { @@ -484,8 +482,6 @@ bool TypeLookupManager::remove_async_get_type_request( bool TypeLookupManager::create_endpoints() { - bool ret = true; - const RTPSParticipantAttributes& pattr = participant_->getRTPSParticipantAttributes(); // Built-in history attributes. @@ -506,11 +502,22 @@ bool TypeLookupManager::create_endpoints() watt.endpoint.durabilityKind = fastrtps::rtps::VOLATILE; watt.mode = fastrtps::rtps::ASYNCHRONOUS_WRITER; - // Built-in request writer + ReaderAttributes ratt; + ratt.endpoint.unicastLocatorList = builtin_protocols_->m_metatrafficUnicastLocatorList; + ratt.endpoint.multicastLocatorList = builtin_protocols_->m_metatrafficMulticastLocatorList; + ratt.endpoint.external_unicast_locators = builtin_protocols_->m_att.metatraffic_external_unicast_locators; + ratt.endpoint.ignore_non_matching_locators = pattr.ignore_non_matching_locators; + ratt.endpoint.remoteLocatorList = builtin_protocols_->m_initialPeersList; + ratt.matched_writers_allocation = pattr.allocation.participants; + ratt.expectsInlineQos = true; + ratt.endpoint.topicKind = fastrtps::rtps::NO_KEY; + ratt.endpoint.reliabilityKind = fastrtps::rtps::RELIABLE; + ratt.endpoint.durabilityKind = fastrtps::rtps::VOLATILE; + request_listener_ = new TypeLookupRequestListener(this); - builtin_request_writer_history_ = new WriterHistory(hatt); - request_wlistener_ = new TypeLookupRequestWListener(this); + // Built-in request writer + builtin_request_writer_history_ = new WriterHistory(hatt); RTPSWriter* req_writer; if (participant_->createWriter( &req_writer, @@ -528,53 +535,13 @@ bool TypeLookupManager::create_endpoints() EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup request writer creation failed."); delete builtin_request_writer_history_; builtin_request_writer_history_ = nullptr; - delete request_wlistener_; - request_wlistener_ = nullptr; - return false; - } - - // Built-in reply writer - reply_listener_ = new TypeLookupReplyListener(this); - builtin_reply_writer_history_ = new WriterHistory(hatt); - reply_wlistener_ = new TypeLookupReplyWListener(this); - - RTPSWriter* rep_writer; - if (participant_->createWriter( - &rep_writer, - watt, - builtin_reply_writer_history_, - reply_listener_, - fastrtps::rtps::c_EntityId_TypeLookup_reply_writer, - true)) - { - builtin_reply_writer_ = dynamic_cast(rep_writer); - EPROSIMA_LOG_INFO(TYPELOOKUP_SERVICE, "Builtin Typelookup reply writer created."); - } - else - { - EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup reply writer creation failed."); - delete builtin_reply_writer_history_; - builtin_reply_writer_history_ = nullptr; - delete reply_wlistener_; - reply_wlistener_ = nullptr; + delete request_listener_; + request_listener_ = nullptr; return false; } - ReaderAttributes ratt; - ratt.endpoint.unicastLocatorList = builtin_protocols_->m_metatrafficUnicastLocatorList; - ratt.endpoint.multicastLocatorList = builtin_protocols_->m_metatrafficMulticastLocatorList; - ratt.endpoint.external_unicast_locators = builtin_protocols_->m_att.metatraffic_external_unicast_locators; - ratt.endpoint.ignore_non_matching_locators = pattr.ignore_non_matching_locators; - ratt.endpoint.remoteLocatorList = builtin_protocols_->m_initialPeersList; - ratt.matched_writers_allocation = pattr.allocation.participants; - ratt.expectsInlineQos = true; - ratt.endpoint.topicKind = fastrtps::rtps::NO_KEY; - ratt.endpoint.reliabilityKind = fastrtps::rtps::RELIABLE; - ratt.endpoint.durabilityKind = fastrtps::rtps::VOLATILE; - // Built-in request reader builtin_request_reader_history_ = new ReaderHistory(hatt); - RTPSReader* req_reader; if (participant_->createReader( &req_reader, @@ -597,9 +564,34 @@ bool TypeLookupManager::create_endpoints() return false; } + reply_listener_ = new TypeLookupReplyListener(this); + + // Built-in reply writer + builtin_reply_writer_history_ = new WriterHistory(hatt); + RTPSWriter* rep_writer; + if (participant_->createWriter( + &rep_writer, + watt, + builtin_reply_writer_history_, + reply_listener_, + fastrtps::rtps::c_EntityId_TypeLookup_reply_writer, + true)) + { + builtin_reply_writer_ = dynamic_cast(rep_writer); + EPROSIMA_LOG_INFO(TYPELOOKUP_SERVICE, "Builtin Typelookup reply writer created."); + } + else + { + EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup reply writer creation failed."); + delete builtin_reply_writer_history_; + builtin_reply_writer_history_ = nullptr; + delete reply_listener_; + reply_listener_ = nullptr; + return false; + } + // Built-in reply reader builtin_reply_reader_history_ = new ReaderHistory(hatt); - RTPSReader* rep_reader; if (participant_->createReader( &rep_reader, @@ -622,46 +614,7 @@ bool TypeLookupManager::create_endpoints() return false; } - // Clean up if something failed. - if (!ret) - { - if (nullptr != builtin_request_writer_history_) - { - delete builtin_request_writer_history_; - builtin_request_writer_history_ = nullptr; - } - - if (nullptr != builtin_reply_writer_history_) - { - delete builtin_reply_writer_history_; - builtin_reply_writer_history_ = nullptr; - } - - if (nullptr != builtin_request_reader_history_) - { - delete builtin_request_reader_history_; - builtin_request_reader_history_ = nullptr; - } - - if (nullptr != builtin_reply_reader_history_) - { - delete builtin_reply_reader_history_; - builtin_reply_reader_history_ = nullptr; - } - - if (nullptr != request_listener_) - { - delete request_listener_; - request_listener_ = nullptr; - } - if (nullptr != reply_listener_) - { - delete reply_listener_; - reply_listener_ = nullptr; - } - } - - return ret; + return true; } TypeLookup_Request* TypeLookupManager::create_request( @@ -754,27 +707,10 @@ bool TypeLookupManager::prepare_receive_payload( { CDRMessage_t msg(change.serializedPayload); msg.pos += 1; - octet encapsulation = 0; - CDRMessage::readOctet(&msg, &encapsulation); - if (encapsulation == PL_CDR_BE) - { - msg.msg_endian = BIGEND; - } - else if (encapsulation == PL_CDR_LE) - { - msg.msg_endian = LITTLEEND; - } - else - { - return false; - } - change.serializedPayload.encapsulation = static_cast(encapsulation); - msg.pos += 2; // Skip encapsulation options. - //SerializedPayload_t payload; - payload.max_size = change.serializedPayload.max_size - 4; - payload.length = change.serializedPayload.length - 4; - payload.data = change.serializedPayload.data + 4; + payload.max_size = change.serializedPayload.max_size; + payload.length = change.serializedPayload.length; + payload.data = change.serializedPayload.data; return true; } @@ -788,7 +724,8 @@ bool TypeLookupManager::receive( return false; } - if (request.header().instanceName() != local_instance_name_) + //Compare only the guid.guidPrefix + if ((request.header().instanceName().to_string()).substr(0, 24) != local_instance_name_.substr(0, 24)) { // Ignore request return false; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index 33833f4f54a..c4217bdd808 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -248,7 +248,7 @@ class TypeLookupManager SampleIdentity request); /** - * Creates a TypeLookup_Request with for the choosen type_server. + * Creates a TypeLookup_Request with for the given type_server. * @param type_server[in] GUID corresponding to the remote participant. * @param pupsubtype[out] PubSubType in charge of TypeLookup_Request . * @return the TypeLookup_Request created. @@ -289,7 +289,7 @@ class TypeLookupManager fastrtps::rtps::WriterHistory* writer_history) const; /** - * Prepares the the received payload of a CacheChange before deserializing. + * Prepares the received payload of a CacheChange before deserializing. * @param change[in] CacheChange_t received. * @param payload[out] SerializedPayload_t prepared. * @return true if received payload is prepared, false otherwise. @@ -299,7 +299,7 @@ class TypeLookupManager fastrtps::rtps::SerializedPayload_t& payload) const; /** - * Uses the send_impl with the appropriate parameters and checks if it is directed to the local DomainParticipant. + * Uses the receive_impl with the appropriate parameters and checks if it is directed to the local DomainParticipant. * @param change[in] CacheChange_t of the request. * @param request[out] TypeLookup_Request after deserialization. * @return true if the request is deserialized and directed to the local participant, false otherwise. @@ -309,9 +309,9 @@ class TypeLookupManager TypeLookup_Request& request) const; /** - * Uses the send_impl with the appropriate parameters and checks if that the reply's recipient is the local participant. + * Uses the receive_impl with the appropriate parameters and checks if the reply's recipient is the local participant. * @param change[in] CacheChange_t of the reply. - * @param reply[out] TypeLookup_Reply after deserialize. + * @param reply[out] TypeLookup_Reply after deserialization. * @return true if the request is deserialized and the reply's recipient is us, false otherwise. */ bool receive( @@ -404,11 +404,9 @@ class TypeLookupManager //! Request Listener object. TypeLookupRequestListener* request_listener_ = nullptr; - TypeLookupRequestWListener* request_wlistener_ = nullptr; //! Reply Listener object. TypeLookupReplyListener* reply_listener_ = nullptr; - TypeLookupReplyWListener* reply_wlistener_ = nullptr; //! Mutex to protect access to temp_reader_proxy_data_ and temp_writer_proxy_data_. std::mutex temp_data_lock_; @@ -436,14 +434,8 @@ class TypeLookupManager std::vector::smart_ptr, AsyncGetTypeReaderCallback>>> async_get_type_reader_callbacks_; - //! Collection SampleIdentity and the TypeIdentfierWithSize it originated from, hashed by its SampleIdentity. + //! Collection of all SampleIdentity and the TypeIdentfierWithSize it originated from, hashed by its SampleIdentity. std::unordered_map async_get_type_requests_; - - void request_cache_change_acked( - fastrtps::rtps::CacheChange_t* change); - - void reply_cache_change_acked( - fastrtps::rtps::CacheChange_t* change); }; } /* namespace builtin */ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 6a00f4358d2..208af1e4868 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -19,10 +19,9 @@ #include -#include #include -#include +#include #include #include @@ -62,7 +61,7 @@ void TypeLookupReplyListener::start_reply_processor_thread() }; // Create and start the processing thread replies_processor_thread = eprosima::create_thread(thread_func, - typelookup_manager_->participant_->getAttributes().typelookup_service_threads, + typelookup_manager_->participant_->getAttributes().typelookup_service_thread, "dds.tls.replies.%u"); } } @@ -122,7 +121,8 @@ void TypeLookupReplyListener::process_reply() } default: // If the type of request is not known, log an error - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REPLY_LISTENER, "Received uknown reply type."); + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REPLY_LISTENER, + "Received unknown reply operation type in type lookup service."); break; } } @@ -141,39 +141,49 @@ void TypeLookupReplyListener::check_get_types_reply( auto requests_it = typelookup_manager_->async_get_type_requests_.find(request_id); if (requests_it != typelookup_manager_->async_get_type_requests_.end()) { - ReturnCode_t register_result = RETCODE_ERROR; + ReturnCode_t register_result = RETCODE_OK; for (xtypes::TypeIdentifierTypeObjectPair pair : reply.types()) { - register_result = fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). - register_type_object(pair.type_identifier(), pair.type_object()); - if (RETCODE_OK != register_result) + if (RETCODE_OK != fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer(). + register_type_object(pair.type_identifier(), pair.type_object())) { - // If registration fails for any type, break out of the loop - break; + // If any of the types is not registered, log error + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REPLY_LISTENER, + "Error registering type: the discriminators differ"); + register_result = RETCODE_ERROR; } } if (RETCODE_OK == register_result) { - // Check if this reply has a continuation_point + // Check if this reply requires a continuation_point std::unique_lock guard(replies_with_continuation_mutex_); auto it = std::find(replies_with_continuation_.begin(), replies_with_continuation_.end(), related_request); if (it != replies_with_continuation_.end()) { - // If it is, remove it from the list and continue + // If it does, remove it from the list and continue replies_with_continuation_.erase(it); } else { - // If it is not, notify the callbacks associated with the request - typelookup_manager_->notify_callbacks(requests_it->second); + // If it does not, check that the type that originated the request is consistent + // before notifying the callbacks associated with the request + try + { + xtypes::TypeObject type_object; + fastrtps::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_object( + requests_it->second.type_id(), type_object); + xtypes::TypeObjectUtils::type_object_consistency(type_object); + + typelookup_manager_->notify_callbacks(requests_it->second); + } + catch (const std::exception& exception) + { + EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE_REPLY_LISTENER, + "Error registering type: " << exception.what()); + } } } - else - { - // If any of the types is not registered, log error - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REPLY_LISTENER, "Error registering type."); - } // Remove the processed SampleIdentity from the outstanding requests typelookup_manager_->remove_async_get_type_request(request_id); @@ -303,7 +313,7 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( reader->getHistory()->remove_change(change); } -void TypeLookupReplyWListener::onWriterChangeReceivedByAll( +void TypeLookupReplyListener::onWriterChangeReceivedByAll( fastrtps::rtps::RTPSWriter*, fastrtps::rtps::CacheChange_t* change) { diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index eca9ece8f0d..aa2df3fbaf1 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -20,16 +20,17 @@ #ifndef _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REPLY_LISTENER_HPP_ #define _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REPLY_LISTENER_HPP_ +#include #include #include #include #include -#include #include #include #include +#include #include #include @@ -127,6 +128,9 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; + void onWriterChangeReceivedByAll( + fastrtps::rtps::RTPSWriter*, + fastrtps::rtps::CacheChange_t* change) override; //! A pointer to the typelookup manager. TypeLookupManager* typelookup_manager_; @@ -141,41 +145,10 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa std::queue replies_queue_; std::mutex replies_processor_cv_mutex_; std::condition_variable replies_processor_cv_; - bool processing_; + bool processing_ = false; rtps::ThreadSettings replies_processor_thread_settings_; }; -class TypeLookupReplyWListener : public fastrtps::rtps::WriterListener -{ -public: - - /** - * @brief Constructor - * @param manager Pointer to the TypeLookupManager - */ - TypeLookupReplyWListener( - TypeLookupManager* manager) - : typelookup_manager_(manager) - { - } - - /** - * @brief Destructor - */ - virtual ~TypeLookupReplyWListener() override - { - } - - void onWriterChangeReceivedByAll( - fastrtps::rtps::RTPSWriter*, - fastrtps::rtps::CacheChange_t* change) override; - -private: - - //! A pointer to the typelookup manager - TypeLookupManager* typelookup_manager_; -}; - } /* namespace builtin */ } /* namespace dds */ } /* namespace fastdds */ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index d0d75975274..a923bb7a64d 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -38,7 +38,7 @@ namespace builtin { //! Constant that specifies the maximum number of dependent types to be included per reply. //! This number is calculated considering the MTU. -const int MAX_DEPENDENCIES_PER_REPLY = 75; +const int32_t MAX_DEPENDENCIES_PER_REPLY = 75; /** * @brief Calculates the opaque value of continuation point. @@ -111,7 +111,7 @@ void TypeLookupRequestListener::start_request_processor_thread() }; // Create and start the processing thread request_processor_thread = eprosima::create_thread(thread_func, - typelookup_manager_->participant_->getAttributes().typelookup_service_threads, + typelookup_manager_->participant_->getAttributes().typelookup_service_thread, "dds.tls.requests.%u"); } } @@ -169,10 +169,10 @@ void TypeLookupRequestListener::process_requests() } default: // If the type of request is not known, log an error and answer with an exception - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "Received unknown request type."); - answer_request( - request.header().requestId(), - rpc::RemoteExceptionCode_t::REMOTE_EX_UNSUPPORTED); + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, + "Received unknown request in type lookup service."); + answer_request(request.header().requestId(), + rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_OPERATION); break; } } @@ -230,15 +230,22 @@ void TypeLookupRequestListener::check_get_types_request( out.types().push_back(std::move(id_obj_pair)); } + // Handle the result based on the type_result if (RETCODE_OK == type_result) { - // Prepare and send the reply + // Prepare and send the reply for successful operation answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_OK, out); } - else + else if (RETCODE_NO_DATA == type_result) + { + // Log error for type not found and reply with appropriate exception + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "TypeIdentifier is not found in the registry."); + answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION); + } + else if (RETCODE_PRECONDITION_NOT_MET == type_result) { - // If any of the types is not found, log error - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "Error getting type."); + // Log error for invalid argument and reply with appropriate exception + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "TypeIdentifier is not a direct hash."); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT); } } @@ -262,6 +269,13 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( type_dependencies = requests_it->second; type_dependencies_result = RETCODE_OK; } + else + { + // If the the received request is not found, log error and answer with exception + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, + "Error processing ongoing type dependencies."); + answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION); + } } else { @@ -278,17 +292,24 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( } } + // Handle the result based on the type_dependencies_result if (RETCODE_OK == type_dependencies_result) { - // Prepare and send the reply + // Prepare and send the reply for successful operation TypeLookup_getTypeDependencies_Out out = prepare_get_type_dependencies_response( request.type_ids(), type_dependencies, request.continuation_point()); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_OK, out); } - else + else if (RETCODE_NO_DATA == type_dependencies_result) { - // If the type dependencies are not found, log error - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "Error getting type dependencies."); + // Log error for type not found and reply with appropriate exception + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "TypeIdentifier is not found in the registry."); + answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION); + } + else if (RETCODE_BAD_PARAMETER == type_dependencies_result) + { + // Log error for invalid argument and reply with appropriate exception + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "TypeIdentifier is not a direct hash."); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT); } } @@ -352,11 +373,9 @@ void TypeLookupRequestListener::answer_request( TypeLookup_getTypeDependencies_Out& out) { TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); - TypeLookup_getTypeDependencies_Result result; result.result(out); reply->return_value().getTypeDependencies(result); - reply->header().relatedRequestId(request_id); reply->header().remoteEx(exception_code); @@ -370,11 +389,9 @@ void TypeLookupRequestListener::answer_request( TypeLookup_getTypes_Out& out) { TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); - TypeLookup_getTypes_Result result; result.result(out); reply->return_value().getType(result); - reply->header().relatedRequestId(request_id); reply->header().remoteEx(exception_code); @@ -387,7 +404,6 @@ void TypeLookupRequestListener::answer_request( rpc::RemoteExceptionCode_t exception_code) { TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); - reply->header().relatedRequestId(request_id); reply->header().remoteEx(exception_code); @@ -427,7 +443,7 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( reader->getHistory()->remove_change(change); } -void TypeLookupRequestWListener::onWriterChangeReceivedByAll( +void TypeLookupRequestListener::onWriterChangeReceivedByAll( fastrtps::rtps::RTPSWriter*, fastrtps::rtps::CacheChange_t* change) { diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index cdb660351b6..4ee685e60e9 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -20,11 +20,11 @@ #ifndef _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REQUEST_LISTENER_HPP_ #define _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_REQUEST_LISTENER_HPP_ +#include #include #include #include #include -#include #include #include @@ -140,10 +140,10 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public const std::vector& continuation_point); /** - * @brief Creates a sends TypeLookup_Reply. + * @brief Creates and sends the TypeLookup_Reply. * @param request_id[in] The SampleIdentity of the request. * @param exception_code[in] The RemoteExceptionCode_t used in the header. - * @param out[in] The result of the request being answered. + * @param out[in] Reply to the query included in the received request. */ void answer_request( SampleIdentity request_id, @@ -166,6 +166,10 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; + void onWriterChangeReceivedByAll( + fastrtps::rtps::RTPSWriter*, + fastrtps::rtps::CacheChange_t* change) override; + //! A pointer to the typelookup manager. TypeLookupManager* typelookup_manager_; @@ -180,41 +184,10 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public std::queue requests_queue_; std::mutex request_processor_cv_mutex_; std::condition_variable request_processor_cv_; - bool processing_; + bool processing_ = false; rtps::ThreadSettings request_processor_thread_settings_; }; -class TypeLookupRequestWListener : public fastrtps::rtps::WriterListener -{ -public: - - /** - * @brief Constructor - * @param pwlp Pointer to the TypeLookupManager - */ - TypeLookupRequestWListener( - TypeLookupManager* manager) - : typelookup_manager_(manager) - { - } - - /** - * @brief Destructor - */ - virtual ~TypeLookupRequestWListener() override - { - } - - void onWriterChangeReceivedByAll( - fastrtps::rtps::RTPSWriter*, - fastrtps::rtps::CacheChange_t* change) override; - -private: - - //! A pointer to the typelookup manager - TypeLookupManager* typelookup_manager_; -}; - } /* namespace builtin */ } /* namespace dds */ } /* namespace fastdds */ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp b/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp index 3df22d734ed..8d0ed3172fb 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp @@ -97,7 +97,7 @@ class TypeLookup_getTypes_In eProsima_user_DllExport TypeLookup_getTypes_In( const TypeLookup_getTypes_In& x) { - m_type_ids = x.m_type_ids; + m_type_ids = x.m_type_ids; } @@ -119,7 +119,7 @@ class TypeLookup_getTypes_In const TypeLookup_getTypes_In& x) { - m_type_ids = x.m_type_ids; + m_type_ids = x.m_type_ids; return *this; } @@ -194,6 +194,8 @@ class TypeLookup_getTypes_In return m_type_ids; } + + private: std::vector m_type_ids; @@ -228,9 +230,9 @@ class TypeLookup_getTypes_Out eProsima_user_DllExport TypeLookup_getTypes_Out( const TypeLookup_getTypes_Out& x) { - m_types = x.m_types; + m_types = x.m_types; - m_complete_to_minimal = x.m_complete_to_minimal; + m_complete_to_minimal = x.m_complete_to_minimal; } @@ -253,9 +255,9 @@ class TypeLookup_getTypes_Out const TypeLookup_getTypes_Out& x) { - m_types = x.m_types; + m_types = x.m_types; - m_complete_to_minimal = x.m_complete_to_minimal; + m_complete_to_minimal = x.m_complete_to_minimal; return *this; } @@ -281,7 +283,7 @@ class TypeLookup_getTypes_Out const TypeLookup_getTypes_Out& x) const { return (m_types == x.m_types && - m_complete_to_minimal == x.m_complete_to_minimal); + m_complete_to_minimal == x.m_complete_to_minimal); } /*! @@ -318,8 +320,7 @@ class TypeLookup_getTypes_Out * @brief This function returns a constant reference to member types * @return Constant reference to member types */ - eProsima_user_DllExport const std::vector& types() - const + eProsima_user_DllExport const std::vector& types() const { return m_types; } @@ -333,6 +334,7 @@ class TypeLookup_getTypes_Out return m_types; } + /*! * @brief This function copies the value in member complete_to_minimal * @param _complete_to_minimal New value to be copied in member complete_to_minimal @@ -357,8 +359,7 @@ class TypeLookup_getTypes_Out * @brief This function returns a constant reference to member complete_to_minimal * @return Constant reference to member complete_to_minimal */ - eProsima_user_DllExport const std::vector& complete_to_minimal() - const + eProsima_user_DllExport const std::vector& complete_to_minimal() const { return m_complete_to_minimal; } @@ -372,6 +373,8 @@ class TypeLookup_getTypes_Out return m_complete_to_minimal; } + + private: std::vector m_types; @@ -537,8 +540,7 @@ class TypeLookup_getTypes_Result if (!valid_discriminator) { - throw eprosima::fastcdr::exception::BadParamException( - "Discriminator doesn't correspond with the selected union member"); + throw eprosima::fastcdr::exception::BadParamException("Discriminator doesn't correspond with the selected union member"); } m__d = __d; @@ -678,9 +680,9 @@ class TypeLookup_getTypeDependencies_In eProsima_user_DllExport TypeLookup_getTypeDependencies_In( const TypeLookup_getTypeDependencies_In& x) { - m_type_ids = x.m_type_ids; + m_type_ids = x.m_type_ids; - m_continuation_point = x.m_continuation_point; + m_continuation_point = x.m_continuation_point; } @@ -703,9 +705,9 @@ class TypeLookup_getTypeDependencies_In const TypeLookup_getTypeDependencies_In& x) { - m_type_ids = x.m_type_ids; + m_type_ids = x.m_type_ids; - m_continuation_point = x.m_continuation_point; + m_continuation_point = x.m_continuation_point; return *this; } @@ -731,7 +733,7 @@ class TypeLookup_getTypeDependencies_In const TypeLookup_getTypeDependencies_In& x) const { return (m_type_ids == x.m_type_ids && - m_continuation_point == x.m_continuation_point); + m_continuation_point == x.m_continuation_point); } /*! @@ -782,6 +784,7 @@ class TypeLookup_getTypeDependencies_In return m_type_ids; } + /*! * @brief This function copies the value in member continuation_point * @param _continuation_point New value to be copied in member continuation_point @@ -820,6 +823,8 @@ class TypeLookup_getTypeDependencies_In return m_continuation_point; } + + private: std::vector m_type_ids; @@ -855,9 +860,9 @@ class TypeLookup_getTypeDependencies_Out eProsima_user_DllExport TypeLookup_getTypeDependencies_Out( const TypeLookup_getTypeDependencies_Out& x) { - m_dependent_typeids = x.m_dependent_typeids; + m_dependent_typeids = x.m_dependent_typeids; - m_continuation_point = x.m_continuation_point; + m_continuation_point = x.m_continuation_point; } @@ -880,9 +885,9 @@ class TypeLookup_getTypeDependencies_Out const TypeLookup_getTypeDependencies_Out& x) { - m_dependent_typeids = x.m_dependent_typeids; + m_dependent_typeids = x.m_dependent_typeids; - m_continuation_point = x.m_continuation_point; + m_continuation_point = x.m_continuation_point; return *this; } @@ -908,7 +913,7 @@ class TypeLookup_getTypeDependencies_Out const TypeLookup_getTypeDependencies_Out& x) const { return (m_dependent_typeids == x.m_dependent_typeids && - m_continuation_point == x.m_continuation_point); + m_continuation_point == x.m_continuation_point); } /*! @@ -945,8 +950,7 @@ class TypeLookup_getTypeDependencies_Out * @brief This function returns a constant reference to member dependent_typeids * @return Constant reference to member dependent_typeids */ - eProsima_user_DllExport const std::vector& dependent_typeids() - const + eProsima_user_DllExport const std::vector& dependent_typeids() const { return m_dependent_typeids; } @@ -960,6 +964,7 @@ class TypeLookup_getTypeDependencies_Out return m_dependent_typeids; } + /*! * @brief This function copies the value in member continuation_point * @param _continuation_point New value to be copied in member continuation_point @@ -998,6 +1003,8 @@ class TypeLookup_getTypeDependencies_Out return m_continuation_point; } + + private: std::vector m_dependent_typeids; @@ -1163,8 +1170,7 @@ class TypeLookup_getTypeDependencies_Result if (!valid_discriminator) { - throw eprosima::fastcdr::exception::BadParamException( - "Discriminator doesn't correspond with the selected union member"); + throw eprosima::fastcdr::exception::BadParamException("Discriminator doesn't correspond with the selected union member"); } m__d = __d; @@ -1461,8 +1467,7 @@ class TypeLookup_Call if (!valid_discriminator) { - throw eprosima::fastcdr::exception::BadParamException( - "Discriminator doesn't correspond with the selected union member"); + throw eprosima::fastcdr::exception::BadParamException("Discriminator doesn't correspond with the selected union member"); } m__d = __d; @@ -1529,6 +1534,7 @@ class TypeLookup_Call return m_getTypes; } + /*! * @brief This function copies the value in member getTypeDependencies * @param _getTypeDependencies New value to be copied in member getTypeDependencies @@ -1673,9 +1679,9 @@ class TypeLookup_Request eProsima_user_DllExport TypeLookup_Request( const TypeLookup_Request& x) { - m_header = x.m_header; + m_header = x.m_header; - m_data = x.m_data; + m_data = x.m_data; } @@ -1698,9 +1704,9 @@ class TypeLookup_Request const TypeLookup_Request& x) { - m_header = x.m_header; + m_header = x.m_header; - m_data = x.m_data; + m_data = x.m_data; return *this; } @@ -1726,7 +1732,7 @@ class TypeLookup_Request const TypeLookup_Request& x) const { return (m_header == x.m_header && - m_data == x.m_data); + m_data == x.m_data); } /*! @@ -1777,6 +1783,7 @@ class TypeLookup_Request return m_header; } + /*! * @brief This function copies the value in member data * @param _data New value to be copied in member data @@ -1815,6 +1822,8 @@ class TypeLookup_Request return m_data; } + + private: eprosima::fastdds::dds::rpc::RequestHeader m_header; @@ -2007,8 +2016,7 @@ class TypeLookup_Return if (!valid_discriminator) { - throw eprosima::fastcdr::exception::BadParamException( - "Discriminator doesn't correspond with the selected union member"); + throw eprosima::fastcdr::exception::BadParamException("Discriminator doesn't correspond with the selected union member"); } m__d = __d; @@ -2075,6 +2083,7 @@ class TypeLookup_Return return m_getType; } + /*! * @brief This function copies the value in member getTypeDependencies * @param _getTypeDependencies New value to be copied in member getTypeDependencies @@ -2219,9 +2228,9 @@ class TypeLookup_Reply eProsima_user_DllExport TypeLookup_Reply( const TypeLookup_Reply& x) { - m_header = x.m_header; + m_header = x.m_header; - m_return_value = x.m_return_value; + m_return_value = x.m_return_value; } @@ -2244,9 +2253,9 @@ class TypeLookup_Reply const TypeLookup_Reply& x) { - m_header = x.m_header; + m_header = x.m_header; - m_return_value = x.m_return_value; + m_return_value = x.m_return_value; return *this; } @@ -2272,7 +2281,7 @@ class TypeLookup_Reply const TypeLookup_Reply& x) const { return (m_header == x.m_header && - m_return_value == x.m_return_value); + m_return_value == x.m_return_value); } /*! @@ -2323,6 +2332,7 @@ class TypeLookup_Reply return m_header; } + /*! * @brief This function copies the value in member return_value * @param _return_value New value to be copied in member return_value @@ -2361,6 +2371,8 @@ class TypeLookup_Reply return m_return_value; } + + private: eprosima::fastdds::dds::rpc::ReplyHeader m_header; diff --git a/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp b/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp index a7f7e478e72..08bd98f598a 100644 --- a/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp +++ b/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp @@ -1068,7 +1068,7 @@ inline bool QosPoliciesSerializer::add_to_cdr_ eprosima::fastcdr::CdrVersion::XCDRv2); // Object that serializes the data. payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); ser << qos_policy.type_information; #if FASTCDR_VERSION_MAJOR == 1 diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index 20d5d540f58..ac99c2d19d4 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1563,7 +1563,9 @@ void DomainParticipantImpl::MyRTPSParticipantListener::onReaderDiscovery( Sentry sentinel(this); if (sentinel) { - participant_->listener_->on_data_reader_discovery(participant_->participant_, std::move(info)); + bool should_be_ignored = false; + participant_->listener_->on_data_reader_discovery(participant_->participant_, std::move(info), + should_be_ignored); } } @@ -1574,7 +1576,9 @@ void DomainParticipantImpl::MyRTPSParticipantListener::onWriterDiscovery( Sentry sentinel(this); if (sentinel) { - participant_->listener_->on_data_writer_discovery(participant_->participant_, std::move(info)); + bool should_be_ignored = false; + participant_->listener_->on_data_writer_discovery(participant_->participant_, std::move(info), + should_be_ignored); } } @@ -1825,11 +1829,11 @@ bool DomainParticipantImpl::can_qos_be_updated( EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "Participant discovery_server_thread cannot be changed after the participant is enabled"); } - if (!(to.typelookup_service_threads() == from.typelookup_service_threads())) + if (!(to.typelookup_service_thread() == from.typelookup_service_thread())) { updatable = false; EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, - "Participant typelookup_service_threads cannot be changed after the participant is enabled"); + "Participant typelookup_service_thread cannot be changed after the participant is enabled"); } #if HAVE_SECURITY if (!(to.security_log_thread() == from.security_log_thread())) diff --git a/src/cpp/fastdds/utils/QosConverters.cpp b/src/cpp/fastdds/utils/QosConverters.cpp index 61d7499356a..a72537c23b8 100644 --- a/src/cpp/fastdds/utils/QosConverters.cpp +++ b/src/cpp/fastdds/utils/QosConverters.cpp @@ -161,7 +161,7 @@ void set_qos_from_attributes( qos.builtin_controllers_sender_thread() = attr.builtin_controllers_sender_thread; qos.timed_events_thread() = attr.timed_events_thread; qos.discovery_server_thread() = attr.discovery_server_thread; - qos.typelookup_service_threads() = attr.typelookup_service_threads; + qos.typelookup_service_thread() = attr.typelookup_service_thread; #if HAVE_SECURITY qos.security_log_thread() = attr.security_log_thread; #endif // if HAVE_SECURITY @@ -210,7 +210,7 @@ void set_attributes_from_qos( attr.builtin_controllers_sender_thread = qos.builtin_controllers_sender_thread(); attr.timed_events_thread = qos.timed_events_thread(); attr.discovery_server_thread = qos.discovery_server_thread(); - attr.typelookup_service_threads = qos.typelookup_service_threads(); + attr.typelookup_service_thread = qos.typelookup_service_thread(); #if HAVE_SECURITY attr.security_log_thread = qos.security_log_thread(); #endif // if HAVE_SECURITY diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp index 1a4754f075c..8c45154ec1d 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp @@ -696,6 +696,24 @@ ReturnCode_t TypeObjectRegistry::get_dependencies_from_type_object( return ret_code; } +const TypeIdentifier TypeObjectRegistry::get_complementary_type_identifier( + const TypeIdentifier& type_id) +{ + std::lock_guard data_guard(type_object_registry_mutex_); + for (const auto& it : local_type_identifiers_) + { + if (it.second.type_identifier1() == type_id && TK_NONE != it.second.type_identifier2()._d()) + { + return it.second.type_identifier2(); + } + else if (it.second.type_identifier2() == type_id && TK_NONE != it.second.type_identifier1()._d()) + { + return it.second.type_identifier1(); + } + } + return type_id; +} + ReturnCode_t TypeObjectRegistry::get_type_dependencies_impl( const TypeIdentifierSeq& type_identifiers, std::unordered_set& type_dependencies) @@ -750,35 +768,6 @@ ReturnCode_t TypeObjectRegistry::get_type_dependencies_impl( return ret_code; } -const TypeIdentifier TypeObjectRegistry::complete_from_minimal_type_identifier( - const TypeIdentifier& type_id) -{ - if (EK_MINIMAL == type_id._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_id._d() && type_id.seq_sdefn().header().equiv_kind() == EK_MINIMAL) || - (TI_PLAIN_SEQUENCE_LARGE == type_id._d() && type_id.seq_ldefn().header().equiv_kind() == EK_MINIMAL) || - (TI_PLAIN_ARRAY_SMALL == type_id._d() && type_id.array_sdefn().header().equiv_kind() == EK_MINIMAL) || - (TI_PLAIN_ARRAY_LARGE == type_id._d() && type_id.array_ldefn().header().equiv_kind() == EK_MINIMAL) || - (TI_PLAIN_MAP_SMALL == type_id._d() && (type_id.map_sdefn().header().equiv_kind() == EK_MINIMAL || - type_id.map_sdefn().key_identifier()->_d() == EK_MINIMAL)) || - (TI_PLAIN_MAP_LARGE == type_id._d() && (type_id.map_ldefn().header().equiv_kind() == EK_MINIMAL || - type_id.map_ldefn().key_identifier()->_d() == EK_MINIMAL))) - { - std::lock_guard data_guard(type_object_registry_mutex_); - for (const auto& it : local_type_identifiers_) - { - if (it.second.type_identifier1() == type_id) - { - return it.second.type_identifier2(); - } - else if (it.second.type_identifier2() == type_id) - { - return it.second.type_identifier1(); - } - } - } - return type_id; -} - void TypeObjectRegistry::add_dependency( const TypeIdentifier& type_id, std::unordered_set& type_dependencies) diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp index f8608dfcdb6..0b2f0fee065 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp @@ -271,13 +271,15 @@ class TypeObjectRegistry : public ITypeObjectRegistry /** * @brief Get Complementary TypeIdentifier. + * Meaning that if the given TypeIdentifier is a complete TypeIdentifier, + * the returned TypeIdentifier will be the minimal TypeIdentifier and vice versa. * - * @param type_id Direct hash TypeIdentifier + * @param type_id TypeIdentifier of which the complementary is to be obtained. * @return TypeIdentifier complementary to the given type_id. - * Same TypeIdentifier if the given TypeIdentifier is not a direct hash TypeIdentifier. + * Same TypeIdentifier if the given TypeIdentifier does not have complementary. */ const TypeIdentifier get_complementary_type_identifier( - const TypeIdentifier& minimal_type_id); + const TypeIdentifier& type_id); // Only DomainParticipantFactory is allowed to instantiate the TypeObjectRegistry class. // It cannot be protected as the standard library needs to access the constructor to allocate the resources. diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp index c446a530a55..4da6e9e22b1 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp @@ -1817,6 +1817,22 @@ const NameHash TypeObjectUtils::name_hash( return name_hashed; } +void TypeObjectUtils::type_object_consistency( + const TypeObject& type_object) +{ + switch (type_object._d()) + { + case EK_COMPLETE: + complete_type_object_consistency(type_object.complete()); + break; + case EK_MINIMAL: + minimal_type_object_consistency(type_object.minimal()); + break; + default: + throw InvalidArgumentError("Inconsistent TypeObject"); + } +} + void TypeObjectUtils::set_try_construct_behavior( MemberFlag& member_flag, TryConstructKind try_construct_kind) @@ -3547,22 +3563,6 @@ void TypeObjectUtils::minimal_type_object_consistency( } } -void TypeObjectUtils::type_object_consistency( - const TypeObject& type_object) -{ - switch (type_object._d()) - { - case EK_COMPLETE: - complete_type_object_consistency(type_object.complete()); - break; - case EK_MINIMAL: - minimal_type_object_consistency(type_object.minimal()); - break; - default: - throw InvalidArgumentError("Inconsistent TypeObject"); - } -} - } // xtypes } // dds } // fastdds diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index eed0b729ad2..4eddeee26c5 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -948,12 +948,14 @@ bool ReaderProxyData::readFromCDRMessage( } case fastdds::dds::PID_TYPE_IDV1: { - EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, "PID_TYPE_IDV1 not supported"); + EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, + "Reception of TypeIdentifiers is not supported. They will be ignored."); break; } case fastdds::dds::PID_TYPE_OBJECTV1: { - EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, "PID_TYPE_OBJECTV1 not supported"); + EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, + "Reception of TypeObjects is not supported. They will be ignored."); break; } case fastdds::dds::PID_TYPE_INFORMATION: diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index 8da276e7fd2..f7a65bbd2fc 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -939,12 +939,14 @@ bool WriterProxyData::readFromCDRMessage( } case fastdds::dds::PID_TYPE_IDV1: { - EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, "PID_TYPE_IDV1 not supported"); + EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, + "Reception of TypeIdentifiers is not supported. They will be ignored"); break; } case fastdds::dds::PID_TYPE_OBJECTV1: { - EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, "PID_TYPE_OBJECTV1 not supported"); + EPROSIMA_LOG_WARNING(RTPS_PROXY_DATA, + "Reception of TypeObjects is not supported. They will be ignored"); break; } case fastdds::dds::PID_TYPE_INFORMATION: diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index a279d342011..e105c64d5d8 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -89,7 +89,7 @@ class EDP //! Bit index for matching failing due to inconsistent partitions static const uint32_t partitions = (0x00000001 << 3u); - //! Bit index for matching failing due to inconsistent TypeInformation + //! Bit index for matching failing due to incompatible TypeInformation static const uint32_t different_typeinfo = (0x00000001 << 4u); }; diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index b6d2deb738b..1ddbbece811 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -138,10 +138,10 @@ void EDPBasePUBListener::add_writer_from_change( temp_writer_data, after_typelookup_callback); } - // If TypeInformation does not exists, try fallbacks + // If TypeInformation does not exist, try fallback mechanism else { - EPROSIMA_LOG_WARNING(RTPS_EDP, "EDPBasePUBListener: No TypeInformation. Using fallbacks"); + EPROSIMA_LOG_INFO(RTPS_EDP, "EDPBasePUBListener: No TypeInformation. Trying fallback mechanism"); after_typelookup_callback(temp_writer_data); } @@ -273,10 +273,10 @@ void EDPBaseSUBListener::add_reader_from_change( temp_reader_data, after_typelookup_callback); } - // If TypeInformation does not exists, try fallbacks + // If TypeInformation does not exist, try fallback mechanism else { - EPROSIMA_LOG_WARNING(RTPS_EDP, "EDPBasePUBListener: No TypeInformation. Using fallbacks"); + EPROSIMA_LOG_INFO(RTPS_EDP, "EDPBasePUBListener: No TypeInformation. Trying fallback mechanism"); after_typelookup_callback(temp_reader_data); } diff --git a/src/cpp/xmlparser/XMLParser.cpp b/src/cpp/xmlparser/XMLParser.cpp index 20a6cf1a575..e394a63349b 100644 --- a/src/cpp/xmlparser/XMLParser.cpp +++ b/src/cpp/xmlparser/XMLParser.cpp @@ -2486,10 +2486,10 @@ XMLP_ret XMLParser::fillDataNode( return XMLP_ret::XML_ERROR; } } - else if (strcmp(name, TYPELOOKUP_SERVICE_THREADS) == 0) + else if (strcmp(name, TYPELOOKUP_SERVICE_THREAD) == 0) { if (XMLP_ret::XML_OK != - getXMLThreadSettings(*p_aux0, participant_node.get()->rtps.typelookup_service_threads)) + getXMLThreadSettings(*p_aux0, participant_node.get()->rtps.typelookup_service_thread)) { return XMLP_ret::XML_ERROR; } diff --git a/src/cpp/xmlparser/XMLParserCommon.cpp b/src/cpp/xmlparser/XMLParserCommon.cpp index a57f288ff61..11b01382b21 100644 --- a/src/cpp/xmlparser/XMLParserCommon.cpp +++ b/src/cpp/xmlparser/XMLParserCommon.cpp @@ -146,7 +146,7 @@ const char* MAX_USER_DATA = "max_user_data"; const char* MAX_PARTITIONS = "max_partitions"; const char* TIMED_EVENTS_THREAD = "timed_events_thread"; const char* DISCOVERY_SERVER_THREAD = "discovery_server_thread"; -const char* TYPELOOKUP_SERVICE_THREADS = "typelookup_service_threads"; +const char* TYPELOOKUP_SERVICE_THREAD = "typelookup_service_thread"; const char* SECURITY_LOG_THREAD = "security_log_thread"; const char* BUILTIN_TRANSPORTS_RECEPTION_THREADS = "builtin_transports_reception_threads"; const char* BUILTIN_CONTROLLERS_SENDER_THREAD = "builtin_controllers_sender_thread"; diff --git a/src/cpp/xmlparser/XMLParserCommon.h b/src/cpp/xmlparser/XMLParserCommon.h index e2995ba5731..d157facebb2 100644 --- a/src/cpp/xmlparser/XMLParserCommon.h +++ b/src/cpp/xmlparser/XMLParserCommon.h @@ -162,7 +162,7 @@ extern const char* MAX_USER_DATA; extern const char* MAX_PARTITIONS; extern const char* TIMED_EVENTS_THREAD; extern const char* DISCOVERY_SERVER_THREAD; -extern const char* TYPELOOKUP_SERVICE_THREADS; +extern const char* TYPELOOKUP_SERVICE_THREAD; extern const char* SECURITY_LOG_THREAD; extern const char* BUILTIN_TRANSPORTS_RECEPTION_THREADS; extern const char* BUILTIN_CONTROLLERS_SENDER_THREAD; diff --git a/test/blackbox/api/dds-pim/PubSubReader.hpp b/test/blackbox/api/dds-pim/PubSubReader.hpp index 759a5b673d4..b679da43758 100644 --- a/test/blackbox/api/dds-pim/PubSubReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubReader.hpp @@ -115,7 +115,8 @@ class PubSubReader void on_data_writer_discovery( eprosima::fastdds::dds::DomainParticipant*, - eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { if (reader_.onEndpointDiscovery_ != nullptr) { diff --git a/test/blackbox/api/dds-pim/PubSubWriter.hpp b/test/blackbox/api/dds-pim/PubSubWriter.hpp index f521da1a95b..9137db8671a 100644 --- a/test/blackbox/api/dds-pim/PubSubWriter.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriter.hpp @@ -117,7 +117,8 @@ class PubSubWriter void on_data_reader_discovery( eprosima::fastdds::dds::DomainParticipant*, - eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { if (info.status == eprosima::fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER) { @@ -136,7 +137,8 @@ class PubSubWriter void on_data_writer_discovery( eprosima::fastdds::dds::DomainParticipant*, - eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { if (info.status == eprosima::fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER) { diff --git a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp index 3ac30141980..5dab51af3f5 100644 --- a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp @@ -110,7 +110,8 @@ class PubSubWriterReader void on_data_reader_discovery( eprosima::fastdds::dds::DomainParticipant* participant, - eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { (void)participant; @@ -131,7 +132,8 @@ class PubSubWriterReader void on_data_writer_discovery( eprosima::fastdds::dds::DomainParticipant* participant, - eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { (void)participant; diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h index 005abd075ac..2ec5e6c784e 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -464,7 +464,7 @@ class RTPSParticipantAttributes (this->security_log_thread == b.security_log_thread) && #endif // if HAVE_SECURITY (this->discovery_server_thread == b.discovery_server_thread) && - (this->typelookup_service_threads == b.typelookup_service_threads) && + (this->typelookup_service_thread == b.typelookup_service_thread) && (this->builtin_transports_reception_threads == b.builtin_transports_reception_threads); } @@ -618,8 +618,8 @@ class RTPSParticipantAttributes //! Thread settings for the discovery server thread fastdds::rtps::ThreadSettings discovery_server_thread; - //! Thread settings for the builtin TypeLookup service threads - fastdds::rtps::ThreadSettings typelookup_service_threads; + //! 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; diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index baaa5dbc831..a3b73f88001 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -3159,9 +3159,9 @@ TEST(ParticipantTests, UpdatableDomainParticipantQos) pqos.discovery_server_thread().affinity = 1; ASSERT_EQ(participant->set_qos(pqos), RETCODE_IMMUTABLE_POLICY); - // Check that the typelookup_service_threads can not be changed in an enabled participant + // Check that the typelookup_service_thread can not be changed in an enabled participant participant->get_qos(pqos); - pqos.typelookup_service_threads().affinity = 1; + pqos.typelookup_service_thread().affinity = 1; ASSERT_EQ(participant->set_qos(pqos), RETCODE_IMMUTABLE_POLICY); #if HAVE_SECURITY diff --git a/test/unittest/dds/profiles/test_xml_for_string_profile.xml b/test/unittest/dds/profiles/test_xml_for_string_profile.xml index 169c6fdae19..b82c883fcaa 100644 --- a/test/unittest/dds/profiles/test_xml_for_string_profile.xml +++ b/test/unittest/dds/profiles/test_xml_for_string_profile.xml @@ -138,10 +138,10 @@ 15 1048576 - + 15 1048576 - + 15 1048576 @@ -287,10 +287,10 @@ 15 1048576 - + 15 1048576 - + 15 1048576 diff --git a/test/unittest/dds/profiles/test_xml_profile.xml b/test/unittest/dds/profiles/test_xml_profile.xml index 620fe5655cf..3d8c3604ed8 100644 --- a/test/unittest/dds/profiles/test_xml_profile.xml +++ b/test/unittest/dds/profiles/test_xml_profile.xml @@ -135,10 +135,10 @@ 15 1048576 - + 15 1048576 - + 15 1048576 @@ -284,10 +284,10 @@ 15 1048576 - + 15 1048576 - + 15 1048576 diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index 22c441415ed..5ff23d7254e 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -374,7 +374,8 @@ TEST(DataWriterTests, get_guid) void on_data_writer_discovery( DomainParticipant*, - fastrtps::rtps::WriterDiscoveryInfo&& info) + fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { std::unique_lock lock(mutex); if (fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER == info.status) diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index c83cbef8242..d2c29d3bdde 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -580,7 +580,8 @@ TEST_F(DataReaderTests, get_guid) void on_data_reader_discovery( DomainParticipant*, - ReaderDiscoveryInfo&& info) + ReaderDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { std::unique_lock lock(mutex); if (ReaderDiscoveryInfo::DISCOVERED_READER == info.status) diff --git a/test/unittest/xmlparser/test_xml_deprecated.xml b/test/unittest/xmlparser/test_xml_deprecated.xml index d21c3a8e32c..baa203da3df 100644 --- a/test/unittest/xmlparser/test_xml_deprecated.xml +++ b/test/unittest/xmlparser/test_xml_deprecated.xml @@ -165,12 +165,12 @@ 12 12 - + 12 12 12 12 - + 12 12 diff --git a/test/unittest/xmlparser/test_xml_profile.xml b/test/unittest/xmlparser/test_xml_profile.xml index 81490cd6ee8..f75239b65db 100644 --- a/test/unittest/xmlparser/test_xml_profile.xml +++ b/test/unittest/xmlparser/test_xml_profile.xml @@ -181,12 +181,12 @@ 12 12 - + 12 12 12 12 - + 12 12 diff --git a/test/unittest/xmlparser/test_xml_profile_env_var.xml b/test/unittest/xmlparser/test_xml_profile_env_var.xml index a1df6f4bbac..57428c1151a 100644 --- a/test/unittest/xmlparser/test_xml_profile_env_var.xml +++ b/test/unittest/xmlparser/test_xml_profile_env_var.xml @@ -162,12 +162,12 @@ ${XML_PROFILES_ENV_VAR_160} ${XML_PROFILES_ENV_VAR_161} - + ${XML_PROFILES_ENV_VAR_158} ${XML_PROFILES_ENV_VAR_159} ${XML_PROFILES_ENV_VAR_160} ${XML_PROFILES_ENV_VAR_161} - + ${XML_PROFILES_ENV_VAR_158} ${XML_PROFILES_ENV_VAR_159} diff --git a/test/unittest/xmlparser/test_xml_rooted_deprecated.xml b/test/unittest/xmlparser/test_xml_rooted_deprecated.xml index ae184a94039..3a5939c3cf8 100644 --- a/test/unittest/xmlparser/test_xml_rooted_deprecated.xml +++ b/test/unittest/xmlparser/test_xml_rooted_deprecated.xml @@ -140,12 +140,12 @@ 12 12 - + 12 12 12 12 - + 12 12 diff --git a/test/unittest/xmlparser/test_xml_rooted_profile.xml b/test/unittest/xmlparser/test_xml_rooted_profile.xml index c0e43194bfd..d02b379f79a 100644 --- a/test/unittest/xmlparser/test_xml_rooted_profile.xml +++ b/test/unittest/xmlparser/test_xml_rooted_profile.xml @@ -155,12 +155,12 @@ 12 12 - + 12 12 12 12 - + 12 12 From e0040ed680a3213750e0fe257ff5da0aa0aeda89 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Fri, 2 Feb 2024 12:42:28 +0100 Subject: [PATCH 24/35] Refs #20160: Changes for xtypes doc. Signed-off-by: adriancampo --- include/fastdds/dds/xtypes/common.hpp | 6 +- .../dynamic_types/AnnotationDescriptor.hpp | 2 +- .../dds/xtypes/dynamic_types/DynamicData.hpp | 4 +- .../dynamic_types/DynamicDataFactory.hpp | 2 +- .../dds/xtypes/dynamic_types/DynamicType.hpp | 3 +- .../dynamic_types/DynamicTypeBuilder.hpp | 5 +- .../DynamicTypeBuilderFactory.hpp | 14 +- .../dynamic_types/DynamicTypeMember.hpp | 2 +- .../xtypes/dynamic_types/MemberDescriptor.hpp | 8 +- .../xtypes/dynamic_types/TypeDescriptor.hpp | 18 +- .../xtypes/type_representation/TypeObject.hpp | 2 +- .../type_representation/TypeObjectUtils.hpp | 194 +++++++++--------- .../type_representation/TypeObjectUtils.cpp | 10 +- 13 files changed, 136 insertions(+), 134 deletions(-) diff --git a/include/fastdds/dds/xtypes/common.hpp b/include/fastdds/dds/xtypes/common.hpp index 3001d6120f4..3a2032fb38b 100644 --- a/include/fastdds/dds/xtypes/common.hpp +++ b/include/fastdds/dds/xtypes/common.hpp @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file + * @file common.hpp * This file contains common definitions for the different XTypes modules. */ @@ -43,8 +43,8 @@ enum class TryConstructKind : uint32_t TRIM }; -/** - * @brief PlacementKind values (@verbatim annotation) +/*! + * @brief PlacementKind values (verbatim annotation) */ enum class PlacementKind : uint32_t { diff --git a/include/fastdds/dds/xtypes/dynamic_types/AnnotationDescriptor.hpp b/include/fastdds/dds/xtypes/dynamic_types/AnnotationDescriptor.hpp index 5eaef141de7..781bed34cf9 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/AnnotationDescriptor.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/AnnotationDescriptor.hpp @@ -45,7 +45,7 @@ class FASTDDS_EXPORTED_API AnnotationDescriptor /*! * Modifies the underlying type reference. - * @param[in] @ref DynamicType reference. + * @param[in] type @ref DynamicType reference. */ virtual void type( traits::ref_type type) = 0; diff --git a/include/fastdds/dds/xtypes/dynamic_types/DynamicData.hpp b/include/fastdds/dds/xtypes/dynamic_types/DynamicData.hpp index 6aefb983224..d1c29039eb3 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/DynamicData.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/DynamicData.hpp @@ -168,7 +168,7 @@ class DynamicData : public std::enable_shared_from_this /*! * Retrieves an \b int32 value associated to an identifier. * @param[inout] value \b int32 to populate - * @param[in] Id identifier of the member to query. + * @param[in] id identifier of the member to query. * @return @ref ReturnCode_t * @retval RETCODE_OK when the value was retrieved successfully. * @retval RETCODE_BAD_PARAMETER when the @ref MemberId is invalid or the member type is not promotable to \b int32. @@ -516,7 +516,7 @@ class DynamicData : public std::enable_shared_from_this /*! * Sets an \b bool value associated to an identifier - * @param[in] Id identifier of the member to set. + * @param[in] id identifier of the member to set. * @param[in] value \b bool to set. * @return @ref ReturnCode_t * @retval RETCODE_OK when the value was set successfully. diff --git a/include/fastdds/dds/xtypes/dynamic_types/DynamicDataFactory.hpp b/include/fastdds/dds/xtypes/dynamic_types/DynamicDataFactory.hpp index a1dc29fcc77..688363347e8 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/DynamicDataFactory.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/DynamicDataFactory.hpp @@ -57,7 +57,7 @@ class DynamicDataFactory : public std::enable_shared_from_this /*! * Returns the member that corresponds to the specified name. * @param[inout] member @ref DynamicTypeMember reference used to return the reference to the member. + * @param[in] name the name of the member. * @return @ref ReturnCode_t * @retval RETCODE_OK when the member was found. * @retval RETCODE_BAD_PARAMETER when the member doesn't exist. @@ -154,7 +155,7 @@ class DynamicType : public std::enable_shared_from_this /** * State comparison according with the [standard] sections \b 7.5.2.8.4 - * @param[in] other @DynamicType reference to compare to + * @param[in] other DynamicType reference to compare to * @return \b bool `true` on equality */ FASTDDS_EXPORTED_API virtual bool equals( diff --git a/include/fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp b/include/fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp index 9ea32a56ecf..ad71893873e 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp @@ -70,7 +70,7 @@ class DynamicTypeBuilder : public std::enable_shared_from_this::ref_type type) = 0; /*! - * Creates a new @ref DynamicTypeBuilder reference based on the given @ref TypeObject instance. - * @param[in] type_object @ref TypeObject instance to be used. + * Creates a new @ref DynamicTypeBuilder reference based on the given @ref xtypes::TypeObject instance. + * @param[in] type_object @ref xtypes::TypeObject instance to be used. * @return New @ref DynamicTypeBuilder reference. Nil reference returned in error case. */ FASTDDS_EXPORTED_API virtual traits::ref_type create_type_w_type_object( @@ -117,7 +117,7 @@ class DynamicTypeBuilderFactory : public std::enable_shared_from_this::ref_type create_array_type( @@ -126,8 +126,8 @@ class DynamicTypeBuilderFactory : public std::enable_shared_from_this /** * State comparison according with the [standard] sections \b 7.5.2.6.3 - * @param[in] other @DynamicTypeMember reference to compare to + * @param[in] other DynamicTypeMember reference to compare to * @return \b bool `true` on equality */ FASTDDS_EXPORTED_API virtual bool equals( diff --git a/include/fastdds/dds/xtypes/dynamic_types/MemberDescriptor.hpp b/include/fastdds/dds/xtypes/dynamic_types/MemberDescriptor.hpp index a39a03fceb8..9c6f7b111ee 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/MemberDescriptor.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/MemberDescriptor.hpp @@ -75,7 +75,7 @@ class FASTDDS_EXPORTED_API MemberDescriptor /*! * Modifies the underlying @ref MemberId. - * @param[in] @ref MemberId to be set. + * @param[in] id @ref MemberId to be set. */ virtual void id( MemberId id) = 0; @@ -94,7 +94,7 @@ class FASTDDS_EXPORTED_API MemberDescriptor /*! * Modifies the underlying member's type reference. - * @param[in] @ref DynamicType reference. + * @param[in] type @ref DynamicType reference. */ virtual void type( traits::ref_type type) = 0; @@ -151,14 +151,14 @@ class FASTDDS_EXPORTED_API MemberDescriptor /*! * Modifies the labels the member belongs to by copy. - * @param[in] @ref UnionCaseLabelSeq + * @param[in] label @ref UnionCaseLabelSeq */ virtual void label( const UnionCaseLabelSeq& label) = 0; /*! * Modifies the labels the member belongs to by move. - * @param[in] @ref UnionCaseLabelSeq + * @param[in] label @ref UnionCaseLabelSeq */ virtual void label( UnionCaseLabelSeq&& label) = 0; diff --git a/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp b/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp index f5512402c26..be43457e6d1 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp @@ -48,7 +48,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Modifies the underlying @ref TypeKind. - * @param[in] @ref TypeKind to be set. + * @param[in] kind @ref TypeKind to be set. */ virtual void kind( TypeKind kind) = 0; @@ -93,7 +93,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Modifies the underlying base type reference. - * @param[in] @ref DynamicType reference. + * @param[in] type @ref DynamicType reference. */ virtual void base_type( traits::ref_type type) = 0; @@ -112,7 +112,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Modifies the underlying discriminator type reference. - * @param[in] @ref DynamicType reference. + * @param[in] type @ref DynamicType reference. */ virtual void discriminator_type( traits::ref_type type) = 0; @@ -131,14 +131,14 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Modifies the underlying bound by copy. - * @param[in] @ref BoundSeq + * @param[in] bound @ref BoundSeq */ virtual void bound( const BoundSeq& bound) = 0; /*! * Modifies the underlying bound by move. - * @param[in] @ref BoundSeq + * @param[in] bound @ref BoundSeq */ virtual void bound( BoundSeq&& bound) = 0; @@ -157,7 +157,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Modifies the underlying element type reference. - * @param[in] @ref DynamicType reference. + * @param[in] type @ref DynamicType reference. */ virtual void element_type( traits::ref_type type) = 0; @@ -176,7 +176,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Modifies the underlying key element type reference. - * @param[in] @ref DynamicType reference. + * @param[in] type @ref DynamicType reference. */ virtual void key_element_type( traits::ref_type type) = 0; @@ -196,7 +196,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Modifies the extensibility kind. - * @param[in] @ref ExtensibilityKind + * @param[in] extensibility_kind @ref ExtensibilityKind */ virtual void extensibility_kind( ExtensibilityKind extensibility_kind) = 0; @@ -215,7 +215,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Mofifies the is_nested property. - * @param[in] Boolean + * @param[in] is_nested */ virtual void is_nested( bool is_nested) = 0; diff --git a/include/fastdds/dds/xtypes/type_representation/TypeObject.hpp b/include/fastdds/dds/xtypes/type_representation/TypeObject.hpp index af46c4f8dbe..3be6383ca03 100644 --- a/include/fastdds/dds/xtypes/type_representation/TypeObject.hpp +++ b/include/fastdds/dds/xtypes/type_representation/TypeObject.hpp @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file TypeObject.h + * @file TypeObject.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. diff --git a/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp b/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp index 84e4c7c8d81..960bd72b36a 100644 --- a/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp +++ b/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp @@ -53,7 +53,7 @@ class TypeObjectUtils * * @param[in] discriminator TypeObjectHashId discriminator to be set. * @param[in] hash StronglyConnectedComponent equivalence hash to be set. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given discriminator is not + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given discriminator is not * EK_COMPLETE/EK_MINIMAL. * @return const TypeObjectHashId instance. */ @@ -80,7 +80,7 @@ class TypeObjectUtils * @param[in] must_understand must_understand annotation value. * @param[in] key key annotation value. * @param[in] external external annotation value. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if both key and optional flags are + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if both key and optional flags are * enabled. * @return StructMemberFlag instance. */ @@ -173,7 +173,7 @@ class TypeObjectUtils * * @pre bound > 0 (INVALID_SBOUND) * @param[in] bound Bound for the small string/wstring. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if bound is 0. + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if bound is 0. * @return const StringSTypeDefn instance. */ FASTDDS_EXPORTED_API static const StringSTypeDefn build_string_s_type_defn( @@ -184,7 +184,7 @@ class TypeObjectUtils * * @pre bound > 255 * @param[in] bound Bound for the large string/wstring. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if bound is lower than 256. + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if bound is lower than 256. * @return const StringLTypeDefn instance. */ FASTDDS_EXPORTED_API static const StringLTypeDefn build_string_l_type_defn( @@ -196,7 +196,7 @@ class TypeObjectUtils * @param[in] equiv_kind EquivalenceKind: EK_MINIMAL/EK_COMPLETE/EK_BOTH * @param[in] element_flags CollectionElementFlags to be set. This element must be constructed with the corresponding * builder to ensure its consistency. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError if the given element_flags are inconsistent. + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError if the given element_flags are inconsistent. * This exception is only thrown in Debug build mode. * @return const PlainCollectionHeader instance. */ @@ -210,9 +210,9 @@ class TypeObjectUtils * @pre bound > 0 (INVALID_SBOUND) * @pre element_identifier has been initialized. * @param[in] header PlainCollectionHeader to be set. - * @param[in] bound Sequence bound. + * @param[in] s_bound Sequence bound. * @param[in] element_identifier Sequence element TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception * 1. The given bound is 0. * 2. The given TypeIdentifier EquivalenceKind is not consistent with the one contained in the header. * 3. Inconsistent header (only in Debug build mode). @@ -230,9 +230,9 @@ class TypeObjectUtils * @pre bound > 255 * @pre element_identifier has been initialized. * @param[in] header PlainCollectionHeader to be set. - * @param[in] bound Sequence bound. + * @param[in] l_bound Sequence bound. * @param[in] element_identifier Sequence element TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception * 1. Bound lower than 256. * 2. The given TypeIdentifier EquivalenceKind is not consistent with the one contained in the header. * 3. Inconsistent header (only in Debug build mode). @@ -241,7 +241,7 @@ class TypeObjectUtils */ FASTDDS_EXPORTED_API static const PlainSequenceLElemDefn build_plain_sequence_l_elem_defn( const PlainCollectionHeader& header, - LBound bound, + LBound l_bound, const eprosima::fastcdr::external& element_identifier); /** @@ -272,7 +272,7 @@ class TypeObjectUtils * @param[in] header PlainCollectionHeader to be set. * @param[in] array_bound_seq Bounds for the array dimensions. * @param[in] element_identifier Array element TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception * 1. Any given bound in array_bound_seq is 0. * 2. The given TypeIdentifier EquivalenceKind is not consistent with the one contained in the header. * 3. Inconsistent header (only in Debug build mode). @@ -292,7 +292,7 @@ class TypeObjectUtils * @param[in] header PlainCollectionHeader to be set. * @param[in] array_bound_seq Bounds for the array dimensions. * @param[in] element_identifier Array element TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception * 1. Any given bound in array_bound_seq is 0. * 2. There is no dimension with a bound greater than 255. * 3. The given TypeIdentifier EquivalenceKind is not consistent with the one contained in the header. @@ -315,7 +315,7 @@ class TypeObjectUtils * @param[in] element_identifier Map element TypeIdentifier. * @param[in] key_flags Flags applying to map key. * @param[in] key_identifier Map key TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception * 1. Given bound is zero (INVALID_SBOUND) * 2. Inconsistent element_identifier EquivalenceKind with the one contained in the header. * 3. Direct hash key_identifier or indirect hash TypeIdentifier with exception to string/wstring. @@ -343,7 +343,7 @@ class TypeObjectUtils * @param[in] element_identifier Map element TypeIdentifier. * @param[in] key_flags Flags applying to map key. * @param[in] key_identifier Map key TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception * 1. Given bound is lower than 256 * 2. Inconsistent element_identifier EquivalenceKind with the one contained in the header. * 3. Direct hash key_identifier or indirect hash TypeIdentifier with exception to string/wstring. @@ -392,7 +392,7 @@ class TypeObjectUtils * @param[in] string StringSTypeDefn union member to set. * @param[in] type_name Type name to be registered. * @param[in] wstring Flag to build a wstring. Default false. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given member is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given member is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeIdentifier registered with @@ -410,7 +410,7 @@ class TypeObjectUtils * @param[in] string StringLTypeDefn union member to set. * @param[in] type_name Type name to be registered. * @param[in] wstring Flag to build a wstring. Default false. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given member is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given member is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeIdentifier registered with @@ -427,7 +427,7 @@ class TypeObjectUtils * * @param[in] plain_seq PlainSequenceSElemDefn union member to set. * @param[in] type_name Type name to be registered. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given member is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given member is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeIdentifier registered with @@ -443,7 +443,7 @@ class TypeObjectUtils * * @param[in] plain_seq PlainSequenceLElemDefn union member to set. * @param[in] type_name Type name to be registered. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given member is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given member is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeIdentifier registered with @@ -459,7 +459,7 @@ class TypeObjectUtils * * @param[in] plain_array PlainArraySElemDefn union member to set. * @param[in] type_name Type name to be registered. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given member is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given member is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeIdentifier registered with @@ -475,7 +475,7 @@ class TypeObjectUtils * * @param[in] plain_array PlainArrayLElemDefn union member to set. * @param[in] type_name Type name to be registered. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given member is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given member is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeIdentifier registered with @@ -491,7 +491,7 @@ class TypeObjectUtils * * @param[in] plain_map PlainMapSTypeDefn union member to set. * @param[in] type_name Type name to be registered. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given member is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given member is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeIdentifier registered with @@ -507,7 +507,7 @@ class TypeObjectUtils * * @param[in] plain_map PlainMapLTypeDefn union member to set. * @param[in] type_name Type name to be registered. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given member is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given member is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeIdentifier registered with @@ -717,7 +717,7 @@ class TypeObjectUtils * @brief Add AppliedAnnotationParameter to the sequence. * * @param[in out] param_seq AppliedAnnotationParameter sequence to be modified. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the parameter being added has + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the parameter being added has * already been included in the sequence. * @param[in] param AppliedAnnotationParameter to be added. */ @@ -730,7 +730,7 @@ class TypeObjectUtils * * @param[in] annotation_typeid Annotation TypeIdentifier. * @param[in] param_seq Annotation parameters. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given annotation_typeid TypeIdentifier does not correspond to an annotation TypeObject (only in * Debug build mode). * 2. Given AppliedAnnotationParameterSeq is inconsistent (only in Debug build mode). @@ -747,7 +747,7 @@ class TypeObjectUtils * * @param[in out] ann_custom_seq AppliedAnnotation sequence to be modified. * @param[in] ann_custom AppliedAnnotation to be added. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given AppliedAnnotation is not consistent (only in Debug build mode). * 2. Given AppliedAnnotation is already present in the sequence. */ @@ -790,7 +790,7 @@ class TypeObjectUtils * @param[in] member_id Member identifier. * @param[in] member_flags Member flags: optional, must_understand, key, and external. * @param[in] member_type_id Member TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception: * 1. The given flags are not consistent (only in Debug build mode). * 2. The given TypeIdentifier is not consistent (only in Debug build mode). * @return const CommonStructMember instance. @@ -806,7 +806,7 @@ class TypeObjectUtils * @param[in] name Member name. * @param[in] ann_builtin Member builtin annotations. * @param[in] ann_custom Member custom annotations. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Empty member name. * 2. Given AppliedAnnotationSeq is not consistent (only Debug build mode). * @return const CompleteMemberDetail instance. @@ -825,7 +825,7 @@ class TypeObjectUtils * * @param[in] common CommonStructMember to be set. * @param[in] detail CompleteMemberDetail to be set. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonStructMember is inconsistent (only Debug build mode). * 2. Given CompleteMemberDetail is inconsistent (only Debug build mode). * @return const CompleteMemberDetail instance. @@ -838,8 +838,8 @@ class TypeObjectUtils * @brief Add CompleteStructMember to the sequence. * * @param[in out] member_seq CompleteStructMember sequence to be modified. - * @param[in] ann_custom CompleteStructMember to be added. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @param[in] member CompleteStructMember to be added. + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CompleteStructMember is not consistent (only in Debug build mode). * 2. There is already another member in the sequence with the same member id or the same member name * (only in Debug build mode). @@ -856,7 +856,7 @@ class TypeObjectUtils * @brief Build AppliedBuiltinTypeAnnotations instance. * * @param[in] verbatim AppliedVerbatimAnnotation to be set. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given verbatim annotation + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given verbatim annotation * is inconsistent (only in Debug build mode). * @return const AppliedBuiltinTypeAnnotations instance. */ @@ -873,7 +873,7 @@ class TypeObjectUtils * @param[in] ann_builtin Verbatim annotation. * @param[in] ann_custom Applied annotations. * @param[in] type_name Name of the type. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given type_name is empty. * 2. any applied annotation is not consistent (only Debug build mode). * @return const CompleteTypeDetail instance. @@ -888,7 +888,7 @@ class TypeObjectUtils * * @param[in] base_type TypeIdentifier of the parent structure (inheritance). * @param[in] detail CompleteTypeDetail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given TypeIdentifier is not consistent (direct HASH or empty TypeIdentifier). In Debug build * mode the corresponding TypeObject is also checked in case of direct HASH TypeIdentifier. * 2. Given CompleteTypeDetail is not consistent (only in Debug build mode). @@ -908,7 +908,7 @@ class TypeObjectUtils * @param[in] struct_flags StructTypeFlags. * @param[in] header CompleteStructHeader. * @param[in] member_seq Sequence of CompleteStructMembers. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given StructTypeFlag is not consistent (only in Debug build mode). * 2. Given CompleteStructHeader is not consistent (only in Debug build mode). * 3. Given CompleteStructMemberSeq is not consistent (only in Debug build mode). @@ -943,7 +943,7 @@ class TypeObjectUtils * @param[in] member_flags Member flags. * @param[in] type_id Member TypeIdentifier. * @param[in] label_seq Member applicable case labels. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given UnionMemberFlags are not consistent (only Debug build mode). * 2. Given TypeIdentifier is not consistent (only Debug build mode). * @return const CommonUnionMember instance. @@ -959,7 +959,7 @@ class TypeObjectUtils * * @param[in] common CommonUnionMember. * @param[in] detail CompleteMemberDetail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonUnionMember is not consistent (only in Debug build mode). * 2. Given CompleteMemberDetail is not consistent (only in Debug build mode). * @return const CompleteUnionMember instance. @@ -973,7 +973,7 @@ class TypeObjectUtils * * @param[in out] complete_union_member_seq Sequence to be modified. * @param[in] member Complete union member to be added. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CompleteUnionMember is not consistent (only in Debug build mode). * 2. There is already another member in the sequence with the same member id or the same member name * (only in Debug build mode). @@ -995,7 +995,7 @@ class TypeObjectUtils * * @param[in] member_flags Discriminator flags. * @param[in] type_id Discriminator TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given discriminator flags are inconsistent (only in Debug build mode). * 2. Given TypeIdentifier is not consistent. * XTypes v1.3 Clause 7.2.2.4.4.3 The discriminator of a union must be one of the following types: @@ -1014,7 +1014,7 @@ class TypeObjectUtils * @param[in] common CommonDiscriminatorMember. * @param[in] ann_builtin Verbatim annotation. * @param[in] ann_custom Applied annotations. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonDiscriminatorMember is inconsistent (only in Debug build mode). * 2. AppliedBuiltinTypeAnnotation is inconsistent (only in Debug build mode). * 3. Any given AppliedAnnotation is inconsistent (only in Debug build mode). @@ -1034,7 +1034,7 @@ class TypeObjectUtils * @brief Build CompleteUnionHeader instance. * * @param detail CompleteTypeDetail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given CompleteTypeDetail is + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given CompleteTypeDetail is * not consistent (only in Debug build mode). * @return const CompleteUnionHeader instance. */ @@ -1052,7 +1052,7 @@ class TypeObjectUtils * @param[in] header * @param[in] discriminator * @param[in] member_seq - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given UnionTypeFlags are not consistent (only in Debug build mode). * 2. Given CompleteUnionHeader is not consistent (only in Debug build mode). * 3. Given CompleteDiscriminatorMember inconsistent (only in Debug build mode). @@ -1077,7 +1077,7 @@ class TypeObjectUtils * * @param[in] member_flags AnnotationParameterFlag: empty. No flags apply. It must be zero. * @param[in] member_type_id Member TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given AnnotationParameterFlag are not empty. * 2. Given TypeIdentifier is not consistent (only in Debug build mode). * @return const CommonAnnotationParameter instance. @@ -1092,7 +1092,7 @@ class TypeObjectUtils * @param[in] common CommonAnnotationParameter. * @param[in] name Member name. * @param[in] default_value Annotation default value. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonAnnotationParameter is inconsistent (only in Debug build mode). * 2. CommonAnnotationParameter TypeIdentifier is inconsistent with AnnotationParameterValue type. * 3. Given parameter name is empty. @@ -1108,7 +1108,7 @@ class TypeObjectUtils * * @param[in out] sequence Sequence to be modified. * @param[in] param Complete annotation parameter to be added. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CompleteAnnotationParameter is not consistent (only in Debug build mode). * 2. There is already another member in the sequence with the same member id or the same member name * (only in Debug build mode). @@ -1125,7 +1125,7 @@ class TypeObjectUtils * @brief Build CompleteAnnotationHeader instance. * * @param[in] annotation_name Qualified annotation type name. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError if the annotation_name is empty. + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError if the annotation_name is empty. * @return const CompleteAnnotationHeader instance. */ FASTDDS_EXPORTED_API static const CompleteAnnotationHeader build_complete_annotation_header( @@ -1141,7 +1141,7 @@ class TypeObjectUtils * @param[in] annotation_flag Unused. No flags apply. It must be 0. * @param[in] header CompleteAnnotationHeader. * @param[in] member_seq CompleteAnnotationParameter sequence. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Any annotation flag is set. * 2. Given header is inconsistent (only in Debug build mode). * 3. Any CompleteAnnotationParameter in the sequence is inconsistent (only in Debug build mode). @@ -1163,7 +1163,7 @@ class TypeObjectUtils * * @param[in] related_flags AliasMemberFlag: unused. No flags apply. It must be 0. * @param[in] related_type Related TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Any alias member flag is set. * 2. Non-consistent TypeIdentifier (only in Debug build mode). * @return const CommonAliasBody instance. @@ -1178,10 +1178,10 @@ class TypeObjectUtils * @param[in] common CommonAliasBody. * @param[in] ann_builtin Applied builtin member annotations: unit, max, min, range, hashid * @param[in] ann_custom Applied custom annotations - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonAliasBody is inconsistent (only Debug build mode). * 2. AppliedAnnotationSeq is inconsistent (only Debug build mode). - * 3. @hashid builtin annotation is set. + * 3. hashid builtin annotation is set. * @return const CompleteAliasBody instance. */ FASTDDS_EXPORTED_API static const CompleteAliasBody build_complete_alias_body( @@ -1197,7 +1197,7 @@ class TypeObjectUtils * @brief Build CompleteAliasHeader instance. * * @param[in] detail Complete type detail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given CompleteTypeDetail is + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given CompleteTypeDetail is * inconsistent (only in Debug build mode). * @return const CompleteAliasHeader instance. */ @@ -1214,7 +1214,7 @@ class TypeObjectUtils * @param[in] alias_flags Alias type flags: unused. No flags apply. It must be zero. * @param[in] header CompleteAliasHeader. * @param[in] body CompleteAliasBody. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Any alias type flag is set. * 2. Inconsistent header and/or body (only in Debug build mode). * @return const CompleteAliasType instance. @@ -1235,9 +1235,9 @@ class TypeObjectUtils * * @param[in] ann_builtin Applied builtin member annotations: unit, max, min, range, hashid * @param[in] ann_custom Applied custom annotations - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. AppliedAnnotationSeq is inconsistent (only Debug build mode). - * 2. @hashid builtin annotation is applied. + * 2. hashid builtin annotation is applied. * @return const CompleteElementDetail instance. */ FASTDDS_EXPORTED_API static const CompleteElementDetail build_complete_element_detail( @@ -1249,7 +1249,7 @@ class TypeObjectUtils * * @param[in] element_flags CollectionElementFlag. * @param[in] type TypeIdentifier. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given collection element flags are not consistent (only in Debug build mode). * 2. Given TypeIdentifier is not consistent (only in Debug build mode). * @return const CommonCollectionElement instance @@ -1263,7 +1263,7 @@ class TypeObjectUtils * * @param[in] common CommonCollectionElement. * @param[in] detail CompleteElementDetail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonCollectionElement is not consistent (only in Debug build mode). * 2. Given CompleteElementDetail is not consistent (only in Debug build mode). * @return const CompleteCollectionElement instance @@ -1280,7 +1280,7 @@ class TypeObjectUtils * @brief Build CommonCollectionHeader instance. * * @param[in] bound Collection bound. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given bound is not + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given bound is not * consistent. * @return const CommonCollectionHeader instance. */ @@ -1292,7 +1292,7 @@ class TypeObjectUtils * * @param[in] common CommonCollectionHeader * @param[in] detail CompleteTypeDetail - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonCollectionHeader is inconsistent (only in Debug build mode). * 2. Given CompleteTypeDetail is inconsistent (only in Debug build mode). * @return const CompleteCollectionHeader instance. @@ -1313,7 +1313,7 @@ class TypeObjectUtils * @param[in] collection_flag collection type flag: unused. No flags apply. It must be 0. * @param[in] header CompleteCollectionHeader. * @param[in] element CompleteCollectionElement. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Any collection flag is set. * 2. Given header is inconsistent (only in Debug build mode). * 3. Given element is inconsistent (only in Debug build mode). @@ -1334,7 +1334,7 @@ class TypeObjectUtils * @brief Build CommonArrayHeader instance. * * @param[in] bound_seq Sequence of the dimension's bounds. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if any given bound is 0 (invalid). + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if any given bound is 0 (invalid). * @return const CommonArrayHeader instance. */ FASTDDS_EXPORTED_API static const CommonArrayHeader build_common_array_header( @@ -1345,7 +1345,7 @@ class TypeObjectUtils * * @param[in] common CommonArrayHeader. * @param[in] detail CompleteTypeDetail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonArrayHeader is inconsistent (only in Debug build mode). * 2. Given CompleteTypeDetail is inconsistent (only in Debug build mode). * @return const CompleteArrayHeader instance. @@ -1364,7 +1364,7 @@ class TypeObjectUtils * @param[in] collection_flag collection type flag: unused. No flags apply. It must be 0. * @param[in] header CompleteArrayHeader. * @param[in] element CompleteCollectionElement. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Any collection flag is set. * 2. Given header is inconsistent (only in Debug build mode). * 3. Given element is inconsistent (only in Debug build mode). @@ -1388,7 +1388,7 @@ class TypeObjectUtils * @param[in] header CompleteArrayHeader. * @param[in] key CompleteCollectionElement describing map key. * @param[in] element CompleteCollectionElement describing map element. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Any collection flag is set. * 2. Given header is inconsistent (only in Debug build mode). * 3. Given key TypeIdentifier is inconsistent. @@ -1413,7 +1413,7 @@ class TypeObjectUtils * * @param[in] value Enumerated literal value. * @param[in] flags Enumerated literal flags: only default flag apply. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if any other flag different from + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if any other flag different from * default is set (only in Debug build mode). * @return const CommonEnumeratedLiteral instance. */ @@ -1426,7 +1426,7 @@ class TypeObjectUtils * * @param[in] common CommonEnumeratedLiteral. * @param[in] detail CompleteMemberDetail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonEnumeratedLiteral is inconsistent (only in Debug build mode). * 2. Given CompleteMemberDetail is inconsistent (only in Debug build mode). * @return const CompleteEnumeratedLiteral instance. @@ -1440,7 +1440,7 @@ class TypeObjectUtils * * @param[in] sequence Sequence to be modified. * @param[in out] enum_literal CompleteEnumeratedLiteral to be added. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonEnumeratedLiteral is not consistent (only in Debug build mode). * 2. There is already another literal in the sequence with the same value or the same member name * (only in Debug build mode). @@ -1457,10 +1457,10 @@ class TypeObjectUtils * @brief Build CommonEnumeratedHeader instance. * * @param[in] bit_bound XTypes v1.3 Clause 7.3.1.2.1.5 It is important to note that the value member of the - * [@bit_bound] annotation may take any value from 1 to 32, inclusive, when this annotation is + * [bit_bound] annotation may take any value from 1 to 32, inclusive, when this annotation is * applied to an enumerated type. * @param[in] bitmask Flag in case that the header being built corresponds to a Bitmask. By default is false. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given bit_bound is not + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given bit_bound is not * consistent. * @return const CommonEnumeratedHeader instance. */ @@ -1475,7 +1475,7 @@ class TypeObjectUtils * @param[in] detail CompleteTypeDetail. * @param[in] bitmask flag set if the given header corresponds to a bitmask. Only required in Debug build mode. * Set to false by default. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonEnumeratedHeader is inconsistent (only in Debug build mode). * 2. Given CompleteTypeDetail is inconsistent (only in Debug build mode). * @return const CompleteEnumeratedHeader instance. @@ -1495,7 +1495,7 @@ class TypeObjectUtils * @param[in] enum_flags Enumeration flags: unused. No flags apply. It must be 0. * @param[in] header CompleteEnumeratedHeader. * @param[in] literal_seq Sequence of CompleteEnumeratedLiterals. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Any flag is set. * 2. Given CompleteEnumeratedHeader is inconsistent (only in Debug build mode). * 3. Given CompleteEnumeratedLiteralSeq is inconsistent (only in Debug build mode). @@ -1517,7 +1517,7 @@ class TypeObjectUtils * * @param[in] position Bit position in the bitmask. * @param[in] flags Bit flags: unused. No flags apply. It must be 0. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. any given flag is set. * 2. given position is inconsistent. XTypes v1.3 Clause 7.2.2.4.1.2 Each bit in this subset is * identified by name and by an index, numbered from 0 to (bound-1). The bound must be greater than @@ -1533,7 +1533,7 @@ class TypeObjectUtils * * @param[in] common CommonBitflag. * @param[in] detail CompleteMemberDetail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonBitflag is inconsistent (only in Debug build mode). * 2. Given CompleteMemberDetail is inconsistent (only in Debug build mode). * 3. Non-applicable builtin annotations applied. @@ -1548,7 +1548,7 @@ class TypeObjectUtils * * @param[in out] sequence Sequence to be modified. * @param[in] bitflag CompleteBitflag to be added. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given bitflag is inconsistent (only in Debug build mode). * 2. There is already another bitflag in the sequence with the same position or the same name * (only in Debug build mode). @@ -1573,7 +1573,7 @@ class TypeObjectUtils * @param[in] bitmask_flags Bitmask flags: unused. No flags apply. It must be 0. * @param[in] header CompleteBitmaskHeader/CompleteEnumeratedHeader * @param[in] flag_seq Sequence of CompleteBitflag. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. any given flag is set. * 2. Given header is inconsistent (only in Debug build mode). * 3. Given Bitflag sequence is inconsistent (only in Debug build mode). @@ -1591,12 +1591,12 @@ class TypeObjectUtils * * @param[in] position Bitfield starting position bit. * @param[in] flags Bitfield flags: unused. No flags apply. It must be 0. - * @param[in] bitcount Bitfield number of bits. IDL v4.2 Clause 7.4.13.4.3.2 The first one () is + * @param[in] bitcount Bitfield number of bits. IDL v4.2 Clause 7.4.13.4.3.2 The first one (positive_int_const) is * the number of bits that can be stored (its [bitfield] size). The maximum value is 64. * @param[in] holder_type Type used to manipulate the bitfield. IDL v4.2 Clause 7.4.13.4.3.2 The second optional one - * () specifies the type that will be used to manipulate the bit field as a + * (destination_type) specifies the type that will be used to manipulate the bit field as a * whole. This type can be boolean, octet or any integer type either signed or unsigned. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given position is not consistent. * 2. Any flag is set. * 3. Given bitcount is not consistent. @@ -1614,7 +1614,7 @@ class TypeObjectUtils * * @param[in] common CommonBitfield. * @param[in] detail CompleteMemberDetail. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given CommonBitfield is inconsistent (only Debug build mode). * 2. Give CompleteMemberDetail is inconsistent (only Debug build mode). * 3. Non-applicable builtin annotations are applied. @@ -1629,7 +1629,7 @@ class TypeObjectUtils * * @param[in out] sequence Sequence to be modified. * @param[in] bitfield CompleteBitfield to be added. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Given bitfield is inconsistent (only in Debug build mode). * 2. There is another bitfield with the same name and/or the same position. */ @@ -1645,7 +1645,7 @@ class TypeObjectUtils * @brief Build CompleteBitsetHeader instance. * * @param[in] detail CompleteTypeDetail - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given CompleteTypeDetail is + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given CompleteTypeDetail is * inconsistent (only in Debug build mode). * @return const CompleteBitsetHeader instance. */ @@ -1662,7 +1662,7 @@ class TypeObjectUtils * @param[in] bitset_flags Bitset flags: unused. No flags apply. It must be 0. * @param[in] header CompleteBitsetHeader. * @param[in] field_seq Sequence of complete bitfields. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if: + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if: * 1. Any given flag is set. * 2. Given header is inconsistent (only in Debug build mode). * 3. Given bitfield sequence is inconsistent (only in Debug build mode). @@ -1692,7 +1692,7 @@ class TypeObjectUtils * * @param[in] alias_type CompleteAliasType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1709,7 +1709,7 @@ class TypeObjectUtils * * @param[in] annotation_type CompleteAnnotationType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1726,7 +1726,7 @@ class TypeObjectUtils * * @param[in] struct_type CompleteStructType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1743,7 +1743,7 @@ class TypeObjectUtils * * @param[in] union_type CompleteUnionType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1760,7 +1760,7 @@ class TypeObjectUtils * * @param[in] bitset_type CompleteBitsetType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1777,7 +1777,7 @@ class TypeObjectUtils * * @param[in] sequence_type CompleteSequenceType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1794,7 +1794,7 @@ class TypeObjectUtils * * @param[in] array_type CompleteArrayType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1811,7 +1811,7 @@ class TypeObjectUtils * * @param[in] map_type CompleteMapType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1828,7 +1828,7 @@ class TypeObjectUtils * * @param[in] enumerated_type CompleteEnumeratedType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -1845,7 +1845,7 @@ class TypeObjectUtils * * @param[in] bitmask_type CompleteBitmaskType. * @param[in] type_name Name to be registered in the registry. - * @exception eprosima::fastdds::dds::xtypesv1_3::InvalidArgumentError exception if the given type is inconsistent + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given type is inconsistent * (only in Debug build mode). * @return ReturnCode_t RETCODE_OK if correctly registered in TypeObjectRegistry. * RETCODE_BAD_PARAMETER if there is already another different TypeObject registered with @@ -2248,7 +2248,7 @@ class TypeObjectUtils /** * @brief Check direct hash TypeIdentifier consistency. * - * @param[in] equivalence_hash Instance to be checked. + * @param[in] type_id Instance to be checked. * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given TypeIdentifier is * not consistent. */ @@ -2258,7 +2258,7 @@ class TypeObjectUtils /** * @brief Check TypeIdentifier consistency. * - * @param[in] plain_map Instance to be checked. + * @param[in] type_identifier Instance to be checked. * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given TypeIdentifier is * not consistent. */ @@ -2340,7 +2340,7 @@ class TypeObjectUtils * * @param[in] common_struct_member CommonStructMember to be checked. * @param[in] complete_member_detail CompleteMemberDetail to be checked. - * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the @hashid builtin applied + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the hashid builtin applied * annotation is set and inconsistent with the member id. */ static void common_struct_member_and_complete_member_detail_consistency( @@ -2351,7 +2351,7 @@ class TypeObjectUtils * @brief Check consistency between a string value and the MemberId (algorithm XTypes v1.3 Clause 7.3.1.2.1.1) * * @param[in] member_id MemberId to be checked. - * @param[in] string_value String provided with either @hashid annotation or the member name. + * @param[in] string_value String provided with either hashid annotation or the member name. * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given data is inconsistent. */ static void string_member_id_consistency( @@ -2461,9 +2461,9 @@ class TypeObjectUtils /** * @brief Check cross-consistency between CommonStructMember and CompleteMemberDetail. * - * @param[in] common_struct_member CommonStructMember to be checked. + * @param[in] common_union_member CommonStructMember to be checked. * @param[in] complete_member_detail CompleteMemberDetail to be checked. - * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the @hashid builtin annotation is + * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the hashid builtin annotation is * set and the member id is not consistent. */ static void common_union_member_complete_member_detail_consistency( @@ -2633,7 +2633,7 @@ class TypeObjectUtils const CommonAliasBody& common_alias_body); /** - * @brief Check that @hashid builtin annotation has not been set. + * @brief Check that hashid builtin annotation has not been set. * * @param[in] ann_builtin Instance to be checked. * @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp index 4da6e9e22b1..4cccc9b041e 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp @@ -216,7 +216,7 @@ const PlainCollectionHeader TypeObjectUtils::build_plain_collection_header( const PlainSequenceSElemDefn TypeObjectUtils::build_plain_sequence_s_elem_defn( const PlainCollectionHeader& header, - SBound bound, + SBound s_bound, const eprosima::fastcdr::external& element_identifier) { #if !defined(NDEBUG) @@ -226,25 +226,25 @@ const PlainSequenceSElemDefn TypeObjectUtils::build_plain_sequence_s_elem_defn( plain_collection_type_identifier_header_consistency(header, *element_identifier); PlainSequenceSElemDefn plain_sequence_s_elem_defn; plain_sequence_s_elem_defn.header(header); - plain_sequence_s_elem_defn.bound(bound); + plain_sequence_s_elem_defn.bound(s_bound); plain_sequence_s_elem_defn.element_identifier(element_identifier); return plain_sequence_s_elem_defn; } const PlainSequenceLElemDefn TypeObjectUtils::build_plain_sequence_l_elem_defn( const PlainCollectionHeader& header, - LBound bound, + LBound l_bound, const eprosima::fastcdr::external& element_identifier) { #if !defined(NDEBUG) plain_collection_header_consistency(header); type_identifier_consistency(*element_identifier); #endif // !defined(NDEBUG) - l_bound_consistency(bound); + l_bound_consistency(l_bound); plain_collection_type_identifier_header_consistency(header, *element_identifier); PlainSequenceLElemDefn plain_sequence_l_elem_defn; plain_sequence_l_elem_defn.header(header); - plain_sequence_l_elem_defn.bound(bound); + plain_sequence_l_elem_defn.bound(l_bound); plain_sequence_l_elem_defn.element_identifier(element_identifier); return plain_sequence_l_elem_defn; } From 61ace277011f24d173e58dcad254aaebf01ce679 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 21 Mar 2024 08:52:48 +0100 Subject: [PATCH 25/35] Refs #20160: Fix for LOG macro. Remove consistency check from register_type_object(from TypeLookupManager). Signed-off-by: adriancampo --- include/fastdds/dds/log/Log.hpp | 51 ++++++++++--------- .../fastdds/rtps/security/logging/Logging.h | 10 ++-- .../TypeLookupReplyListener.cpp | 1 - .../TypeObjectRegistry.cpp | 11 +--- 4 files changed, 32 insertions(+), 41 deletions(-) diff --git a/include/fastdds/dds/log/Log.hpp b/include/fastdds/dds/log/Log.hpp index 9f2cc0f819a..51c9bb68b02 100644 --- a/include/fastdds/dds/log/Log.hpp +++ b/include/fastdds/dds/log/Log.hpp @@ -282,17 +282,18 @@ class LogConsumer // Name of variables inside macros must be unique, or it could produce an error with external variables #if !HAVE_LOG_NO_ERROR -#define EPROSIMA_LOG_ERROR_IMPL_(cat, msg) \ +#define EPROSIMA_LOG_ERROR_IMPL_(cat, msg) \ do { \ - using namespace eprosima::fastdds::dds; \ std::stringstream fastdds_log_ss_tmp__; \ fastdds_log_ss_tmp__ << msg; \ - Log::QueueLog(fastdds_log_ss_tmp__.str(), Log::Context{__FILE__, __LINE__, __func__, #cat}, Log::Kind::Error); \ + eprosima::fastdds::dds::Log::QueueLog( \ + fastdds_log_ss_tmp__.str(), eprosima::fastdds::dds::Log::Context{__FILE__, __LINE__, __func__, #cat}, \ + eprosima::fastdds::dds::Log::Kind::Error); \ } while (0) #elif (__INTERNALDEBUG || _INTERNALDEBUG) -#define EPROSIMA_LOG_ERROR_IMPL_(cat, msg) \ +#define EPROSIMA_LOG_ERROR_IMPL_(cat, msg) \ do { \ auto fastdds_log_lambda_tmp__ = [&]() \ { \ @@ -312,21 +313,21 @@ class LogConsumer ***********/ #if !HAVE_LOG_NO_WARNING -#define EPROSIMA_LOG_WARNING_IMPL_(cat, msg) \ - do { \ - using namespace eprosima::fastdds::dds; \ - if (Log::GetVerbosity() >= Log::Kind::Warning) \ - { \ - std::stringstream fastdds_log_ss_tmp__; \ - fastdds_log_ss_tmp__ << msg; \ - Log::QueueLog( \ - fastdds_log_ss_tmp__.str(), Log::Context{__FILE__, __LINE__, __func__, #cat}, Log::Kind::Warning); \ - } \ +#define EPROSIMA_LOG_WARNING_IMPL_(cat, msg) \ + do { \ + if (eprosima::fastdds::dds::Log::GetVerbosity() >= eprosima::fastdds::dds::Log::Kind::Warning) \ + { \ + std::stringstream fastdds_log_ss_tmp__; \ + fastdds_log_ss_tmp__ << msg; \ + eprosima::fastdds::dds::Log::QueueLog( \ + fastdds_log_ss_tmp__.str(), eprosima::fastdds::dds::Log::Context{__FILE__, __LINE__, __func__, #cat}, \ + eprosima::fastdds::dds::Log::Kind::Warning); \ + } \ } while (0) #elif (__INTERNALDEBUG || _INTERNALDEBUG) -#define EPROSIMA_LOG_WARNING_IMPL_(cat, msg) \ +#define EPROSIMA_LOG_WARNING_IMPL_(cat, msg) \ do { \ auto fastdds_log_lambda_tmp__ = [&]() \ { \ @@ -351,16 +352,16 @@ class LogConsumer ((defined(__INTERNALDEBUG) || defined(_INTERNALDEBUG)) && (defined(_DEBUG) || defined(__DEBUG) || \ !defined(NDEBUG)))) -#define EPROSIMA_LOG_INFO_IMPL_(cat, msg) \ - do { \ - using namespace eprosima::fastdds::dds; \ - if (Log::GetVerbosity() >= Log::Kind::Info) \ - { \ - std::stringstream fastdds_log_ss_tmp__; \ - fastdds_log_ss_tmp__ << msg; \ - Log::QueueLog(fastdds_log_ss_tmp__.str(), Log::Context{__FILE__, __LINE__, __func__, #cat}, \ - Log::Kind::Info); \ - } \ +#define EPROSIMA_LOG_INFO_IMPL_(cat, msg) \ + do { \ + if (eprosima::fastdds::dds::Log::GetVerbosity() >= eprosima::fastdds::dds::Log::Kind::Info) \ + { \ + std::stringstream fastdds_log_ss_tmp__; \ + fastdds_log_ss_tmp__ << msg; \ + eprosima::fastdds::dds::Log::QueueLog( \ + fastdds_log_ss_tmp__.str(), eprosima::fastdds::dds::Log::Context{__FILE__, __LINE__, __func__, #cat}, \ + eprosima::fastdds::dds::Log::Kind::Info); \ + } \ } while (0) #elif (__INTERNALDEBUG || _INTERNALDEBUG) diff --git a/include/fastdds/rtps/security/logging/Logging.h b/include/fastdds/rtps/security/logging/Logging.h index 51ccbc1658b..7e684b4faad 100644 --- a/include/fastdds/rtps/security/logging/Logging.h +++ b/include/fastdds/rtps/security/logging/Logging.h @@ -243,22 +243,22 @@ bool Logging::compose_header( MESSAGE, \ std::string(CLASS ",") + __func__, \ EXCEPTION); \ - } \ - else { \ + } \ + else { \ switch (LEVEL){ \ case LoggingLevel::EMERGENCY_LEVEL: \ case LoggingLevel::ALERT_LEVEL: \ case LoggingLevel::CRITICAL_LEVEL: \ case LoggingLevel::ERROR_LEVEL: \ - EPROSIMA_LOG_ERROR(SECURITY, MESSAGE); \ + EPROSIMA_LOG_ERROR(SECURITY, MESSAGE); \ break; \ case LoggingLevel::WARNING_LEVEL: \ - EPROSIMA_LOG_WARNING(SECURITY, MESSAGE); \ + EPROSIMA_LOG_WARNING(SECURITY, MESSAGE); \ break; \ case LoggingLevel::NOTICE_LEVEL: \ case LoggingLevel::INFORMATIONAL_LEVEL: \ case LoggingLevel::DEBUG_LEVEL: \ - EPROSIMA_LOG_INFO(SECURITY, MESSAGE); \ + EPROSIMA_LOG_INFO(SECURITY, MESSAGE); \ break; \ } \ } \ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 208af1e4868..92ac0ecf306 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -18,7 +18,6 @@ */ #include - #include #include diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp index 8c45154ec1d..c7996974316 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp @@ -73,7 +73,7 @@ ReturnCode_t TypeObjectRegistry::register_type_object( auto type_ids_result = local_type_identifiers_.insert({type_name, type_ids}); auto min_entry_result = type_registry_entries_.insert({type_ids.type_identifier1(), minimal_entry}); auto max_entry_result = type_registry_entries_.insert({type_ids.type_identifier2(), complete_entry}); - if (!type_ids_result.second || !min_entry_result.second || !max_entry_result.second) + if (!type_ids_result.second || !max_entry_result.second) { if (local_type_identifiers_[type_name] != type_ids || type_registry_entries_[type_ids.type_identifier1()] != minimal_entry || @@ -438,15 +438,6 @@ ReturnCode_t TypeObjectRegistry::register_type_object( const TypeObject& type_object) { uint32_t type_object_serialized_size = 0; - try - { - TypeObjectUtils::type_object_consistency(type_object); - } - catch (const InvalidArgumentError& exception) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Inconsistent CompleteTypeObject: " << exception.what()); - return eprosima::fastdds::dds::RETCODE_PRECONDITION_NOT_MET; - } if (type_identifier._d() != type_object._d() || type_identifier != calculate_type_identifier(type_object, type_object_serialized_size)) { From 1bba30b7ecf46d77e8c45fcd3f87d47781b9064e Mon Sep 17 00:00:00 2001 From: adriancampo Date: Tue, 26 Mar 2024 13:04:10 +0100 Subject: [PATCH 26/35] Refs #20160: Applied suggestions. Signed-off-by: adriancampo --- .../dds/xtypes/dynamic_types/DynamicType.hpp | 4 +- .../dynamic_types/DynamicTypeBuilder.hpp | 2 +- .../DynamicTypeBuilderFactory.hpp | 4 +- .../dynamic_types/DynamicTypeMember.hpp | 2 +- .../xtypes/dynamic_types/TypeDescriptor.hpp | 2 +- .../type_lookup_service/TypeLookupManager.cpp | 89 +++++++++++++------ .../type_lookup_service/TypeLookupManager.hpp | 8 +- .../TypeLookupReplyListener.cpp | 11 +-- .../TypeLookupRequestListener.cpp | 16 ++-- .../TypeObjectRegistry.cpp | 2 +- .../TypeObjectRegistry.hpp | 4 +- .../rtps/builtin/discovery/endpoint/EDP.cpp | 8 ++ test/dds/communication/CMakeLists.txt | 80 +++++++++-------- test/dds/communication/PublisherDynamic.cpp | 7 +- test/unittest/rtps/discovery/EdpTests.cpp | 2 + 15 files changed, 149 insertions(+), 92 deletions(-) diff --git a/include/fastdds/dds/xtypes/dynamic_types/DynamicType.hpp b/include/fastdds/dds/xtypes/dynamic_types/DynamicType.hpp index 324fe13a0e7..f9082159f40 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/DynamicType.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/DynamicType.hpp @@ -60,7 +60,7 @@ class DynamicType : public std::enable_shared_from_this /*! * Returns the member that corresponds to the specified name. * @param[inout] member @ref DynamicTypeMember reference used to return the reference to the member. - * @param[in] name the name of the member. + * @param[in] name Member name of the member being queried. * @return @ref ReturnCode_t * @retval RETCODE_OK when the member was found. * @retval RETCODE_BAD_PARAMETER when the member doesn't exist. @@ -155,7 +155,7 @@ class DynamicType : public std::enable_shared_from_this /** * State comparison according with the [standard] sections \b 7.5.2.8.4 - * @param[in] other DynamicType reference to compare to + * @param[in] other @ref DynamicType reference to compare to * @return \b bool `true` on equality */ FASTDDS_EXPORTED_API virtual bool equals( diff --git a/include/fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp b/include/fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp index ad71893873e..dcda644b415 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp @@ -165,7 +165,7 @@ class DynamicTypeBuilder : public std::enable_shared_from_this::ref_type create_array_type( @@ -148,7 +148,7 @@ class DynamicTypeBuilderFactory : public std::enable_shared_from_this /** * State comparison according with the [standard] sections \b 7.5.2.6.3 - * @param[in] other DynamicTypeMember reference to compare to + * @param[in] other @ref DynamicTypeMember reference to compare to * @return \b bool `true` on equality */ FASTDDS_EXPORTED_API virtual bool equals( diff --git a/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp b/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp index be43457e6d1..69dc4fbe4c5 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp @@ -215,7 +215,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor /*! * Mofifies the is_nested property. - * @param[in] is_nested + * @param[in] is_nested Boolean value to be set. */ virtual void is_nested( bool is_nested) = 0; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 8427d0a1f5f..c103d77e151 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -482,6 +482,8 @@ bool TypeLookupManager::remove_async_get_type_request( bool TypeLookupManager::create_endpoints() { + bool ret = true; + const RTPSParticipantAttributes& pattr = participant_->getRTPSParticipantAttributes(); // Built-in history attributes. @@ -514,10 +516,10 @@ bool TypeLookupManager::create_endpoints() ratt.endpoint.reliabilityKind = fastrtps::rtps::RELIABLE; ratt.endpoint.durabilityKind = fastrtps::rtps::VOLATILE; - request_listener_ = new TypeLookupRequestListener(this); - // Built-in request writer + request_listener_ = new TypeLookupRequestListener(this); builtin_request_writer_history_ = new WriterHistory(hatt); + RTPSWriter* req_writer; if (participant_->createWriter( &req_writer, @@ -533,15 +535,16 @@ bool TypeLookupManager::create_endpoints() else { EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup request writer creation failed."); - delete builtin_request_writer_history_; - builtin_request_writer_history_ = nullptr; - delete request_listener_; - request_listener_ = nullptr; - return false; + ret = false; } // Built-in request reader + if (nullptr == request_listener_) + { + request_listener_ = new TypeLookupRequestListener(this); + } builtin_request_reader_history_ = new ReaderHistory(hatt); + RTPSReader* req_reader; if (participant_->createReader( &req_reader, @@ -557,17 +560,13 @@ bool TypeLookupManager::create_endpoints() else { EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup request reader creation failed."); - delete builtin_request_reader_history_; - builtin_request_reader_history_ = nullptr; - delete request_listener_; - request_listener_ = nullptr; - return false; + ret = false; } - reply_listener_ = new TypeLookupReplyListener(this); - // Built-in reply writer + reply_listener_ = new TypeLookupReplyListener(this); builtin_reply_writer_history_ = new WriterHistory(hatt); + RTPSWriter* rep_writer; if (participant_->createWriter( &rep_writer, @@ -583,15 +582,16 @@ bool TypeLookupManager::create_endpoints() else { EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup reply writer creation failed."); - delete builtin_reply_writer_history_; - builtin_reply_writer_history_ = nullptr; - delete reply_listener_; - reply_listener_ = nullptr; - return false; + ret = false; } // Built-in reply reader + if (nullptr == reply_listener_) + { + reply_listener_ = new TypeLookupReplyListener(this); + } builtin_reply_reader_history_ = new ReaderHistory(hatt); + RTPSReader* rep_reader; if (participant_->createReader( &rep_reader, @@ -607,14 +607,49 @@ bool TypeLookupManager::create_endpoints() else { EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup reply reader creation failed."); - delete builtin_reply_reader_history_; - builtin_reply_reader_history_ = nullptr; - delete reply_listener_; - reply_listener_ = nullptr; - return false; + ret = false; } - return true; + // Clean up if something failed. + if (!ret) + { + if (nullptr != builtin_request_writer_history_) + { + delete builtin_request_writer_history_; + builtin_request_writer_history_ = nullptr; + } + + if (nullptr != builtin_reply_writer_history_) + { + delete builtin_reply_writer_history_; + builtin_reply_writer_history_ = nullptr; + } + + if (nullptr != builtin_request_reader_history_) + { + delete builtin_request_reader_history_; + builtin_request_reader_history_ = nullptr; + } + + if (nullptr != builtin_reply_reader_history_) + { + delete builtin_reply_reader_history_; + builtin_reply_reader_history_ = nullptr; + } + + if (nullptr != request_listener_) + { + delete request_listener_; + request_listener_ = nullptr; + } + if (nullptr != reply_listener_) + { + delete reply_listener_; + reply_listener_ = nullptr; + } + } + + return ret; } TypeLookup_Request* TypeLookupManager::create_request( @@ -724,8 +759,8 @@ bool TypeLookupManager::receive( return false; } - //Compare only the guid.guidPrefix - if ((request.header().instanceName().to_string()).substr(0, 24) != local_instance_name_.substr(0, 24)) + //Compare only the "dds.builtin.TOS." + guid.guidPrefix + if ((request.header().instanceName().to_string()).substr(0, 40) != local_instance_name_.substr(0, 40)) { // Ignore request return false; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp index c4217bdd808..a9b90c92bb3 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_SERVICE_MANAGER_HPP_ -#define _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_SERVICE_MANAGER_HPP_ +#ifndef _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_MANAGER_HPP_ +#define _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_MANAGER_HPP_ #include #include @@ -248,7 +248,7 @@ class TypeLookupManager SampleIdentity request); /** - * Creates a TypeLookup_Request with for the given type_server. + * Creates a TypeLookup_Request for the given type_server. * @param type_server[in] GUID corresponding to the remote participant. * @param pupsubtype[out] PubSubType in charge of TypeLookup_Request . * @return the TypeLookup_Request created. @@ -442,4 +442,4 @@ class TypeLookupManager } /* namespace dds */ } /* namespace fastdds */ } /* namespace eprosima */ -#endif /* _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_SERVICE_MANAGER_HPP_ */ +#endif /* _FASTDDS_BUILTIN_TYPE_LOOKUP_SERVICE_TYPE_LOOKUP_MANAGER_HPP_ */ diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 92ac0ecf306..8823824099e 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -18,6 +18,7 @@ */ #include + #include #include @@ -148,24 +149,24 @@ void TypeLookupReplyListener::check_get_types_reply( { // If any of the types is not registered, log error EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REPLY_LISTENER, - "Error registering type: the discriminators differ"); + "Error registering remote type"); register_result = RETCODE_ERROR; } } if (RETCODE_OK == register_result) { - // Check if this reply requires a continuation_point + // Check if the get_type_dependencies related to this reply required a continuation_point std::unique_lock guard(replies_with_continuation_mutex_); auto it = std::find(replies_with_continuation_.begin(), replies_with_continuation_.end(), related_request); if (it != replies_with_continuation_.end()) { - // If it does, remove it from the list and continue + // If it did, remove it from the list and continue replies_with_continuation_.erase(it); } else { - // If it does not, check that the type that originated the request is consistent + // If it did not, check that the type that originated the request is consistent // before notifying the callbacks associated with the request try { @@ -179,7 +180,7 @@ void TypeLookupReplyListener::check_get_types_reply( catch (const std::exception& exception) { EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE_REPLY_LISTENER, - "Error registering type: " << exception.what()); + "Error registering remote type: " << exception.what()); } } } diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index a923bb7a64d..608ac76f5f9 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -239,13 +239,15 @@ void TypeLookupRequestListener::check_get_types_request( else if (RETCODE_NO_DATA == type_result) { // Log error for type not found and reply with appropriate exception - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "TypeIdentifier is not found in the registry."); + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, + "Requested TypeIdentifier is not found in the registry."); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION); } else if (RETCODE_PRECONDITION_NOT_MET == type_result) { // Log error for invalid argument and reply with appropriate exception - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "TypeIdentifier is not a direct hash."); + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, + "Requested TypeIdentifier is not a direct hash."); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT); } } @@ -265,7 +267,7 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( auto requests_it = requests_with_continuation_.find(request.type_ids()); if (requests_it != requests_with_continuation_.end()) { - // Get the dependencies without chechking the registry + // Get the dependencies without checking the registry type_dependencies = requests_it->second; type_dependencies_result = RETCODE_OK; } @@ -273,7 +275,7 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( { // If the the received request is not found, log error and answer with exception EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, - "Error processing ongoing type dependencies."); + "Error processing ongoing type dependencies request."); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION); } } @@ -303,13 +305,15 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( else if (RETCODE_NO_DATA == type_dependencies_result) { // Log error for type not found and reply with appropriate exception - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "TypeIdentifier is not found in the registry."); + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, + "Requested TypeIdentifier is not found in the registry."); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_UNKNOWN_EXCEPTION); } else if (RETCODE_BAD_PARAMETER == type_dependencies_result) { // Log error for invalid argument and reply with appropriate exception - EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, "TypeIdentifier is not a direct hash."); + EPROSIMA_LOG_WARNING(TYPELOOKUP_SERVICE_REQUEST_LISTENER, + "Requested TypeIdentifier is not a direct hash."); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_INVALID_ARGUMENT); } } diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp index c7996974316..77449f34bd9 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp @@ -697,7 +697,7 @@ const TypeIdentifier TypeObjectRegistry::get_complementary_type_identifier( { return it.second.type_identifier2(); } - else if (it.second.type_identifier2() == type_id && TK_NONE != it.second.type_identifier1()._d()) + else if (it.second.type_identifier2() == type_id || TK_NONE == it.second.type_identifier2()._d()) { return it.second.type_identifier1(); } diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp index 0b2f0fee065..6a65a476d53 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp @@ -227,6 +227,9 @@ class TypeObjectRegistry : public ITypeObjectRegistry * @brief Register a remote TypeObject. * This auxiliary method might register only the minimal TypeObject and TypeIdentifier or register both * TypeObjects constructing the minimal from the complete TypeObject information. + * TypeObject consistency is not checked in this method as the order of the dependencies received by the + * TypeLookupService is not guaranteed. + * The consistency is checked by the TypeLookupService after all denpendencies are registered * * @pre TypeIdentifier discriminator must match TypeObject discriminator. * TypeIdentifier consistency is only checked in Debug build mode. @@ -237,7 +240,6 @@ class TypeObjectRegistry : public ITypeObjectRegistry * RETCODE_PRECONDITION_NOT_MET if the discriminators differ. * RETCODE_PRECONDITION_NOT_MET if the TypeIdentifier is not consistent with the given * TypeObject. - * RETCODE_PRECONDITION_NOT_MET if the given TypeObject is not consistent. */ ReturnCode_t register_type_object( const TypeIdentifier& type_identifier, diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 714b7f51f81..67c4a9657c6 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -584,6 +584,14 @@ bool EDP::valid_matching( return false; } } + else + { + if (wdata->typeName() != rdata->typeName()) + { + reason.set(MatchingFailureMask::inconsistent_topic); + return false; + } + } if (wdata->topicKind() != rdata->topicKind()) { diff --git a/test/dds/communication/CMakeLists.txt b/test/dds/communication/CMakeLists.txt index 6aac5677baa..ee6ec3d8312 100644 --- a/test/dds/communication/CMakeLists.txt +++ b/test/dds/communication/CMakeLists.txt @@ -25,26 +25,27 @@ include_directories(${Asio_INCLUDE_DIR}) # Binaries ############################################################################### -# Dynamic types test -set(DDS_PUBLISHER_DYNAMIC_SOURCE - PublisherDynamic.cpp - ) -add_executable(DDSSimpleCommunicationDynamicPublisher ${DDS_PUBLISHER_DYNAMIC_SOURCE}) -target_compile_definitions(DDSSimpleCommunicationDynamicPublisher PRIVATE - $<$>,$>:__DEBUG> - $<$:__INTERNALDEBUG> # Internal debug activated. - ) -target_link_libraries(DDSSimpleCommunicationDynamicPublisher fastdds fastcdr foonathan_memory ${CMAKE_DL_LIBS}) - -set(DDS_SUBSCRIBER_DYNAMIC_SOURCE - SubscriberDynamic.cpp - ) -add_executable(DDSSimpleCommunicationDynamicSubscriber ${DDS_SUBSCRIBER_DYNAMIC_SOURCE}) -target_compile_definitions(DDSSimpleCommunicationDynamicSubscriber PRIVATE - $<$>,$>:__DEBUG> - $<$:__INTERNALDEBUG> # Internal debug activated. - ) -target_link_libraries(DDSSimpleCommunicationDynamicSubscriber fastdds fastcdr foonathan_memory ${CMAKE_DL_LIBS}) +# TODO Restore when Dynamic types are registered in TypeObjectRegistry +# # Dynamic types test +# set(DDS_PUBLISHER_DYNAMIC_SOURCE +# PublisherDynamic.cpp +# ) +# add_executable(DDSSimpleCommunicationDynamicPublisher ${DDS_PUBLISHER_DYNAMIC_SOURCE}) +# target_compile_definitions(DDSSimpleCommunicationDynamicPublisher PRIVATE +# $<$>,$>:__DEBUG> +# $<$:__INTERNALDEBUG> # Internal debug activated. +# ) +# target_link_libraries(DDSSimpleCommunicationDynamicPublisher fastdds fastcdr foonathan_memory ${CMAKE_DL_LIBS}) + +# set(DDS_SUBSCRIBER_DYNAMIC_SOURCE +# SubscriberDynamic.cpp +# ) +# add_executable(DDSSimpleCommunicationDynamicSubscriber ${DDS_SUBSCRIBER_DYNAMIC_SOURCE}) +# target_compile_definitions(DDSSimpleCommunicationDynamicSubscriber PRIVATE +# $<$>,$>:__DEBUG> +# $<$:__INTERNALDEBUG> # Internal debug activated. +# ) +# target_link_libraries(DDSSimpleCommunicationDynamicSubscriber fastdds fastcdr foonathan_memory ${CMAKE_DL_LIBS}) # Standard tests set(COMMON_SOURCE @@ -94,9 +95,10 @@ target_link_libraries(DDSCommunicationPubSub fastdds fastcdr foonathan_memory ${ ############################################################################### # Necessary files ############################################################################### -# Dynamic types test -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_communication_dynamic.py - ${CMAKE_CURRENT_BINARY_DIR}/simple_communication_dynamic.py COPYONLY) +# TODO Restore when Dynamic types are registered in TypeObjectRegistry +# # Dynamic types test +# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_communication_dynamic.py +# ${CMAKE_CURRENT_BINARY_DIR}/simple_communication_dynamic.py COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/example_type_profile.xml ${CMAKE_CURRENT_BINARY_DIR}/example_type_profile.xml COPYONLY) @@ -180,22 +182,24 @@ endif() # Tests specification ############################################################################### if(Python3_Interpreter_FOUND) - # Dynamic types test - add_test(NAME DDSSimpleCommunicationTypeDiscovery - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/simple_communication_dynamic.py) - - # Set test with label NoMemoryCheck - set_property(TEST DDSSimpleCommunicationTypeDiscovery PROPERTY LABELS "NoMemoryCheck") - set_property(TEST DDSSimpleCommunicationTypeDiscovery PROPERTY ENVIRONMENT - "DDS_SIMPLE_COMMUNICATION_PUBLISHER_BIN=$") - set_property(TEST DDSSimpleCommunicationTypeDiscovery APPEND PROPERTY ENVIRONMENT - "DDS_SIMPLE_COMMUNICATION_SUBSCRIBER_BIN=$") - if(WIN32) - string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}") - set_property(TEST DDSSimpleCommunicationTypeDiscovery APPEND PROPERTY ENVIRONMENT - "PATH=$\\;$\\;${WIN_PATH}") - endif() + # TODO Restore when Dynamic types are registered in TypeObjectRegistry + # # Dynamic types test + # add_test(NAME DDSSimpleCommunicationTypeDiscovery + # COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/simple_communication_dynamic.py) + + # # Set test with label NoMemoryCheck + # set_property(TEST DDSSimpleCommunicationTypeDiscovery PROPERTY LABELS "NoMemoryCheck") + + # set_property(TEST DDSSimpleCommunicationTypeDiscovery PROPERTY ENVIRONMENT + # "DDS_SIMPLE_COMMUNICATION_PUBLISHER_BIN=$") + # set_property(TEST DDSSimpleCommunicationTypeDiscovery APPEND PROPERTY ENVIRONMENT + # "DDS_SIMPLE_COMMUNICATION_SUBSCRIBER_BIN=$") + # if(WIN32) + # string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}") + # set_property(TEST DDSSimpleCommunicationTypeDiscovery APPEND PROPERTY ENVIRONMENT + # "PATH=$\\;$\\;${WIN_PATH}") + # endif() # Standard types test set(TEST_BUILDER ${BINARY_TEST_DIR}test_build.py) diff --git a/test/dds/communication/PublisherDynamic.cpp b/test/dds/communication/PublisherDynamic.cpp index 817e99d470b..b2a2e0e878e 100644 --- a/test/dds/communication/PublisherDynamic.cpp +++ b/test/dds/communication/PublisherDynamic.cpp @@ -245,9 +245,8 @@ int main( } DynamicType::_ref_type dyn_type; - if (RETCODE_OK != - DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("TypeLookup", - dyn_type)) + if (RETCODE_OK != DomainParticipantFactory::get_instance()-> + get_dynamic_type_builder_from_xml_by_name("TypeLookup", dyn_type)) { std::cout << "Error getting dynamic type from XML file" << std::endl; return 1; @@ -308,6 +307,7 @@ int main( data->set_uint32_value(1, 1); DynamicData::_ref_type inner {data->loan_value(2)}; inner->set_byte_value(0, 10); + data->return_loaned_value(inner); while (run) { @@ -329,6 +329,7 @@ int main( octet inner_count; inner->get_byte_value(inner_count, 0); inner->set_byte_value(0, inner_count + 1); + data->return_loaned_value(inner); std::this_thread::sleep_for(std::chrono::milliseconds(250)); } diff --git a/test/unittest/rtps/discovery/EdpTests.cpp b/test/unittest/rtps/discovery/EdpTests.cpp index 5075625579f..f092e87bbbe 100644 --- a/test/unittest/rtps/discovery/EdpTests.cpp +++ b/test/unittest/rtps/discovery/EdpTests.cpp @@ -133,6 +133,8 @@ class EdpTests : public ::testing::Test void set_incompatible_type() { rdata->typeName("AnotherTypeName"); + rdata->type_information().assigned(false); + wdata->type_information().assigned(false); } void check_expectations( From f840f9874d3e53b8da4477b1c3f232ae34e72960 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 27 Mar 2024 10:00:06 +0100 Subject: [PATCH 27/35] Refs #20160: Removed obsolete check. Signed-off-by: adriancampo --- .../builtin/type_lookup_service/TypeLookupManager.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index c103d77e151..43cf762e8e4 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -539,10 +539,6 @@ bool TypeLookupManager::create_endpoints() } // Built-in request reader - if (nullptr == request_listener_) - { - request_listener_ = new TypeLookupRequestListener(this); - } builtin_request_reader_history_ = new ReaderHistory(hatt); RTPSReader* req_reader; @@ -586,10 +582,6 @@ bool TypeLookupManager::create_endpoints() } // Built-in reply reader - if (nullptr == reply_listener_) - { - reply_listener_ = new TypeLookupReplyListener(this); - } builtin_reply_reader_history_ = new ReaderHistory(hatt); RTPSReader* rep_reader; From 0a9026a693d620f6b43d7d8fcc513b108ddf05c1 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Tue, 2 Apr 2024 18:38:23 +0200 Subject: [PATCH 28/35] Refs #20160: Fixed DS tests and warnings. Signed-off-by: adriancampo --- .../type_lookup_service/TypeLookupManager.cpp | 15 ++- .../discovery/endpoint/EDPServerListeners.cpp | 107 +++++++++++------- .../discovery/endpoint/EDPServerListeners.hpp | 8 ++ .../discovery/endpoint/EDPSimpleListeners.cpp | 19 +++- .../discovery/endpoint/EDPSimpleListeners.h | 11 +- .../discovery/participant/PDPClient.cpp | 9 +- .../discovery/participant/PDPServer.cpp | 13 ++- 7 files changed, 122 insertions(+), 60 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 43cf762e8e4..a561caaae79 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -381,6 +381,7 @@ ReturnCode_t TypeLookupManager::check_type_identifier_received( void TypeLookupManager::notify_callbacks( xtypes::TypeIdentfierWithSize type_identifier_with_size) { + bool removed = false; // Check that type is pending to be resolved auto writer_callbacks_it = async_get_type_writer_callbacks_.find(type_identifier_with_size); if (writer_callbacks_it != async_get_type_writer_callbacks_.end()) @@ -389,8 +390,7 @@ void TypeLookupManager::notify_callbacks( { proxy_callback_pair.second(proxy_callback_pair.first); } - //Erase the solved TypeIdentfierWithSize - remove_async_get_type_callback(type_identifier_with_size); + removed = true; } auto reader_callbacks_it = async_get_type_reader_callbacks_.find(type_identifier_with_size); @@ -400,6 +400,11 @@ void TypeLookupManager::notify_callbacks( { proxy_callback_pair.second(proxy_callback_pair.first); } + removed = true; + } + + if (removed) + { // Erase the solved TypeIdentfierWithSize remove_async_get_type_callback(type_identifier_with_size); } @@ -421,6 +426,7 @@ bool TypeLookupManager::add_async_get_type_request( "Error in TypeLookupManager::add_async_get_type_request: " << e.what()); return false; } + } bool TypeLookupManager::remove_async_get_type_callback( @@ -461,6 +467,7 @@ bool TypeLookupManager::remove_async_get_type_callback( "Error in TypeLookupManager::remove_async_get_type_callback: " << e.what()); return false; } + } bool TypeLookupManager::remove_async_get_type_request( @@ -803,11 +810,11 @@ std::string TypeLookupManager::get_instance_name( ss << std::hex; for (const auto& elem : guid.guidPrefix.value) { - ss << std::setw(2) << std::setfill('0') << static_cast(elem); + ss << std::setw(2) << std::setfill('0') << static_cast(static_cast(elem)); } for (const auto& elem : guid.entityId.value) { - ss << std::setw(2) << std::setfill('0') << static_cast(elem); + ss << std::setw(2) << std::setfill('0') << static_cast(static_cast(elem)); } std::string str = ss.str(); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp index 8fa05ee493e..29dd81a74d4 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp @@ -78,47 +78,56 @@ void EDPServerPUBListener::onNewCacheChangeAdded( change->writer_info.previous = nullptr; change->writer_info.num_sent_submessages = 0; - // String to store the topic of the writer - std::string topic_name = ""; // DATA(w) case: new writer or updated information about an existing writer if (change->kind == ALIVE) { + EndpointAddedCallback writer_added_callback = + std::bind(&EDPServerPUBListener::continue_with_writer, this, reader, change); + // Note: add_writer_from_change() removes the change from the EDP publications' reader history, but it does not // return it to the pool - add_writer_from_change(reader, reader_history, change, sedp_, false); + add_writer_from_change(reader, reader_history, change, sedp_, false, writer_added_callback); - // Retrieve the topic after creating the WriterProxyData (in add_writer_from_change()). This way, not matter - // whether the DATA(w) is a new one or an update, the WriterProxyData exists, and so the topic can be retrieved - auto temp_writer_data = get_pdp()->get_temporary_writer_proxies_pool().get(); - if (get_pdp()->lookupWriterProxyData(auxGUID, *temp_writer_data)) - { - topic_name = temp_writer_data->topicName().to_string(); - } + // Stop and wait for callback in case of TypeLookupService needed time to process the types + return; } // DATA(Uw) case else { EPROSIMA_LOG_INFO(RTPS_EDP_LISTENER, "Disposed Remote Writer, removing..."); - // Retrieve the topic before removing the WriterProxyData. We need it to add the DATA(Uw) to the database - auto temp_writer_data = get_pdp()->get_temporary_writer_proxies_pool().get(); - if (get_pdp()->lookupWriterProxyData(auxGUID, *temp_writer_data)) - { - topic_name = temp_writer_data->topicName().to_string(); - } - else - { - EPROSIMA_LOG_WARNING(RTPS_EDP_LISTENER, "Writer Proxy Data missing for change " << auxGUID); - } - - // Remove WriterProxy data information get_pdp()->removeWriterProxyData(auxGUID); // Removing change from history, not returning the change to the pool, since the ownership will be yielded to // the database reader_history->remove_change(reader_history->find_change(change), false); + + // Continue without waiting + continue_with_writer(reader, change); + } +} + +void EDPServerPUBListener::continue_with_writer( + RTPSReader* reader, + CacheChange_t* change) +{ + GUID_t auxGUID = iHandle2GUID(change->instanceHandle); + // String to store the topic of the writer + std::string topic_name = ""; + + // DATA(w) case: Retrieve the topic after creating the WriterProxyData (in add_writer_from_change()). This way, not matter + // whether the DATA(w) is a new one or an update, the WriterProxyData exists, and so the topic can be retrieved + // DATA(Uw) case: Retrieve the topic before removing the WriterProxyData. We need it to add the DATA(Uw) to the database + auto temp_writer_data = get_pdp()->get_temporary_writer_proxies_pool().get(); + if (get_pdp()->lookupWriterProxyData(auxGUID, *temp_writer_data)) + { + topic_name = temp_writer_data->topicName().to_string(); + } + else + { + EPROSIMA_LOG_WARNING(RTPS_EDP_LISTENER, "Writer Proxy Data missing for change " << auxGUID); } // Notify the DiscoveryDataBase if it is enabled already @@ -140,6 +149,7 @@ void EDPServerPUBListener::onNewCacheChangeAdded( reader->releaseCache(change); } } + EPROSIMA_LOG_INFO(RTPS_EDP_LISTENER, "-------------------- " << sedp_->mp_RTPSParticipant->getGuid() << " --------------------"); EPROSIMA_LOG_INFO(RTPS_EDP_LISTENER, "------------------ EDP PUB SERVER LISTENER END ------------------"); @@ -192,27 +202,20 @@ void EDPServerSUBListener::onNewCacheChangeAdded( GUID_t auxGUID = iHandle2GUID(change->instanceHandle); ReaderHistory* reader_history = reader->getHistory(); - // String to store the topic of the reader - std::string topic_name = ""; + // DATA(r) case: new reader or updated information about an existing reader if (change->kind == ALIVE) { + EndpointAddedCallback reader_added_callback = + std::bind(&EDPServerSUBListener::continue_with_reader, this, reader, change); + // Note: add_reader_from_change() removes the change from the EDP subscriptions' reader history, but it does not // return it to the pool - add_reader_from_change(reader, reader_history, change, sedp_, false); + add_reader_from_change(reader, reader_history, change, sedp_, false, reader_added_callback); - // Retrieve the topic after creating the ReaderProxyData (in add_reader_from_change()). This way, not matter - // whether the DATA(r) is a new one or an update, the ReaderProxyData exists, and so the topic can be retrieved - auto temp_reader_data = get_pdp()->get_temporary_reader_proxies_pool().get(); - if (get_pdp()->lookupReaderProxyData(auxGUID, *temp_reader_data)) - { - topic_name = temp_reader_data->topicName().to_string(); - } - else - { - EPROSIMA_LOG_WARNING(RTPS_EDP_LISTENER, "Reader Proxy Data missing for change " << auxGUID); - } + // Stop and wait for callback in case of TypeLookupService needed time to process the types + return; } // DATA(Ur) case else @@ -220,19 +223,37 @@ void EDPServerSUBListener::onNewCacheChangeAdded( //REMOVE WRITER FROM OUR READERS: EPROSIMA_LOG_INFO(RTPS_EDP_LISTENER, "Disposed Remote Reader, removing..."); - // Retrieve the topic before removing the ReaderProxyData. We need it to add the DATA(Ur) to the database - auto temp_reader_data = get_pdp()->get_temporary_reader_proxies_pool().get(); - if (get_pdp()->lookupReaderProxyData(auxGUID, *temp_reader_data)) - { - topic_name = temp_reader_data->topicName().to_string(); - } - // Remove ReaderProxy data information get_pdp()->removeReaderProxyData(auxGUID); // Removing change from history, not returning the change to the pool, since the ownership will be yielded to // the database reader_history->remove_change(reader_history->find_change(change), false); + + // Continue without waiting + continue_with_reader(reader, change); + } +} + +void EDPServerSUBListener::continue_with_reader( + RTPSReader* reader, + CacheChange_t* change) +{ + GUID_t auxGUID = iHandle2GUID(change->instanceHandle); + // String to store the topic of the reader + std::string topic_name = ""; + + // DATA(w) case: Retrieve the topic after creating the ReaderProxyData (in add_reader_from_change()). This way, not matter + // whether the DATA(r) is a new one or an update, the ReaderProxyData exists, and so the topic can be retrieved + // DATA(Uw) case: Retrieve the topic before removing the ReaderProxyData. We need it to add the DATA(Ur) to the database + auto temp_reader_data = get_pdp()->get_temporary_reader_proxies_pool().get(); + if (get_pdp()->lookupReaderProxyData(auxGUID, *temp_reader_data)) + { + topic_name = temp_reader_data->topicName().to_string(); + } + else + { + EPROSIMA_LOG_WARNING(RTPS_EDP_LISTENER, "Reader Proxy Data missing for change " << auxGUID); } // Notify the DiscoveryDataBase if it is enabled already diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp index 8a3d1bd4694..c796e0a0847 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp @@ -72,6 +72,10 @@ class EDPServerPUBListener : public fastrtps::rtps::EDPBasePUBListener fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; + void continue_with_writer( + fastrtps::rtps::RTPSReader* reader, + fastrtps::rtps::CacheChange_t* change); + private: //!Pointer to the EDPServer @@ -106,6 +110,10 @@ class EDPServerSUBListener : public fastrtps::rtps::EDPBaseSUBListener fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; + void continue_with_reader( + fastrtps::rtps::RTPSReader* reader, + fastrtps::rtps::CacheChange_t* change); + private: //!Pointer to the EDPServer diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index 1ddbbece811..5a3deab0908 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -39,6 +39,7 @@ using ParameterList = eprosima::fastdds::dds::ParameterList; + // Release reader lock to avoid ABBA lock. PDP mutex should always be first. // Keep change information on local variables to check consistency later #define PREVENT_PDP_DEADLOCK(reader, change, pdp) \ @@ -65,7 +66,8 @@ void EDPBasePUBListener::add_writer_from_change( ReaderHistory* reader_history, CacheChange_t* change, EDP* edp, - bool release_change /*=true*/) + bool release_change /*= true*/, + const EndpointAddedCallback& writer_added_callback /* = nullptr*/) { //LOAD INFORMATION IN DESTINATION WRITER PROXY DATA const NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); @@ -83,7 +85,7 @@ void EDPBasePUBListener::add_writer_from_change( // Callback function to continue after typelookup is complete fastdds::dds::builtin::AsyncGetTypeWriterCallback after_typelookup_callback = - [change, edp, release_change, &network] + [reader, change, edp, &network, writer_added_callback] (eprosima::ProxyPool::smart_ptr& temp_writer_data) { //LOAD INFORMATION IN DESTINATION WRITER PROXY DATA @@ -118,6 +120,10 @@ void EDPBasePUBListener::add_writer_from_change( if (writer_data != nullptr) { edp->pairing_writer_proxy_with_any_local_reader(participant_guid, writer_data); + if (nullptr != writer_added_callback) + { + writer_added_callback(reader, change); + } } else { @@ -200,7 +206,8 @@ void EDPBaseSUBListener::add_reader_from_change( ReaderHistory* reader_history, CacheChange_t* change, EDP* edp, - bool release_change /*=true*/) + bool release_change /*= true*/, + const EndpointAddedCallback& reader_added_callback /* = nullptr*/) { //LOAD INFORMATION IN TEMPORAL READER PROXY DATA const NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); @@ -218,7 +225,7 @@ void EDPBaseSUBListener::add_reader_from_change( // Callback function to continue after typelookup is complete fastdds::dds::builtin::AsyncGetTypeReaderCallback after_typelookup_callback = - [change, edp, release_change, &network] + [reader, change, edp, &network, reader_added_callback] (eprosima::ProxyPool::smart_ptr& temp_reader_data) { auto copy_data_fun = [&temp_reader_data, &network]( @@ -253,6 +260,10 @@ void EDPBaseSUBListener::add_reader_from_change( if (reader_data != nullptr) //ADDED NEW DATA { edp->pairing_reader_proxy_with_any_local_writer(participant_guid, reader_data); + if (nullptr != reader_added_callback) + { + reader_added_callback(reader, change); + } } else { diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h index 7d9dade4425..6dcce1c9267 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h @@ -33,6 +33,9 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using EndpointAddedCallback = std::function< + void (RTPSReader* reader, const CacheChange_t* const change)>; + class RTPSReader; struct CacheChange_t; @@ -77,7 +80,9 @@ class EDPBasePUBListener : public EDPListener ReaderHistory* reader_history, CacheChange_t* change, EDP* edp, - bool release_change = true); + bool release_change = true, + const EndpointAddedCallback& writer_added_callback = nullptr + ); }; /** @@ -99,7 +104,9 @@ class EDPBaseSUBListener : public EDPListener ReaderHistory* reader_history, CacheChange_t* change, EDP* edp, - bool release_change = true); + bool release_change = true, + const EndpointAddedCallback& reader_added_callback = nullptr + ); }; /*! diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index 7b6f707461b..4215d3094e6 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -26,7 +26,9 @@ #include #include #include +#include +#include #include #include #include @@ -35,8 +37,8 @@ #include #include #include - -#include +#include +#include #include #include #include @@ -47,7 +49,6 @@ #include #include #include -#include using namespace eprosima::fastrtps; @@ -575,6 +576,8 @@ void PDPClient::perform_builtin_endpoints_matching( { mp_builtin->mp_WLP->assignRemoteEndpoints(pdata, true); } + + mp_builtin->typelookup_manager_->assign_remote_endpoints(pdata); } void PDPClient::removeRemoteEndpoints( diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index 67a51120127..518ea3fdcf1 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -22,17 +22,20 @@ #include #include +#include #include #include +#include +#include #include #include #include #include #include #include -#include +#include +#include -#include #include #include #include @@ -43,10 +46,10 @@ #include #include #include +#include +#include #include -#include #include -#include namespace eprosima { namespace fastdds { @@ -720,6 +723,8 @@ void PDPServer::perform_builtin_endpoints_matching( { mp_builtin->mp_WLP->assignRemoteEndpoints(pdata, true); } + + mp_builtin->typelookup_manager_->assign_remote_endpoints(pdata); } void PDPServer::removeRemoteEndpoints( From 38c3df55bcb6b3134c1e3162a63fa486e6c6620e Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 3 Apr 2024 11:28:47 +0200 Subject: [PATCH 29/35] Refs #20160: Fixes after rebase. Signed-off-by: adriancampo --- .../rtps/builtin/discovery/participant/PDPClient.cpp | 6 +++--- .../rtps/builtin/discovery/participant/PDPServer.cpp | 10 ++++------ test/blackbox/api/dds-pim/PubSubReader.hpp | 2 +- test/blackbox/api/dds-pim/PubSubWriter.hpp | 4 ++-- test/blackbox/api/dds-pim/PubSubWriterReader.hpp | 4 ++-- test/unittest/dds/publisher/DataWriterTests.cpp | 2 +- test/unittest/dds/subscriber/DataReaderTests.cpp | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index 4215d3094e6..7328573aade 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -37,8 +36,8 @@ #include #include #include -#include -#include + +#include #include #include #include @@ -49,6 +48,7 @@ #include #include #include +#include using namespace eprosima::fastrtps; diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index 518ea3fdcf1..d6814035965 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -25,17 +25,15 @@ #include #include #include -#include -#include #include #include #include #include #include #include -#include -#include +#include +#include #include #include #include @@ -46,10 +44,10 @@ #include #include #include -#include -#include #include +#include #include +#include namespace eprosima { namespace fastdds { diff --git a/test/blackbox/api/dds-pim/PubSubReader.hpp b/test/blackbox/api/dds-pim/PubSubReader.hpp index b679da43758..00df6c72cd0 100644 --- a/test/blackbox/api/dds-pim/PubSubReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubReader.hpp @@ -146,7 +146,7 @@ class PubSubReader private: using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; - using eprosima::fastdds::dds::DomainParticipantListener::on_publisher_discovery; + using eprosima::fastdds::dds::DomainParticipantListener::on_data_writer_discovery; ParticipantListener& operator =( const ParticipantListener&) = delete; diff --git a/test/blackbox/api/dds-pim/PubSubWriter.hpp b/test/blackbox/api/dds-pim/PubSubWriter.hpp index 9137db8671a..a1caf168ed1 100644 --- a/test/blackbox/api/dds-pim/PubSubWriter.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriter.hpp @@ -157,8 +157,8 @@ class PubSubWriter private: using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; - using eprosima::fastdds::dds::DomainParticipantListener::on_publisher_discovery; - using eprosima::fastdds::dds::DomainParticipantListener::on_subscriber_discovery; + using eprosima::fastdds::dds::DomainParticipantListener::on_data_writer_discovery; + using eprosima::fastdds::dds::DomainParticipantListener::on_data_reader_discovery; ParticipantListener& operator =( const ParticipantListener&) = delete; diff --git a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp index 5dab51af3f5..96348c98e96 100644 --- a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp @@ -173,8 +173,8 @@ class PubSubWriterReader private: using eprosima::fastdds::dds::DomainParticipantListener::on_participant_discovery; - using eprosima::fastdds::dds::DomainParticipantListener::on_publisher_discovery; - using eprosima::fastdds::dds::DomainParticipantListener::on_subscriber_discovery; + using eprosima::fastdds::dds::DomainParticipantListener::on_data_writer_discovery; + using eprosima::fastdds::dds::DomainParticipantListener::on_data_reader_discovery; //! Mutex guarding all info collections mutable std::mutex info_mutex_; diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index 5ff23d7254e..5f614fb9b06 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -391,7 +391,7 @@ TEST(DataWriterTests, get_guid) private: - using DomainParticipantListener::on_publisher_discovery; + using DomainParticipantListener::on_data_writer_discovery; } discovery_listener; diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index d2c29d3bdde..e7607f4ffbf 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -597,7 +597,7 @@ TEST_F(DataReaderTests, get_guid) private: - using DomainParticipantListener::on_subscriber_discovery; + using DomainParticipantListener::on_data_reader_discovery; } discovery_listener; From b45c43eaa6d6f0264532940eb24e4c9e4543e93b Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 3 Apr 2024 12:30:54 +0200 Subject: [PATCH 30/35] Refs #20160: Windows warning. Signed-off-by: adriancampo --- .../builtin/type_lookup_service/TypeLookupManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index a561caaae79..2b924742abd 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -810,18 +810,18 @@ std::string TypeLookupManager::get_instance_name( ss << std::hex; for (const auto& elem : guid.guidPrefix.value) { - ss << std::setw(2) << std::setfill('0') << static_cast(static_cast(elem)); + ss << std::setw(2) << std::setfill('0') << static_cast(elem); } for (const auto& elem : guid.entityId.value) { - ss << std::setw(2) << std::setfill('0') << static_cast(static_cast(elem)); + ss << std::setw(2) << std::setfill('0') << static_cast(elem); } std::string str = ss.str(); std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c) { - return std::tolower(c); + return static_cast(std::tolower(c)); }); return "dds.builtin.TOS." + str; } From 6d3bdd273c97b75f31b8cf0d9826817975752aa8 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 4 Apr 2024 17:45:15 +0200 Subject: [PATCH 31/35] Refs #20160: Applied suggestions. Signed-off-by: adriancampo --- .../discovery/endpoint/EDPServerListeners.cpp | 84 ++++++++++++------- .../discovery/endpoint/EDPServerListeners.hpp | 24 +++++- .../discovery/endpoint/EDPSimpleListeners.h | 2 +- .../discovery/participant/PDPClient.cpp | 2 +- .../discovery/participant/PDPServer.cpp | 2 +- 5 files changed, 76 insertions(+), 38 deletions(-) diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp index 29dd81a74d4..23c4156e7f3 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp @@ -62,8 +62,7 @@ void EDPServerPUBListener::onNewCacheChangeAdded( EPROSIMA_LOG_WARNING(RTPS_EDP_LISTENER, "Received change with no Key"); } - // Get writer's GUID and EDP publications' reader history - GUID_t auxGUID = iHandle2GUID(change->instanceHandle); + // Get EDP publications' reader history ReaderHistory* reader_history = reader->getHistory(); // Related_sample_identity could be lost in message delivered, so we set as sample_identity @@ -78,7 +77,6 @@ void EDPServerPUBListener::onNewCacheChangeAdded( change->writer_info.previous = nullptr; change->writer_info.num_sent_submessages = 0; - // DATA(w) case: new writer or updated information about an existing writer if (change->kind == ALIVE) { @@ -89,6 +87,9 @@ void EDPServerPUBListener::onNewCacheChangeAdded( // return it to the pool add_writer_from_change(reader, reader_history, change, sedp_, false, writer_added_callback); + // DATA(w) case: Retrieve the topic after creating the WriterProxyData (in add_writer_from_change()). This way, not matter + // whether the DATA(w) is a new one or an update, the WriterProxyData exists, and so the topic can be retrieved + // Stop and wait for callback in case of TypeLookupService needed time to process the types return; } @@ -97,29 +98,24 @@ void EDPServerPUBListener::onNewCacheChangeAdded( { EPROSIMA_LOG_INFO(RTPS_EDP_LISTENER, "Disposed Remote Writer, removing..."); + // DATA(Uw) case: Retrieve the topic before removing the WriterProxyData. We need it to add the DATA(Uw) to the database + GUID_t auxGUID = iHandle2GUID(change->instanceHandle); + std::string topic_name = get_writer_proxy_topic_name(auxGUID); + // Remove WriterProxy data information get_pdp()->removeWriterProxyData(auxGUID); - // Removing change from history, not returning the change to the pool, since the ownership will be yielded to - // the database + // Removing change from history, not returning the change to the pool, since the ownership will be yielded to the database reader_history->remove_change(reader_history->find_change(change), false); - // Continue without waiting - continue_with_writer(reader, change); + notify_discoverydatabase(topic_name, reader, change); } } -void EDPServerPUBListener::continue_with_writer( - RTPSReader* reader, - CacheChange_t* change) +std::string EDPServerPUBListener::get_writer_proxy_topic_name( + GUID_t auxGUID) { - GUID_t auxGUID = iHandle2GUID(change->instanceHandle); - // String to store the topic of the writer std::string topic_name = ""; - - // DATA(w) case: Retrieve the topic after creating the WriterProxyData (in add_writer_from_change()). This way, not matter - // whether the DATA(w) is a new one or an update, the WriterProxyData exists, and so the topic can be retrieved - // DATA(Uw) case: Retrieve the topic before removing the WriterProxyData. We need it to add the DATA(Uw) to the database auto temp_writer_data = get_pdp()->get_temporary_writer_proxies_pool().get(); if (get_pdp()->lookupWriterProxyData(auxGUID, *temp_writer_data)) { @@ -129,7 +125,14 @@ void EDPServerPUBListener::continue_with_writer( { EPROSIMA_LOG_WARNING(RTPS_EDP_LISTENER, "Writer Proxy Data missing for change " << auxGUID); } + return topic_name; +} +void EDPServerPUBListener::notify_discoverydatabase( + std::string topic_name, + RTPSReader* reader, + CacheChange_t* change) +{ // Notify the DiscoveryDataBase if it is enabled already // In case it is not enable, the change should not be updated or released because it is been // updated from a backup @@ -156,6 +159,14 @@ void EDPServerPUBListener::continue_with_writer( EPROSIMA_LOG_INFO(RTPS_EDP_LISTENER, ""); } +void EDPServerPUBListener::continue_with_writer( + RTPSReader* reader, + CacheChange_t* change) +{ + std::string topic_name = get_writer_proxy_topic_name(iHandle2GUID(change->instanceHandle)); + notify_discoverydatabase(topic_name, reader, change); +} + PDPServer* EDPServerSUBListener::get_pdp() { return sedp_->get_pdp(); @@ -198,12 +209,9 @@ void EDPServerSUBListener::onNewCacheChangeAdded( change->writer_info.previous = nullptr; change->writer_info.num_sent_submessages = 0; - // Get readers's GUID and EDP subscriptions' reader history - GUID_t auxGUID = iHandle2GUID(change->instanceHandle); + // Get EDP subscriptions' reader history ReaderHistory* reader_history = reader->getHistory(); - - // DATA(r) case: new reader or updated information about an existing reader if (change->kind == ALIVE) { @@ -214,6 +222,9 @@ void EDPServerSUBListener::onNewCacheChangeAdded( // return it to the pool add_reader_from_change(reader, reader_history, change, sedp_, false, reader_added_callback); + // DATA(w) case: Retrieve the topic after creating the ReaderProxyData (in add_reader_from_change()). This way, not matter + // whether the DATA(r) is a new one or an update, the ReaderProxyData exists, and so the topic can be retrieved + // Stop and wait for callback in case of TypeLookupService needed time to process the types return; } @@ -223,6 +234,10 @@ void EDPServerSUBListener::onNewCacheChangeAdded( //REMOVE WRITER FROM OUR READERS: EPROSIMA_LOG_INFO(RTPS_EDP_LISTENER, "Disposed Remote Reader, removing..."); + // DATA(Uw) case: Retrieve the topic before removing the ReaderProxyData. We need it to add the DATA(Ur) to the database + GUID_t auxGUID = iHandle2GUID(change->instanceHandle); + std::string topic_name = get_reader_proxy_topic_name(auxGUID); + // Remove ReaderProxy data information get_pdp()->removeReaderProxyData(auxGUID); @@ -230,22 +245,14 @@ void EDPServerSUBListener::onNewCacheChangeAdded( // the database reader_history->remove_change(reader_history->find_change(change), false); - // Continue without waiting - continue_with_reader(reader, change); + notify_discoverydatabase(topic_name, reader, change); } } -void EDPServerSUBListener::continue_with_reader( - RTPSReader* reader, - CacheChange_t* change) +std::string EDPServerSUBListener::get_reader_proxy_topic_name( + GUID_t auxGUID) { - GUID_t auxGUID = iHandle2GUID(change->instanceHandle); - // String to store the topic of the reader std::string topic_name = ""; - - // DATA(w) case: Retrieve the topic after creating the ReaderProxyData (in add_reader_from_change()). This way, not matter - // whether the DATA(r) is a new one or an update, the ReaderProxyData exists, and so the topic can be retrieved - // DATA(Uw) case: Retrieve the topic before removing the ReaderProxyData. We need it to add the DATA(Ur) to the database auto temp_reader_data = get_pdp()->get_temporary_reader_proxies_pool().get(); if (get_pdp()->lookupReaderProxyData(auxGUID, *temp_reader_data)) { @@ -255,7 +262,14 @@ void EDPServerSUBListener::continue_with_reader( { EPROSIMA_LOG_WARNING(RTPS_EDP_LISTENER, "Reader Proxy Data missing for change " << auxGUID); } + return topic_name; +} +void EDPServerSUBListener::notify_discoverydatabase( + std::string topic_name, + RTPSReader* reader, + CacheChange_t* change) +{ // Notify the DiscoveryDataBase if it is enabled already // In case it is not enable, the change should not be updated or released because it is been // updated from a backup @@ -282,6 +296,14 @@ void EDPServerSUBListener::continue_with_reader( EPROSIMA_LOG_INFO(RTPS_EDP_LISTENER, ""); } +void EDPServerSUBListener::continue_with_reader( + RTPSReader* reader, + CacheChange_t* change) +{ + std::string topic_name = get_reader_proxy_topic_name(iHandle2GUID(change->instanceHandle)); + notify_discoverydatabase(topic_name, reader, change); +} + } /* namespace rtps */ } // namespace fastdds } /* namespace eprosima */ diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp index c796e0a0847..5dd370ec426 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp @@ -72,11 +72,19 @@ class EDPServerPUBListener : public fastrtps::rtps::EDPBasePUBListener fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; - void continue_with_writer( +private: + + std::string get_writer_proxy_topic_name( + fastrtps::rtps::GUID_t auxGUID); + + void notify_discoverydatabase( + std::string topic_name, fastrtps::rtps::RTPSReader* reader, fastrtps::rtps::CacheChange_t* change); -private: + void continue_with_writer( + fastrtps::rtps::RTPSReader* reader, + fastrtps::rtps::CacheChange_t* change); //!Pointer to the EDPServer EDPServer* sedp_; @@ -110,11 +118,19 @@ class EDPServerSUBListener : public fastrtps::rtps::EDPBaseSUBListener fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; - void continue_with_reader( +private: + + std::string get_reader_proxy_topic_name( + fastrtps::rtps::GUID_t auxGUID); + + void notify_discoverydatabase( + std::string topic_name, fastrtps::rtps::RTPSReader* reader, fastrtps::rtps::CacheChange_t* change); -private: + void continue_with_reader( + fastrtps::rtps::RTPSReader* reader, + fastrtps::rtps::CacheChange_t* change); //!Pointer to the EDPServer EDPServer* sedp_; diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h index 6dcce1c9267..9c9c34b54ac 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h @@ -34,7 +34,7 @@ namespace fastrtps { namespace rtps { using EndpointAddedCallback = std::function< - void (RTPSReader* reader, const CacheChange_t* const change)>; + void (RTPSReader* reader, const CacheChange_t* change)>; class RTPSReader; struct CacheChange_t; diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index 7328573aade..fba0cf377fe 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -37,6 +36,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index d6814035965..8a4cd1e3247 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -33,6 +32,7 @@ #include #include +#include #include #include #include From 27a861e2ee1bd7497f17788f16b64253a5cc47c3 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Fri, 5 Apr 2024 11:46:58 +0200 Subject: [PATCH 32/35] Refs #20160: Fixed tests. Signed-off-by: adriancampo --- .../rtps/monitor_service/connections_fwd.hpp | 2 +- .../type_representation/TypeObjectRegistry.cpp | 13 ++++++++++--- .../rtps/builtin/BuiltinDataSerializationTests.cpp | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp b/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp index 0f6ee4ef799..abea1e4cf1e 100644 --- a/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp +++ b/include/fastdds/statistics/rtps/monitor_service/connections_fwd.hpp @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file connection_fwd.hpp + * @file connections_fwd.hpp * */ diff --git a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp index 77449f34bd9..7329161c7b9 100644 --- a/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp +++ b/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp @@ -693,11 +693,18 @@ const TypeIdentifier TypeObjectRegistry::get_complementary_type_identifier( std::lock_guard data_guard(type_object_registry_mutex_); for (const auto& it : local_type_identifiers_) { - if (it.second.type_identifier1() == type_id && TK_NONE != it.second.type_identifier2()._d()) + if (it.second.type_identifier1() == type_id) { - return it.second.type_identifier2(); + if (TK_NONE != it.second.type_identifier2()._d()) + { + return it.second.type_identifier2(); + } + else + { + return it.second.type_identifier1(); + } } - else if (it.second.type_identifier2() == type_id || TK_NONE == it.second.type_identifier2()._d()) + else if (it.second.type_identifier2() == type_id) { return it.second.type_identifier1(); } diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index b35f180aad9..fcbce6a0373 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -141,6 +141,7 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) } // Regression test for redmine issue #10547 +// After XTypes1.3 readFromCDRMessage is expected to return false when reading fails TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) { // DATA(w) @@ -189,7 +190,7 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) msg.length = msg.max_size; WriterProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, true))); + EXPECT_NO_THROW(EXPECT_FALSE(out.readFromCDRMessage(&msg, network, false, true))); } // DATA(r) @@ -241,7 +242,7 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, true))); + EXPECT_NO_THROW(EXPECT_FALSE(out.readFromCDRMessage(&msg, network, false, true))); } } From b0e2e6529f009162cad6ddb9027c37072875f28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 9 Apr 2024 11:29:55 +0200 Subject: [PATCH 33/35] Refs #20242. Update unsupported_type_info tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now we works successfully against OpenDDS 3.27 Signed-off-by: Ricardo González Moreno --- .../builtin/BuiltinDataSerializationTests.cpp | 83 ++++++++++++------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index fcbce6a0373..76cd708b1bc 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -140,9 +140,9 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) } } -// Regression test for redmine issue #10547 -// After XTypes1.3 readFromCDRMessage is expected to return false when reading fails -TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) +// Regression test for redmine issue #10547. +// Update against OpenDDS 3.27. With this version we can read the remote DATA(w). +TEST(BuiltinDataSerializationTests, interoperability_with_opendds_3_27) { // DATA(w) { @@ -154,16 +154,17 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) // Topic name 0x05, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x43, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x00, 0x00, - // Type information - 0x75, 0x00, 0x50, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x40, 0x24, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf1, 0x80, 0x99, 0x5e, 0xfc, 0xdb, 0xda, 0xbe, 0xd5, 0xb3, 0x3d, 0xe3, - 0xea, 0x3a, 0x4b, 0x00, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x10, 0x00, 0x40, 0x18, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Type name 0x07, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x70, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, + // Type information + 0x75, 0x00, 0x58, 0x00, + 0x54, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x40, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0xf1, 0x8b, 0x4b, 0x28, 0x4d, 0xe3, 0xa2, 0x4e, 0x5f, 0x86, 0x58, 0x5c, + 0x57, 0x88, 0xf6, 0x00, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x40, 0x1c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Reliability 0x1a, 0x00, 0x0c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0xf5, 0x05, @@ -172,15 +173,27 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // Endpoint GUID 0x5a, 0x00, 0x10, 0x00, - 0x01, 0x03, 0x08, 0x00, 0x27, 0x5c, 0x4f, 0x05, 0x0f, 0x19, 0x05, 0xea, 0x00, 0x00, 0x00, 0x02, + 0x01, 0x03, 0x74, 0x04, 0xf1, 0x0b, 0x6b, 0x16, 0x94, 0x6c, 0x26, 0x73, 0x00, 0x00, 0x00, 0x02, // Multicast locator 0x30, 0x00, 0x18, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe9, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xff, 0x00, 0x02, // Unicast locator 0x2f, 0x00, 0x18, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x3e, 0xcd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x01, 0xb4, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x01, 0x27, + 0x2f, 0x00, 0x18, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xac, 0x11, 0x00, 0x01, + 0x2f, 0x00, 0x18, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x05, 0x00, 0x01, + 0x2f, 0x00, 0x18, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x50, 0x01, + 0x2f, 0x00, 0x18, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x01, 0x8b, // Sentinel 0x01, 0x00, 0x00, 0x00 }; @@ -190,7 +203,7 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) msg.length = msg.max_size; WriterProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_FALSE(out.readFromCDRMessage(&msg, network, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, true))); } // DATA(r) @@ -204,35 +217,45 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) 0x05, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x43, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x00, 0x00, // Type information - 0x75, 0x00, 0x50, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x40, 0x24, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf1, 0x80, 0x99, 0x5e, 0xfc, 0xdb, 0xda, 0xbe, 0xd5, 0xb3, 0x3d, 0xe3, - 0xea, 0x3a, 0x4b, 0x00, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x10, 0x00, 0x40, 0x18, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x75, 0x00, 0x58, 0x00, + 0x54, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x40, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0xf1, 0x8b, 0x4b, 0x28, 0x4d, 0xe3, 0xa2, 0x4e, 0x5f, 0x86, 0x58, 0x5c, + 0x57, 0x88, 0xf6, 0x00, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x40, 0x1c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Type name 0x07, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x70, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, // Reliability 0x1a, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, - // Endpoint GUID - 0x5a, 0x00, 0x10, 0x00, - 0x01, 0x03, 0x08, 0x00, 0x27, 0x5c, 0x4f, 0x05, 0x0f, 0x40, 0x29, 0x9d, 0x00, 0x00, 0x00, 0x07, // Data representation 0x73, 0x00, 0x08, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x94, 0xd0, 0x00, 0x00, + // Endpoint GUID + 0x5a, 0x00, 0x10, 0x00, + 0x01, 0x03, 0x74, 0x04, 0xf1, 0x0b, 0x6b, 0x16, 0x84, 0x3e, 0x9d, 0x2b, 0x00, 0x00, 0x00, 0x07, // Multicast locator 0x30, 0x00, 0x18, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe9, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xff, 0x00, 0x02, // Unicast locator 0x2f, 0x00, 0x18, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x45, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x01, 0xb4, - // Type consistency - 0x74, 0x00, 0x08, 0x00, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x01, 0x27, + 0x2f, 0x00, 0x18, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xac, 0x11, 0x00, 0x01, + 0x2f, 0x00, 0x18, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x05, 0x00, 0x01, + 0x2f, 0x00, 0x18, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x50, 0x01, + 0x2f, 0x00, 0x18, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x01, 0x8b, // Sentinel 0x01, 0x00, 0x00, 0x00 }; @@ -242,7 +265,7 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_FALSE(out.readFromCDRMessage(&msg, network, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, true))); } } From feea1ec53df80a723ffaea696c1a9f8ef0718f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 9 Apr 2024 12:03:40 +0200 Subject: [PATCH 34/35] Refs #20242. Apply suggestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp b/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp index 69dc4fbe4c5..b7a5b10b6d7 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp @@ -214,7 +214,7 @@ class FASTDDS_EXPORTED_API TypeDescriptor virtual bool& is_nested() = 0; /*! - * Mofifies the is_nested property. + * Modifies the is_nested property. * @param[in] is_nested Boolean value to be set. */ virtual void is_nested( From 5ae348a900fddb00c2e1a93285cd92709d524ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Wed, 10 Apr 2024 10:55:22 +0200 Subject: [PATCH 35/35] Refs #20242. Fix log thread being killed in windows on unit test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González --- .../dds/xtypes/type_representation/TypeObjectUtilsTests.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/unittest/dds/xtypes/type_representation/TypeObjectUtilsTests.cpp b/test/unittest/dds/xtypes/type_representation/TypeObjectUtilsTests.cpp index 48d20f3f588..55cbd0b5d6a 100644 --- a/test/unittest/dds/xtypes/type_representation/TypeObjectUtilsTests.cpp +++ b/test/unittest/dds/xtypes/type_representation/TypeObjectUtilsTests.cpp @@ -3451,5 +3451,7 @@ int main( char** argv) { testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + int ret_value = RUN_ALL_TESTS(); + eprosima::fastdds::dds::Log::KillThread(); + return ret_value; }