Skip to content

Commit

Permalink
Refs #20165. Fixes on mac
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Sep 16, 2024
1 parent 556445a commit 174fe92
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,19 @@ void TypeLookupRequestListener::check_get_type_dependencies_request(
SampleIdentity request_id,
const TypeLookup_getTypeDependencies_In& request)
{
std::unordered_set<xtypes::TypeIdentfierWithSize>* type_dependencies_ptr {nullptr};
std::unordered_set<xtypes::TypeIdentfierWithSize> 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<std::mutex> 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
Expand All @@ -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;
}
}
}
Expand All @@ -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)
Expand Down Expand Up @@ -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<std::mutex> lock(requests_with_continuation_mutex_);
auto requests_it = requests_with_continuation_.find(id_seq);
if (requests_it != requests_with_continuation_.end())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<xtypes::TypeIdentifierSeq, std::unordered_set<xtypes::TypeIdentfierWithSize>>
requests_with_continuation_;
Expand Down
6 changes: 3 additions & 3 deletions test/dds/xtypes/BaseCases/Case8.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"kind": "publisher",
"samples": "3",
"timeout": "10",
"timeout": "30",
"expected_matches": "100",
"known_types": [
"Type1",
Expand Down Expand Up @@ -64,7 +64,7 @@
{
"kind": "subscriber",
"samples": "3",
"timeout": "10",
"timeout": "30",
"expected_matches": "100",
"known_types": [
"Type51",
Expand Down Expand Up @@ -122,4 +122,4 @@
]
}
]
}
}
2 changes: 2 additions & 0 deletions test/dds/xtypes/TypeLookupServicePublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions test/dds/xtypes/TypeLookupServiceSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 174fe92

Please sign in to comment.