Skip to content

Commit 0077886

Browse files
committed
Refs #22056: Apply review suggestions
Signed-off-by: cferreiragonz <[email protected]>
1 parent c627744 commit 0077886

File tree

11 files changed

+48
-59
lines changed

11 files changed

+48
-59
lines changed

include/fastdds/dds/core/policy/ParameterTypes.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ enum ParameterId_t : uint16_t
168168
/* eProsima Fast DDS extensions */
169169
PID_PRODUCT_VERSION = 0x8000,
170170
PID_PERSISTENCE_GUID = 0x8002,
171-
PID_HOST_ID = 0x8003,
171+
PID_MACHINE_ID = 0x8003,
172172
PID_DISABLE_POSITIVE_ACKS = 0x8005,
173173
PID_DATASHARING = 0x8006,
174174
PID_NETWORK_CONFIGURATION_SET = 0x8007,

src/cpp/rtps/builtin/data/ParticipantProxyData.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ParticipantProxyData::ParticipantProxyData(
8181
const ParticipantProxyData& pdata)
8282
: m_protocolVersion(pdata.m_protocolVersion)
8383
, m_guid(pdata.m_guid)
84-
, m_host_id(pdata.m_host_id)
84+
, machine_id(pdata.machine_id)
8585
, m_VendorId(pdata.m_VendorId)
8686
, product_version(pdata.product_version)
8787
, m_domain_id(pdata.m_domain_id)
@@ -176,11 +176,11 @@ uint32_t ParticipantProxyData::get_serialized_size(
176176
// PID_NETWORK_CONFIGURATION_SET
177177
ret_val += 4 + PARAMETER_NETWORKCONFIGSET_LENGTH;
178178

179-
if (m_host_id.size() > 0)
179+
if (machine_id.size() > 0)
180180
{
181-
// PID_HOST_ID
181+
// PID_MACHINE_ID
182182
ret_val +=
183-
fastdds::dds::ParameterSerializer<Parameter_t>::cdr_serialized_size(m_host_id);
183+
fastdds::dds::ParameterSerializer<Parameter_t>::cdr_serialized_size(machine_id);
184184
}
185185

186186
// PID_METATRAFFIC_MULTICAST_LOCATOR
@@ -331,9 +331,9 @@ bool ParticipantProxyData::writeToCDRMessage(
331331
return false;
332332
}
333333
}
334-
if (m_host_id.size() > 0)
334+
if (machine_id.size() > 0)
335335
{
336-
ParameterString_t p(fastdds::dds::PID_HOST_ID, 0, m_host_id);
336+
ParameterString_t p(fastdds::dds::PID_MACHINE_ID, 0, machine_id);
337337
if (!fastdds::dds::ParameterSerializer<ParameterString_t>::add_to_cdr_message(p, msg))
338338
{
339339
return false;
@@ -606,7 +606,7 @@ bool ParticipantProxyData::readFromCDRMessage(
606606
m_networkConfiguration = p.netconfigSet;
607607
break;
608608
}
609-
case fastdds::dds::PID_HOST_ID:
609+
case fastdds::dds::PID_MACHINE_ID:
610610
{
611611
// Ignore custom PID when coming from other vendors
612612
if (c_VendorId_eProsima != m_VendorId)
@@ -625,7 +625,7 @@ bool ParticipantProxyData::readFromCDRMessage(
625625
return false;
626626
}
627627

628-
m_host_id = p.getName();
628+
machine_id = p.getName();
629629
break;
630630
}
631631
case fastdds::dds::PID_METATRAFFIC_MULTICAST_LOCATOR:
@@ -647,7 +647,7 @@ bool ParticipantProxyData::readFromCDRMessage(
647647
Locator_t temp_locator;
648648
if (network.transform_remote_locator(
649649
p.locator, temp_locator, m_networkConfiguration,
650-
check_same_host()))
650+
is_from_this_host()))
651651
{
652652
ProxyDataFilters::filter_locators(
653653
network,
@@ -677,7 +677,7 @@ bool ParticipantProxyData::readFromCDRMessage(
677677
Locator_t temp_locator;
678678
if (network.transform_remote_locator(
679679
p.locator, temp_locator, m_networkConfiguration,
680-
check_same_host()))
680+
is_from_this_host()))
681681
{
682682
ProxyDataFilters::filter_locators(
683683
network,
@@ -707,7 +707,7 @@ bool ParticipantProxyData::readFromCDRMessage(
707707
Locator_t temp_locator;
708708
if (network.transform_remote_locator(
709709
p.locator, temp_locator, m_networkConfiguration,
710-
check_same_host()))
710+
is_from_this_host()))
711711
{
712712
ProxyDataFilters::filter_locators(
713713
network,
@@ -737,7 +737,7 @@ bool ParticipantProxyData::readFromCDRMessage(
737737
Locator_t temp_locator;
738738
if (network.transform_remote_locator(
739739
p.locator, temp_locator, m_networkConfiguration,
740-
check_same_host()))
740+
is_from_this_host()))
741741
{
742742
ProxyDataFilters::filter_locators(
743743
network,
@@ -893,12 +893,12 @@ bool ParticipantProxyData::readFromCDRMessage(
893893
}
894894
}
895895

896-
bool ParticipantProxyData::check_same_host()
896+
bool ParticipantProxyData::is_from_this_host() const
897897
{
898898
bool same_host = false;
899-
if (m_host_id.size() > 0)
899+
if (machine_id.size() > 0)
900900
{
901-
same_host = m_host_id == SystemInfo::instance().machine_id();
901+
same_host = machine_id == SystemInfo::instance().machine_id();
902902
}
903903
else
904904
{
@@ -911,7 +911,7 @@ void ParticipantProxyData::clear()
911911
{
912912
m_protocolVersion = ProtocolVersion_t();
913913
m_guid = GUID_t();
914-
m_host_id = "";
914+
machine_id = "";
915915
//set_VendorId_Unknown(m_VendorId);
916916
m_VendorId = c_VendorId_Unknown;
917917
product_version = {};
@@ -945,7 +945,7 @@ void ParticipantProxyData::copy(
945945
{
946946
m_protocolVersion = pdata.m_protocolVersion;
947947
m_guid = pdata.m_guid;
948-
m_host_id = pdata.m_host_id;
948+
machine_id = pdata.machine_id;
949949
m_VendorId[0] = pdata.m_VendorId[0];
950950
m_VendorId[1] = pdata.m_VendorId[1];
951951
product_version = pdata.product_version;

src/cpp/rtps/builtin/data/ParticipantProxyData.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class ParticipantProxyData
7777
ProtocolVersion_t m_protocolVersion;
7878
//!GUID
7979
GUID_t m_guid;
80-
//!HOST ID
81-
fastcdr::string_255 m_host_id;
80+
//!Machine ID
81+
fastcdr::string_255 machine_id;
8282
//!Vendor ID
8383
fastdds::rtps::VendorId_t m_VendorId;
8484
//! Product version
@@ -166,11 +166,11 @@ class ParticipantProxyData
166166
fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima);
167167

168168
/**
169-
* Check if the host is the same as the one that sent the data.
170-
* It tries to use the m_host_id. If it is not available, it will compare GUIDs.
169+
* Check if the host where the current process is running is the same as the one that sent the data.
170+
* It tries to use the machine_id. If it is not available, it will compare GUIDs.
171171
* @return True if the host is the same
172172
*/
173-
bool check_same_host();
173+
bool is_from_this_host() const;
174174

175175
//! Clear the data (restore to default state).
176176
void clear();

src/cpp/rtps/builtin/data/ReaderProxyData.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1193,12 +1193,12 @@ bool ReaderProxyData::readFromCDRMessage(
11931193
return false;
11941194
}
11951195

1196-
bool ReaderProxyData::check_same_host()
1196+
bool ReaderProxyData::is_from_this_host()
11971197
{
11981198
bool same_host = false;
1199-
if (m_host_id.size() > 0)
1199+
if (machine_id.size() > 0)
12001200
{
1201-
same_host = m_host_id == SystemInfo::instance().machine_id();
1201+
same_host = machine_id == SystemInfo::instance().machine_id();
12021202
}
12031203
else
12041204
{
@@ -1215,7 +1215,7 @@ void ReaderProxyData::clear()
12151215
plugin_security_attributes_ = 0UL;
12161216
#endif // if HAVE_SECURITY
12171217
m_guid = c_Guid_Unknown;
1218-
m_host_id = "";
1218+
machine_id = "";
12191219
m_networkConfiguration = 0;
12201220
remote_locators_.unicast.clear();
12211221
remote_locators_.multicast.clear();
@@ -1280,7 +1280,7 @@ void ReaderProxyData::copy(
12801280
ReaderProxyData* rdata)
12811281
{
12821282
m_guid = rdata->m_guid;
1283-
m_host_id = rdata->m_host_id;
1283+
machine_id = rdata->machine_id;
12841284
m_networkConfiguration = rdata->m_networkConfiguration;
12851285
remote_locators_ = rdata->remote_locators_;
12861286
m_key = rdata->m_key;
@@ -1349,7 +1349,7 @@ void ReaderProxyData::set_remote_unicast_locators(
13491349
remote_locators_.unicast.clear();
13501350
for (const Locator_t& locator : locators)
13511351
{
1352-
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
1352+
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
13531353
{
13541354
remote_locators_.add_unicast_locator(locator);
13551355
}
@@ -1369,7 +1369,7 @@ void ReaderProxyData::set_multicast_locators(
13691369
remote_locators_.multicast.clear();
13701370
for (const Locator_t& locator : locators)
13711371
{
1372-
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
1372+
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
13731373
{
13741374
remote_locators_.add_multicast_locator(locator);
13751375
}
@@ -1392,7 +1392,7 @@ void ReaderProxyData::set_remote_locators(
13921392

13931393
for (const Locator_t& locator : locators.unicast)
13941394
{
1395-
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
1395+
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
13961396
{
13971397
remote_locators_.add_unicast_locator(locator);
13981398
}
@@ -1402,7 +1402,7 @@ void ReaderProxyData::set_remote_locators(
14021402
{
14031403
for (const Locator_t& locator : locators.multicast)
14041404
{
1405-
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
1405+
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
14061406
{
14071407
remote_locators_.add_multicast_locator(locator);
14081408
}

src/cpp/rtps/builtin/data/ReaderProxyData.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ class ReaderProxyData
436436

437437
/**
438438
* Check if the host is the same as the one that sent the data.
439-
* It tries to use the m_host_id. If it is not available, it will compare GUIDs.
439+
* It tries to use the machine_id. If it is not available, it will compare GUIDs.
440440
* @return True if the host is the same
441441
*/
442-
bool check_same_host();
442+
bool is_from_this_host();
443443

444444
//!
445445
bool m_expectsInlineQos;
@@ -486,7 +486,7 @@ class ReaderProxyData
486486
//!GUID
487487
GUID_t m_guid;
488488
//!HOST ID
489-
fastcdr::string_255 m_host_id;
489+
fastcdr::string_255 machine_id;
490490
//!Network configuration
491491
NetworkConfigSet_t m_networkConfiguration;
492492
//!Holds locator information

src/cpp/rtps/builtin/data/WriterProxyData.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1137,9 +1137,9 @@ bool WriterProxyData::readFromCDRMessage(
11371137
bool WriterProxyData::check_same_host()
11381138
{
11391139
bool same_host = false;
1140-
if (m_host_id.size() > 0)
1140+
if (machine_id.size() > 0)
11411141
{
1142-
same_host = m_host_id == SystemInfo::instance().machine_id();
1142+
same_host = machine_id == SystemInfo::instance().machine_id();
11431143
}
11441144
else
11451145
{
@@ -1155,7 +1155,7 @@ void WriterProxyData::clear()
11551155
plugin_security_attributes_ = 0UL;
11561156
#endif // if HAVE_SECURITY
11571157
m_guid = c_Guid_Unknown;
1158-
m_host_id = "";
1158+
machine_id = "";
11591159
m_networkConfiguration = 0;
11601160
remote_locators_.unicast.clear();
11611161
remote_locators_.multicast.clear();
@@ -1189,7 +1189,7 @@ void WriterProxyData::copy(
11891189
WriterProxyData* wdata)
11901190
{
11911191
m_guid = wdata->m_guid;
1192-
m_host_id = wdata->m_host_id;
1192+
machine_id = wdata->machine_id;
11931193
m_networkConfiguration = wdata->m_networkConfiguration;
11941194
remote_locators_ = wdata->remote_locators_;
11951195
m_key = wdata->m_key;
@@ -1283,7 +1283,7 @@ void WriterProxyData::set_remote_unicast_locators(
12831283
remote_locators_.unicast.clear();
12841284
for (const Locator_t& locator : locators)
12851285
{
1286-
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
1286+
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
12871287
{
12881288
remote_locators_.add_unicast_locator(locator);
12891289
}
@@ -1303,7 +1303,7 @@ void WriterProxyData::set_multicast_locators(
13031303
remote_locators_.multicast.clear();
13041304
for (const Locator_t& locator : locators)
13051305
{
1306-
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
1306+
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
13071307
{
13081308
remote_locators_.add_multicast_locator(locator);
13091309
}
@@ -1326,7 +1326,7 @@ void WriterProxyData::set_remote_locators(
13261326

13271327
for (const Locator_t& locator : locators.unicast)
13281328
{
1329-
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
1329+
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
13301330
{
13311331
remote_locators_.add_unicast_locator(locator);
13321332
}
@@ -1336,7 +1336,7 @@ void WriterProxyData::set_remote_locators(
13361336
{
13371337
for (const Locator_t& locator : locators.multicast)
13381338
{
1339-
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
1339+
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
13401340
{
13411341
remote_locators_.add_multicast_locator(locator);
13421342
}

src/cpp/rtps/builtin/data/WriterProxyData.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -457,18 +457,18 @@ class WriterProxyData
457457

458458
/**
459459
* Check if the host is the same as the one that sent the data.
460-
* It tries to use the m_host_id. If it is not available, it will compare GUIDs.
460+
* It tries to use the machine_id. If it is not available, it will compare GUIDs.
461461
* @return True if the host is the same
462462
*/
463-
bool check_same_host();
463+
bool is_from_this_host();
464464

465465
private:
466466

467467
//!GUID
468468
GUID_t m_guid;
469469

470470
//!HOST ID
471-
fastcdr::string_255 m_host_id;
471+
fastcdr::string_255 machine_id;
472472

473473
//!Network configuration
474474
NetworkConfigSet_t m_networkConfiguration;

src/cpp/rtps/builtin/discovery/participant/PDP.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void PDP::initializeParticipantProxyData(
313313
participant_data->product_version.major = FASTDDS_VERSION_MAJOR;
314314
participant_data->product_version.minor = FASTDDS_VERSION_MINOR;
315315
participant_data->product_version.patch = FASTDDS_VERSION_MICRO;
316-
participant_data->m_host_id = SystemInfo::instance().machine_id();
316+
participant_data->machine_id = SystemInfo::instance().machine_id();
317317

318318
// TODO: participant_data->m_availableBuiltinEndpoints |= mp_builtin->available_builtin_endpoints();
319319

src/cpp/utils/Host.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ class Host
145145
if (machine_id_ == "")
146146
{
147147
EPROSIMA_LOG_WARNING(UTILS, "Cannot get machine id. Failing back to IP based ID");
148-
machine_id_ = "";
149148
}
150149
}
151150

src/cpp/utils/SystemInfo.hpp

-10
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ class SystemInfo
8787
return Host::instance().machine_id();
8888
}
8989

90-
/**
91-
* Get the identifier of the current machine.
92-
*
93-
* @return the identifier of the current host.
94-
*/
95-
inline fastcdr::string_255 check_machine_id() const
96-
{
97-
return Host::instance().machine_id();
98-
}
99-
10090
/**
10191
* Get a reference to the singleton instance.
10292
*

tools/fds/server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ int fastdds_discovery_server(
572572
}
573573

574574
fastdds::rtps::GuidPrefix_t guid_prefix = participantQos.wire_protocol().prefix;
575-
participantQos.transport().use_builtin_transports = true ? udp_server_initialized : false;
575+
participantQos.transport().use_builtin_transports = udp_server_initialized;
576576

577577
// Create the server
578578
int return_value = 0;

0 commit comments

Comments
 (0)