diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index f022851655..2cd8c84637 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -286,19 +286,19 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( SampleIdentity request_id, const TypeLookup_getTypeDependencies_In& request) { + std::unordered_set* type_dependencies_ptr {nullptr}; std::unordered_set type_dependencies; ReturnCode_t type_dependencies_result = RETCODE_ERROR; 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()) { auto requests_it = requests_with_continuation_.find(request.type_ids()); if (requests_it != requests_with_continuation_.end()) { // Get the dependencies without checking the registry - type_dependencies = requests_it->second; + type_dependencies_ptr = &requests_it->second; type_dependencies_result = RETCODE_OK; } else @@ -319,7 +319,12 @@ void TypeLookupRequestListener::check_get_type_dependencies_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); + auto ret = requests_with_continuation_.emplace(request.type_ids(), std::move(type_dependencies)); + type_dependencies_ptr = &ret.first->second; + } + else + { + type_dependencies_ptr = &type_dependencies; } } } @@ -333,7 +338,7 @@ void TypeLookupRequestListener::check_get_type_dependencies_request( { // 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()); + request.type_ids(), *type_dependencies_ptr, request.continuation_point()); answer_request(request_id, rpc::RemoteExceptionCode_t::REMOTE_EX_OK, out); } else if (RETCODE_NO_DATA == type_dependencies_result) @@ -388,7 +393,6 @@ TypeLookup_getTypeDependencies_Out TypeLookupRequestListener::prepare_get_type_d if ((start_index + MAX_DEPENDENCIES_PER_REPLY) > type_dependencies.size()) { // 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()) { diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index 5c986b1632..04b64247f1 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -176,9 +176,6 @@ class TypeLookupRequestListener : public fastdds::rtps::ReaderListener, public f //! 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_; diff --git a/test/dds/xtypes/BaseCases/Case8.json b/test/dds/xtypes/BaseCases/Case8.json index 6bf6ada2b4..169eee85e8 100644 --- a/test/dds/xtypes/BaseCases/Case8.json +++ b/test/dds/xtypes/BaseCases/Case8.json @@ -6,7 +6,7 @@ { "kind": "publisher", "samples": "3", - "timeout": "10", + "timeout": "30", "expected_matches": "100", "known_types": [ "Type1", @@ -64,7 +64,7 @@ { "kind": "subscriber", "samples": "3", - "timeout": "10", + "timeout": "30", "expected_matches": "100", "known_types": [ "Type51", @@ -122,4 +122,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/test/dds/xtypes/TypeLookupServicePublisher.cpp b/test/dds/xtypes/TypeLookupServicePublisher.cpp index d444258368..f6649d8dc1 100644 --- a/test/dds/xtypes/TypeLookupServicePublisher.cpp +++ b/test/dds/xtypes/TypeLookupServicePublisher.cpp @@ -99,6 +99,8 @@ bool TypeLookupServicePublisher::setup_publisher( // CREATE THE DATAWRITER DataWriterQos wqos = publisher->get_default_datawriter_qos(); wqos.data_sharing().off(); + wqos.reliability().kind = RELIABLE_RELIABILITY_QOS; + wqos.durability().kind = TRANSIENT_LOCAL_DURABILITY_QOS; a_type.writer_ = publisher->create_datawriter(topic, wqos); if (a_type.writer_ == nullptr) { diff --git a/test/dds/xtypes/TypeLookupServiceSubscriber.cpp b/test/dds/xtypes/TypeLookupServiceSubscriber.cpp index dd8fb14d24..83e6b8b654 100644 --- a/test/dds/xtypes/TypeLookupServiceSubscriber.cpp +++ b/test/dds/xtypes/TypeLookupServiceSubscriber.cpp @@ -105,6 +105,8 @@ bool TypeLookupServiceSubscriber::setup_subscriber( //CREATE THE DATAREADER DataReaderQos rqos = subscriber->get_default_datareader_qos(); rqos.data_sharing().off(); + rqos.reliability().kind = RELIABLE_RELIABILITY_QOS; + rqos.durability().kind = TRANSIENT_LOCAL_DURABILITY_QOS; DataReader* reader = subscriber->create_datareader(topic, rqos); if (reader == nullptr) {