Skip to content

Commit

Permalink
Refs #20165. Fix minimal type_id built
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Sep 24, 2024
1 parent e7c0a00 commit 5b5eaeb
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,11 +918,47 @@ const TypeIdentifier TypeObjectRegistry::get_complementary_type_identifier(
{
if (TypeObjectUtils::is_direct_hash_type_identifier(type_id))
{
std::lock_guard<std::mutex> data_guard(type_object_registry_mutex_);
std::unique_lock<std::mutex> lock(type_object_registry_mutex_);
auto it = type_registry_entries_.find(type_id);
if (type_registry_entries_.end() != it)
{
return it->second.complementary_type_id;
if (TK_NONE != it->second.complementary_type_id._d())
{
return it->second.complementary_type_id;
}
else
{
TypeRegistryEntry minimal_entry;
CompleteTypeObject complete_type_object = it->second.type_object.complete();
lock.unlock();
minimal_entry.type_object = build_minimal_from_complete_type_object(complete_type_object);
minimal_entry.complementary_type_id = type_id;
TypeIdentifier minimal_type_id = calculate_type_identifier(
minimal_entry.type_object,
minimal_entry.type_object_serialized_size);

lock.lock();
auto min_entry_result {type_registry_entries_.insert(
{minimal_type_id, minimal_entry})};
if (!min_entry_result.second)
{
EPROSIMA_LOG_INFO(
XTYPES_TYPE_REPRESENTATION,
"Minimal type identifier already registered his EK_MINIMAL remotely.");
}
it = type_registry_entries_.find(type_id);
assert(type_registry_entries_.end() != it);
it->second.complementary_type_id = minimal_type_id;

return minimal_type_id;
}
}
else
{
EPROSIMA_LOG_WARNING(
XTYPES_TYPE_REPRESENTATION,
"Complete type identifier was not registered previously.");

}
}
return type_id;
Expand Down Expand Up @@ -1375,12 +1411,7 @@ const TypeIdentifier TypeObjectRegistry::minimal_from_complete_type_identifier(
switch (type_id._d()){
case EK_COMPLETE:
{
std::lock_guard<std::mutex> data_guard(type_object_registry_mutex_);
auto it = type_registry_entries_.find(type_id);
if (type_registry_entries_.end() != it)
{
return it->second.complementary_type_id;
}
return get_complementary_type_identifier(type_id);
}
break;
case TI_PLAIN_SEQUENCE_SMALL:
Expand Down

0 comments on commit 5b5eaeb

Please sign in to comment.