diff --git a/include/fastdds/rtps/builtin/discovery/endpoint/EDP.h b/include/fastdds/rtps/builtin/discovery/endpoint/EDP.h index 0ac21fdb505..72b64a2f892 100644 --- a/include/fastdds/rtps/builtin/discovery/endpoint/EDP.h +++ b/include/fastdds/rtps/builtin/discovery/endpoint/EDP.h @@ -87,6 +87,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/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index b6f2561cfbe..d8f625a2e69 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -952,27 +952,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 e04e6456d68..402c12cee3a 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -925,27 +925,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 03bbf8d58b9..eff5e8bb445 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -597,6 +597,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/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index ad7c297819e..4d32830b632 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 */