Skip to content

Commit

Permalink
Parse missing TCPTransportDescriptor XML elements (#4001)
Browse files Browse the repository at this point in the history
* Refs #19378: Set DomainParticipantFactoryQos when loading profiles

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

* Refs #19378: Parse missing TCPTransportDescriptor XML elements

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

---------

Signed-off-by: EduPonz <eduardoponz@eprosima.com>
  • Loading branch information
EduPonz committed Nov 20, 2023
1 parent 22ba229 commit 12f3727
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class DomainParticipantFactoryQos

};

RTPS_DllAPI extern const DomainParticipantFactoryQos PARTICIPANT_FACTORY_QOS_DEFAULT;

} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */
Expand Down
2 changes: 2 additions & 0 deletions include/fastrtps/xmlparser/XMLParserCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ extern const char* METADATA_LOGICAL_PORT;
extern const char* LISTENING_PORTS;
extern const char* CALCULATE_CRC;
extern const char* CHECK_CRC;
extern const char* KEEP_ALIVE_THREAD;
extern const char* ACCEPT_THREAD;
extern const char* SEGMENT_SIZE;
extern const char* PORT_QUEUE_CAPACITY;
extern const char* PORT_OVERFLOW_POLICY;
Expand Down
4 changes: 4 additions & 0 deletions resources/xsd/fastRTPS_profiles.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,8 @@
├ calculate_crc [bool], (ONLY available for TCP type)
├ check_crc [bool], (ONLY available for TCP type)
├ enable_tcp_nodelay [bool], (ONLY available for TCP type)
├ keep_alive_thread [threadSettingsType], (ONLY available for TCP type)
├ accept_thread [threadSettingsType], (ONLY available for TCP type)
├ segment_size [uint32], (ONLY available for SHM type)
├ port_queue_capacity [uint32], (ONLY available for SHM type)
├ healthy_check_timeout_ms [uint32], (ONLY available for SHM type)
Expand Down Expand Up @@ -912,6 +914,8 @@
<xs:element name="check_crc" type="boolean" minOccurs="0" maxOccurs="1"/>
<xs:element name="enable_tcp_nodelay" type="boolean" minOccurs="0" maxOccurs="1"/>
<xs:element name="tls" type="tlsConfigType" minOccurs="0" maxOccurs="1"/>
<xs:element name="keep_alive_thread" type="threadSettingsType" minOccurs="0" maxOccurs="1"/>
<xs:element name="accept_thread" type="threadSettingsType" minOccurs="0" maxOccurs="1"/>
<xs:element name="segment_size" type="uint32" minOccurs="0" maxOccurs="1"/>
<xs:element name="port_queue_capacity" type="uint32" minOccurs="0" maxOccurs="1"/>
<xs:element name="healthy_check_timeout_ms" type="uint32" minOccurs="0" maxOccurs="1"/>
Expand Down
23 changes: 15 additions & 8 deletions src/cpp/fastdds/domain/DomainParticipantFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@

#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/domain/DomainParticipantImpl.hpp>
#include <fastdds/log/LogResources.hpp>
#include <fastdds/rtps/participant/RTPSParticipant.h>
#include <fastdds/rtps/RTPSDomain.h>
#include <fastdds/utils/QosConverters.hpp>
#include <fastrtps/types/DynamicDataFactory.h>
#include <fastrtps/types/DynamicTypeBuilderFactory.h>
#include <fastrtps/types/TypeObjectFactory.h>
#include <fastrtps/xmlparser/XMLProfileManager.h>
#include <fastrtps/xmlparser/XMLEndpointParser.h>
#include <fastrtps/xmlparser/XMLProfileManager.h>

#include <fastdds/log/LogResources.hpp>
#include <fastdds/domain/DomainParticipantImpl.hpp>
#include <fastdds/utils/QosConverters.hpp>
#include <rtps/RTPSDomainImpl.hpp>
#include <rtps/history/TopicPayloadPoolRegistry.hpp>
#include <rtps/RTPSDomainImpl.hpp>
#include <statistics/fastdds/domain/DomainParticipantImpl.hpp>
#include <utils/SystemInfo.hpp>
#include <utils/shared_memory/SharedMemWatchdog.hpp>
#include <utils/SystemInfo.hpp>

using namespace eprosima::fastrtps::xmlparser;

Expand Down Expand Up @@ -157,8 +158,6 @@ DomainParticipant* DomainParticipantFactory::create_participant(
{
load_profiles();

RTPSDomain::set_filewatch_thread_config(factory_qos_.file_watch_threads(), factory_qos_.file_watch_threads());

const DomainParticipantQos& pqos = (&qos == &PARTICIPANT_QOS_DEFAULT) ? default_participant_qos_ : qos;

DomainParticipant* dom_part = new DomainParticipant(mask);
Expand Down Expand Up @@ -337,11 +336,19 @@ ReturnCode_t DomainParticipantFactory::load_profiles()
// Change as already loaded
default_xml_profiles_loaded = true;

// Only change factory qos when not explicitly set by the user
if (factory_qos_ == PARTICIPANT_FACTORY_QOS_DEFAULT)
{
XMLProfileManager::getDefaultDomainParticipantFactoryQos(factory_qos_);
}

// Only change default participant qos when not explicitly set by the user
if (default_participant_qos_ == PARTICIPANT_QOS_DEFAULT)
{
reset_default_participant_qos();
}

RTPSDomain::set_filewatch_thread_config(factory_qos_.file_watch_threads(), factory_qos_.file_watch_threads());
}

return ReturnCode_t::RETCODE_OK;
Expand Down
13 changes: 12 additions & 1 deletion src/cpp/fastdds/domain/qos/DomainParticipantFactoryQos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@
// limitations under the License.

/**
* @file DomainParticipantQos.cpp
* @file DomainParticipantFactoryQos.cpp
*
*/

#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>


namespace eprosima {
namespace fastdds {
namespace dds {

const DomainParticipantFactoryQos PARTICIPANT_FACTORY_QOS_DEFAULT;

} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */
20 changes: 20 additions & 0 deletions src/cpp/rtps/xmlparser/XMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ XMLP_ret XMLParser::validateXMLTransportElements(
strcmp(name, LISTENING_PORTS) == 0 ||
strcmp(name, CALCULATE_CRC) == 0 ||
strcmp(name, CHECK_CRC) == 0 ||
strcmp(name, KEEP_ALIVE_THREAD) == 0 ||
strcmp(name, ACCEPT_THREAD) == 0 ||
strcmp(name, ENABLE_TCP_NODELAY) == 0 ||
strcmp(name, TLS) == 0 ||
strcmp(name, SEGMENT_SIZE) == 0 ||
Expand Down Expand Up @@ -634,6 +636,8 @@ XMLP_ret XMLParser::parseXMLCommonTCPTransportData(
<xs:element name="check_crc" type="boolType" minOccurs="0" maxOccurs="1"/>
<xs:element name="enable_tcp_nodelay" type="boolType" minOccurs="0" maxOccurs="1"/>
<xs:element name="tls" type="tlsConfigType" minOccurs="0" maxOccurs="1"/>
<xs:element name="keep_alive_thread" type="threadSettingsType" minOccurs="0" maxOccurs="1"/>
<xs:element name="accept_thread" type="threadSettingsType" minOccurs="0" maxOccurs="1"/>
</xs:all>
</xs:complexType>
*/
Expand Down Expand Up @@ -743,6 +747,22 @@ XMLP_ret XMLParser::parseXMLCommonTCPTransportData(
return XMLP_ret::XML_ERROR;
}
}
else if (strcmp(name, KEEP_ALIVE_THREAD) == 0)
{
if (getXMLThreadSettings(*p_aux0, pTCPDesc->keep_alive_thread) != XMLP_ret::XML_OK)
{
EPROSIMA_LOG_ERROR(XMLPARSER, "Incorrect thread settings");
return XMLP_ret::XML_ERROR;
}
}
else if (strcmp(name, ACCEPT_THREAD) == 0)
{
if (getXMLThreadSettings(*p_aux0, pTCPDesc->accept_thread) != XMLP_ret::XML_OK)
{
EPROSIMA_LOG_ERROR(XMLPARSER, "Incorrect thread settings");
return XMLP_ret::XML_ERROR;
}
}
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/cpp/rtps/xmlparser/XMLParserCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const char* METADATA_LOGICAL_PORT = "metadata_logical_port";
const char* LISTENING_PORTS = "listening_ports";
const char* CALCULATE_CRC = "calculate_crc";
const char* CHECK_CRC = "check_crc";
const char* KEEP_ALIVE_THREAD = "keep_alive_thread";
const char* ACCEPT_THREAD = "accept_thread";
const char* SEGMENT_SIZE = "segment_size";
const char* PORT_QUEUE_CAPACITY = "port_queue_capacity";
const char* PORT_OVERFLOW_POLICY = "port_overflow_policy";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ typedef struct TCPTransportDescriptor : public SocketTransportDescriptor

TLSConfig tls_config;

fastdds::rtps::ThreadSettings keep_alive_thread;
fastdds::rtps::ThreadSettings accept_thread;

void add_listener_port(
uint16_t port)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
#define XMLENDPOINTPARSER_H_
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC


#include <fastrtps/xmlparser/XMLParserCommon.h>

namespace eprosima {
namespace fastrtps {
namespace xmlparser {



/**
* Class XMLEndpointParser used to parse the XML file that contains information about remote endpoints.
* @ingroup DISCVOERYMODULE
Expand Down
1 change: 1 addition & 0 deletions test/unittest/dds/publisher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/DomainParticipant.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/DomainParticipantFactory.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/DomainParticipantImpl.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/qos/DomainParticipantFactoryQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/FileConsumer.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp
Expand Down
1 change: 1 addition & 0 deletions test/unittest/statistics/dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX)
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/QosPolicyUtils.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/DomainParticipant.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/DomainParticipantFactory.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/qos/DomainParticipantFactoryQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/FileConsumer.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp
Expand Down
20 changes: 19 additions & 1 deletion test/unittest/xmlparser/XMLParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,18 @@ TEST_F(XMLParserTests, parseXMLTransportData)
<check_crc>false</check_crc>\
<enable_tcp_nodelay>false</enable_tcp_nodelay>\
<tls><!-- TLS Section --></tls>\
<keep_alive_thread>\
<scheduling_policy>12</scheduling_policy>\
<priority>12</priority>\
<affinity>12</affinity>\
<stack_size>12</stack_size>\
</keep_alive_thread>\
<accept_thread>\
<scheduling_policy>12</scheduling_policy>\
<priority>12</priority>\
<affinity>12</affinity>\
<stack_size>12</stack_size>\
</accept_thread>\
<default_reception_threads>\
<scheduling_policy>12</scheduling_policy>\
<priority>12</priority>\
Expand All @@ -1036,7 +1048,7 @@ TEST_F(XMLParserTests, parseXMLTransportData)
</reception_threads>\
</transport_descriptor>\
";
constexpr size_t xml_len {3000};
constexpr size_t xml_len {3500};
char xml[xml_len];

// TCPv4
Expand Down Expand Up @@ -1066,6 +1078,8 @@ TEST_F(XMLParserTests, parseXMLTransportData)
EXPECT_EQ(pTCPv4Desc->logical_port_increment, 2u);
EXPECT_EQ(pTCPv4Desc->listening_ports[0], 5100u);
EXPECT_EQ(pTCPv4Desc->listening_ports[1], 5200u);
EXPECT_EQ(pTCPv4Desc->keep_alive_thread, modified_thread_settings);
EXPECT_EQ(pTCPv4Desc->accept_thread, modified_thread_settings);
EXPECT_EQ(pTCPv4Desc->default_reception_threads(), modified_thread_settings);
EXPECT_EQ(pTCPv4Desc->get_thread_config_for_port(12345), modified_thread_settings);
EXPECT_EQ(pTCPv4Desc->get_thread_config_for_port(12346), modified_thread_settings);
Expand Down Expand Up @@ -1094,6 +1108,8 @@ TEST_F(XMLParserTests, parseXMLTransportData)
EXPECT_EQ(pTCPv6Desc->logical_port_increment, 2u);
EXPECT_EQ(pTCPv6Desc->listening_ports[0], 5100u);
EXPECT_EQ(pTCPv6Desc->listening_ports[1], 5200u);
EXPECT_EQ(pTCPv4Desc->keep_alive_thread, modified_thread_settings);
EXPECT_EQ(pTCPv4Desc->accept_thread, modified_thread_settings);
EXPECT_EQ(pTCPv6Desc->default_reception_threads(), modified_thread_settings);
EXPECT_EQ(pTCPv6Desc->get_thread_config_for_port(12345), modified_thread_settings);
EXPECT_EQ(pTCPv6Desc->get_thread_config_for_port(12346), modified_thread_settings);
Expand Down Expand Up @@ -1213,6 +1229,8 @@ TEST_F(XMLParserTests, parseXMLTransportData_NegativeClauses)
"check_crc",
"enable_tcp_nodelay",
"tls",
"keep_alive_thread",
"accept_thread",
"default_reception_threads",
"reception_threads",
"bad_element"
Expand Down

0 comments on commit 12f3727

Please sign in to comment.