From 3d89b88facbfd9ce0b2979fb157660f9336097eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Dom=C3=ADnguez=20L=C3=B3pez?= <116071334+Mario-DL@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:21:29 +0100 Subject: [PATCH] Check if `SHM` transport is disabled in `LARGE_DATA` modes (#5355) * Refs #21959: Check for SHM_DISABLE in large_data setup modes Signed-off-by: Mario-DL * Refs #21959: Apply Miguels rev Signed-off-by: Mario Dominguez * Refs #21959: Apply suggestion Signed-off-by: Mario Dominguez --------- Signed-off-by: Mario-DL Signed-off-by: Mario Dominguez (cherry picked from commit a7dfdf5b44c1f2a5e0168c026f026b2993c04749) --- .../attributes/RTPSParticipantAttributes.cpp | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp b/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp index d60e1281b87..74140cf2896 100644 --- a/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp +++ b/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp @@ -217,6 +217,24 @@ static void setup_transports_udpv6( att.userTransports.push_back(descriptor); } +static void setup_large_data_shm_transport( + RTPSParticipantAttributes& att, + const fastdds::rtps::BuiltinTransportsOptions& options) +{ +#ifdef FASTDDS_SHM_TRANSPORT_DISABLED + static_cast(att); + EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, "Trying to configure Large Data transport, " << + "but Fast DDS was built without SHM transport support. Will use " << + "TCP for communications on the same host."); +#else + auto descriptor = create_shm_transport(att, options); + att.userTransports.push_back(descriptor); + + auto shm_loc = fastdds::rtps::SHMLocator::create_locator(0, fastdds::rtps::SHMLocator::Type::UNICAST); + att.defaultUnicastLocatorList.push_back(shm_loc); +#endif // FASTDDS_SHM_TRANSPORT_DISABLED +} + static void setup_transports_large_data( RTPSParticipantAttributes& att, bool intraprocess_only, @@ -224,11 +242,7 @@ static void setup_transports_large_data( { if (!intraprocess_only) { - auto shm_transport = create_shm_transport(att, options); - att.userTransports.push_back(shm_transport); - - auto shm_loc = fastdds::rtps::SHMLocator::create_locator(0, fastdds::rtps::SHMLocator::Type::UNICAST); - att.defaultUnicastLocatorList.push_back(shm_loc); + setup_large_data_shm_transport(att, options); auto tcp_transport = create_tcpv4_transport(att, options); att.userTransports.push_back(tcp_transport); @@ -261,11 +275,7 @@ static void setup_transports_large_datav6( { if (!intraprocess_only) { - auto shm_transport = create_shm_transport(att, options); - att.userTransports.push_back(shm_transport); - - auto shm_loc = fastdds::rtps::SHMLocator::create_locator(0, fastdds::rtps::SHMLocator::Type::UNICAST); - att.defaultUnicastLocatorList.push_back(shm_loc); + setup_large_data_shm_transport(att, options); auto tcp_transport = create_tcpv6_transport(att, options); att.userTransports.push_back(tcp_transport);