Skip to content

Commit

Permalink
Refs #20160: Added valid_matching check for TypeInformation.
Browse files Browse the repository at this point in the history
Signed-off-by: adriancampo <adriancampo@eprosima.com>
  • Loading branch information
adriancampo committed Jan 23, 2024
1 parent e7596a5 commit dd105e0
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 40 deletions.
3 changes: 3 additions & 0 deletions include/fastdds/rtps/builtin/discovery/endpoint/EDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

/**
Expand Down
15 changes: 3 additions & 12 deletions src/cpp/rtps/builtin/data/ReaderProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,27 +952,18 @@ bool ReaderProxyData::readFromCDRMessage(
}
case fastdds::dds::PID_TYPE_IDV1:
{
if (!fastdds::dds::QosPoliciesSerializer<TypeIdV1>::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<TypeObjectV1>::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<xtypes::TypeInformationParameter>::
read_from_cdr_message(
type_information(), msg, plength))
read_from_cdr_message(type_information(), msg, plength))
{
return false;
}
Expand Down
15 changes: 3 additions & 12 deletions src/cpp/rtps/builtin/data/WriterProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,27 +925,18 @@ bool WriterProxyData::readFromCDRMessage(
}
case fastdds::dds::PID_TYPE_IDV1:
{
if (!fastdds::dds::QosPoliciesSerializer<TypeIdV1>::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<TypeObjectV1>::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<xtypes::TypeInformationParameter>::
read_from_cdr_message(
type_information(), msg, plength))
read_from_cdr_message(type_information(), msg, plength))
{
return false;
}
Expand Down
9 changes: 9 additions & 0 deletions src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
34 changes: 18 additions & 16 deletions src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 <vector>

#include <gmock/gmock.h>

#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>

#include <fastdds/builtin/type_lookup_service/detail/TypeLookupTypes.hpp>

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<void>(pdata);
}

};

} /* namespace builtin */
} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */
#endif /* _FASTDDS_TYPELOOKUP_SERVICE_MANAGER_HPP */

0 comments on commit dd105e0

Please sign in to comment.