@@ -243,13 +243,7 @@ RTPSParticipantImpl::RTPSParticipantImpl(
243
243
/* INSERT DEFAULT MANDATORY MULTICAST LOCATORS HERE */
244
244
if (m_att.builtin .metatrafficMulticastLocatorList .empty () && m_att.builtin .metatrafficUnicastLocatorList .empty ())
245
245
{
246
- m_network_Factory.getDefaultMetatrafficMulticastLocators (m_att.builtin .metatrafficMulticastLocatorList ,
247
- metatraffic_multicast_port);
248
- m_network_Factory.NormalizeLocators (m_att.builtin .metatrafficMulticastLocatorList );
249
-
250
- m_network_Factory.getDefaultMetatrafficUnicastLocators (m_att.builtin .metatrafficUnicastLocatorList ,
251
- metatraffic_unicast_port);
252
- m_network_Factory.NormalizeLocators (m_att.builtin .metatrafficUnicastLocatorList );
246
+ get_default_metatraffic_locators ();
253
247
}
254
248
else
255
249
{
@@ -291,7 +285,6 @@ RTPSParticipantImpl::RTPSParticipantImpl(
291
285
}
292
286
293
287
// Creation of user locator and receiver resources
294
- bool hasLocatorsDefined = true ;
295
288
// If no default locators are defined we define some.
296
289
/* The reasoning here is the following.
297
290
If the parameters of the RTPS Participant don't hold default listening locators for the creation
@@ -303,9 +296,9 @@ RTPSParticipantImpl::RTPSParticipantImpl(
303
296
{
304
297
// Default Unicast Locators in case they have not been provided
305
298
/* INSERT DEFAULT UNICAST LOCATORS FOR THE PARTICIPANT */
306
- hasLocatorsDefined = false ;
307
-
308
- m_network_Factory. getDefaultUnicastLocators (domain_id_, m_att.defaultUnicastLocatorList , m_att );
299
+ get_default_unicast_locators () ;
300
+ logInfo (RTPS_PARTICIPANT, m_att. getName () << " Created with NO default Unicast Locator List, adding Locators: "
301
+ << m_att.defaultUnicastLocatorList );
309
302
}
310
303
else
311
304
{
@@ -315,22 +308,13 @@ RTPSParticipantImpl::RTPSParticipantImpl(
315
308
{
316
309
m_network_Factory.fill_default_locator_port (domain_id_, loc, m_att, false );
317
310
});
311
+ m_network_Factory.NormalizeLocators (m_att.defaultUnicastLocatorList );
318
312
319
313
std::for_each (m_att.defaultMulticastLocatorList .begin (), m_att.defaultMulticastLocatorList .end (),
320
314
[&](Locator_t& loc)
321
315
{
322
316
m_network_Factory.fill_default_locator_port (domain_id_, loc, m_att, true );
323
317
});
324
-
325
- }
326
-
327
- // Normalize unicast locators.
328
- m_network_Factory.NormalizeLocators (m_att.defaultUnicastLocatorList );
329
-
330
- if (!hasLocatorsDefined)
331
- {
332
- logInfo (RTPS_PARTICIPANT, m_att.getName () << " Created with NO default Unicast Locator List, adding Locators:"
333
- << m_att.defaultUnicastLocatorList );
334
318
}
335
319
336
320
#if HAVE_SECURITY
@@ -1176,110 +1160,140 @@ bool RTPSParticipantImpl::registerReader(
1176
1160
void RTPSParticipantImpl::update_attributes (
1177
1161
const RTPSParticipantAttributes& patt)
1178
1162
{
1179
- // Check if there are changes
1180
- if (patt. builtin . discovery_config . m_DiscoveryServers == m_att. builtin . discovery_config . m_DiscoveryServers
1181
- && patt.userData == m_att. userData )
1163
+ bool update_pdp = false ;
1164
+ // Check if new interfaces have been added
1165
+ if (patt. builtin . metatrafficMulticastLocatorList . empty () && patt.builtin . metatrafficUnicastLocatorList . empty () )
1182
1166
{
1183
- return ;
1167
+ LocatorList_t metatraffic_multicast_locator_list = m_att.builtin .metatrafficMulticastLocatorList ;
1168
+ LocatorList_t metatraffic_unicast_locator_list = m_att.builtin .metatrafficUnicastLocatorList ;
1169
+
1170
+ get_default_metatraffic_locators ();
1171
+
1172
+ if (!(metatraffic_multicast_locator_list == m_att.builtin .metatrafficMulticastLocatorList ) ||
1173
+ !(metatraffic_unicast_locator_list == m_att.builtin .metatrafficUnicastLocatorList ))
1174
+ {
1175
+ update_pdp = true ;
1176
+ logInfo (RTPS_PARTICIPANT, m_att.getName () << " updated its metatraffic locators" );
1177
+ }
1178
+ }
1179
+ if (patt.defaultUnicastLocatorList .empty () && patt.defaultMulticastLocatorList .empty ())
1180
+ {
1181
+ LocatorList_t default_unicast_locator_list = m_att.defaultUnicastLocatorList ;
1182
+ get_default_unicast_locators ();
1183
+ if (!(default_unicast_locator_list == m_att.defaultUnicastLocatorList ))
1184
+ {
1185
+ update_pdp = true ;
1186
+ logInfo (RTPS_PARTICIPANT, m_att.getName () << " updated default unicast locator list, current locators: "
1187
+ << m_att.defaultUnicastLocatorList );
1188
+ }
1184
1189
}
1185
1190
1186
- // Check that the remote servers list is consistent: all the already known remote servers must be included in the
1187
- // list and only new remote servers can be added.
1188
- for (auto existing_server : m_att.builtin .discovery_config .m_DiscoveryServers )
1191
+ auto pdp = mp_builtinProtocols->mp_PDP ;
1192
+ // Check if there are changes
1193
+ if (patt.builtin .discovery_config .m_DiscoveryServers != m_att.builtin .discovery_config .m_DiscoveryServers
1194
+ || patt.userData != m_att.userData )
1189
1195
{
1190
- bool contained = false ;
1191
- bool locator_contained = false ;
1192
- for (auto incoming_server : patt.builtin .discovery_config .m_DiscoveryServers )
1196
+ update_pdp = true ;
1197
+ // Check that the remote servers list is consistent: all the already known remote servers must be included in the
1198
+ // list and only new remote servers can be added.
1199
+ for (auto existing_server : m_att.builtin .discovery_config .m_DiscoveryServers )
1193
1200
{
1194
- if (existing_server.guidPrefix == incoming_server.guidPrefix )
1201
+ bool contained = false ;
1202
+ bool locator_contained = false ;
1203
+ for (auto incoming_server : patt.builtin .discovery_config .m_DiscoveryServers )
1195
1204
{
1196
- for ( auto incoming_locator : incoming_server.metatrafficUnicastLocatorList )
1205
+ if (existing_server. guidPrefix == incoming_server.guidPrefix )
1197
1206
{
1198
- for (auto existing_locator : existing_server .metatrafficUnicastLocatorList )
1207
+ for (auto incoming_locator : incoming_server .metatrafficUnicastLocatorList )
1199
1208
{
1200
- if (incoming_locator == existing_locator)
1209
+ for ( auto existing_locator : existing_server. metatrafficUnicastLocatorList )
1201
1210
{
1202
- locator_contained = true ;
1203
- break ;
1211
+ if (incoming_locator == existing_locator)
1212
+ {
1213
+ locator_contained = true ;
1214
+ break ;
1215
+ }
1216
+ }
1217
+ if (!locator_contained)
1218
+ {
1219
+ logWarning (RTPS_QOS_CHECK,
1220
+ " Discovery Servers cannot add/modify their locators: " << incoming_locator <<
1221
+ " has not been added" )
1222
+ return ;
1204
1223
}
1205
1224
}
1206
- if (!locator_contained)
1207
- {
1208
- logWarning (RTPS_QOS_CHECK,
1209
- " Discovery Servers cannot add/modify their locators: " << incoming_locator <<
1210
- " has not been added" )
1211
- return ;
1212
- }
1225
+ contained = true ;
1226
+ break ;
1213
1227
}
1214
- contained = true ;
1215
- break ;
1228
+ }
1229
+ if (!contained)
1230
+ {
1231
+ logWarning (RTPS_QOS_CHECK,
1232
+ " Discovery Servers cannot be removed from the list; they can only be added" );
1233
+ return ;
1216
1234
}
1217
1235
}
1218
- if (!contained)
1219
- {
1220
- logWarning (RTPS_QOS_CHECK,
1221
- " Discovery Servers cannot be removed from the list; they can only be added" );
1222
- return ;
1223
- }
1224
- }
1225
1236
1226
- // Update RTPSParticipantAttributes member
1227
- m_att.userData = patt.userData ;
1237
+ // Update RTPSParticipantAttributes member
1238
+ m_att.userData = patt.userData ;
1228
1239
1229
- auto pdp = mp_builtinProtocols->mp_PDP ;
1230
- {
1231
- std::unique_lock<std::recursive_mutex> lock (*pdp->getMutex ());
1240
+ {
1241
+ std::unique_lock<std::recursive_mutex> lock (*pdp->getMutex ());
1232
1242
1233
- // Update user data
1234
- auto local_participant_proxy_data = pdp->getLocalParticipantProxyData ();
1235
- local_participant_proxy_data->m_userData .data_vec (m_att.userData );
1243
+ // Update user data
1244
+ auto local_participant_proxy_data = pdp->getLocalParticipantProxyData ();
1245
+ local_participant_proxy_data->m_userData .data_vec (m_att.userData );
1236
1246
1237
- // Update remote servers list
1238
- if (m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::CLIENT ||
1239
- m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::SUPER_CLIENT ||
1240
- m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::SERVER ||
1241
- m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::BACKUP)
1242
- {
1243
- // Add incoming servers iff we don't know about them already
1244
- for (auto incoming_server : patt.builtin .discovery_config .m_DiscoveryServers )
1247
+ // Update remote servers list
1248
+ if (m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::CLIENT ||
1249
+ m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::SUPER_CLIENT ||
1250
+ m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::SERVER ||
1251
+ m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::BACKUP)
1245
1252
{
1246
- eprosima::fastdds::rtps::RemoteServerList_t::iterator server_it;
1247
- for (server_it = m_att.builtin .discovery_config .m_DiscoveryServers .begin ();
1248
- server_it != m_att.builtin .discovery_config .m_DiscoveryServers .end (); server_it++)
1253
+ // Add incoming servers iff we don't know about them already
1254
+ for (auto incoming_server : patt.builtin .discovery_config .m_DiscoveryServers )
1249
1255
{
1250
- if (server_it->guidPrefix == incoming_server.guidPrefix )
1256
+ eprosima::fastdds::rtps::RemoteServerList_t::iterator server_it;
1257
+ for (server_it = m_att.builtin .discovery_config .m_DiscoveryServers .begin ();
1258
+ server_it != m_att.builtin .discovery_config .m_DiscoveryServers .end (); server_it++)
1251
1259
{
1252
- break ;
1260
+ if (server_it->guidPrefix == incoming_server.guidPrefix )
1261
+ {
1262
+ break ;
1263
+ }
1264
+ }
1265
+ if (server_it == m_att.builtin .discovery_config .m_DiscoveryServers .end ())
1266
+ {
1267
+ m_att.builtin .discovery_config .m_DiscoveryServers .push_back (incoming_server);
1253
1268
}
1254
1269
}
1255
- if (server_it == m_att.builtin .discovery_config .m_DiscoveryServers .end ())
1256
- {
1257
- m_att.builtin .discovery_config .m_DiscoveryServers .push_back (incoming_server);
1258
- }
1259
- }
1260
1270
1261
- // Update the servers list in builtin protocols
1262
- mp_builtinProtocols->m_DiscoveryServers = m_att.builtin .discovery_config .m_DiscoveryServers ;
1271
+ // Update the servers list in builtin protocols
1272
+ mp_builtinProtocols->m_DiscoveryServers = m_att.builtin .discovery_config .m_DiscoveryServers ;
1263
1273
1264
- // Notify PDPServer
1265
- if (m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::SERVER ||
1266
- m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::BACKUP)
1267
- {
1268
- fastdds::rtps::PDPServer* pdp_server = static_cast <fastdds::rtps::PDPServer*>(pdp);
1269
- pdp_server->update_remote_servers_list ();
1270
- }
1271
- // Notify PDPClient
1272
- else if (m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::CLIENT ||
1273
- m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::SUPER_CLIENT)
1274
- {
1275
- fastdds::rtps::PDPClient* pdp_client = static_cast <fastdds::rtps::PDPClient*>(pdp);
1276
- pdp_client->update_remote_servers_list ();
1274
+ // Notify PDPServer
1275
+ if (m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::SERVER ||
1276
+ m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::BACKUP)
1277
+ {
1278
+ fastdds::rtps::PDPServer* pdp_server = static_cast <fastdds::rtps::PDPServer*>(pdp);
1279
+ pdp_server->update_remote_servers_list ();
1280
+ }
1281
+ // Notify PDPClient
1282
+ else if (m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::CLIENT ||
1283
+ m_att.builtin .discovery_config .discoveryProtocol == DiscoveryProtocol::SUPER_CLIENT)
1284
+ {
1285
+ fastdds::rtps::PDPClient* pdp_client = static_cast <fastdds::rtps::PDPClient*>(pdp);
1286
+ pdp_client->update_remote_servers_list ();
1287
+ }
1277
1288
}
1278
1289
}
1279
1290
}
1280
1291
1281
- // Send DATA(P)
1282
- pdp->announceParticipantState (true );
1292
+ if (update_pdp)
1293
+ {
1294
+ // Send DATA(P)
1295
+ pdp->announceParticipantState (true );
1296
+ }
1283
1297
}
1284
1298
1285
1299
bool RTPSParticipantImpl::updateLocalWriter (
@@ -2198,6 +2212,27 @@ void RTPSParticipantImpl::environment_file_has_changed()
2198
2212
}
2199
2213
}
2200
2214
2215
+ void RTPSParticipantImpl::get_default_metatraffic_locators ()
2216
+ {
2217
+ uint32_t metatraffic_multicast_port = m_att.port .getMulticastPort (domain_id_);
2218
+ uint32_t metatraffic_unicast_port = m_att.port .getUnicastPort (domain_id_,
2219
+ static_cast <uint32_t >(m_att.participantID ));
2220
+
2221
+ m_network_Factory.getDefaultMetatrafficMulticastLocators (m_att.builtin .metatrafficMulticastLocatorList ,
2222
+ metatraffic_multicast_port);
2223
+ m_network_Factory.NormalizeLocators (m_att.builtin .metatrafficMulticastLocatorList );
2224
+
2225
+ m_network_Factory.getDefaultMetatrafficUnicastLocators (m_att.builtin .metatrafficUnicastLocatorList ,
2226
+ metatraffic_unicast_port);
2227
+ m_network_Factory.NormalizeLocators (m_att.builtin .metatrafficUnicastLocatorList );
2228
+ }
2229
+
2230
+ void RTPSParticipantImpl::get_default_unicast_locators ()
2231
+ {
2232
+ m_network_Factory.getDefaultUnicastLocators (domain_id_, m_att.defaultUnicastLocatorList , m_att);
2233
+ m_network_Factory.NormalizeLocators (m_att.defaultUnicastLocatorList );
2234
+ }
2235
+
2201
2236
#ifdef FASTDDS_STATISTICS
2202
2237
2203
2238
bool RTPSParticipantImpl::register_in_writer (
0 commit comments