@@ -232,6 +232,127 @@ static bool get_unique_flows_parameters(
232
232
return true ;
233
233
}
234
234
235
+ // -- The following is a backport from 3.x of a PDP method
236
+ static void local_participant_attributes_update_nts (
237
+ const RTPSParticipantAttributes& new_atts,
238
+ PDP* pdp,
239
+ RTPSParticipantImpl* participant)
240
+ {
241
+ auto participant_data = pdp->getLocalParticipantProxyData ();
242
+ participant_data->m_userData .data_vec (new_atts.userData );
243
+
244
+ // If we are intraprocess only, we do not need to update locators
245
+ bool announce_locators = !participant->is_intraprocess_only ();
246
+ if (announce_locators)
247
+ {
248
+ // Clear all locators
249
+ participant_data->metatraffic_locators .unicast .clear ();
250
+ participant_data->metatraffic_locators .multicast .clear ();
251
+ participant_data->default_locators .unicast .clear ();
252
+ participant_data->default_locators .multicast .clear ();
253
+
254
+ // Update default locators
255
+ for (const Locator_t& loc : new_atts.defaultUnicastLocatorList )
256
+ {
257
+ participant_data->default_locators .add_unicast_locator (loc);
258
+ }
259
+ for (const Locator_t& loc : new_atts.defaultMulticastLocatorList )
260
+ {
261
+ participant_data->default_locators .add_multicast_locator (loc);
262
+ }
263
+
264
+ // Update metatraffic locators
265
+ for (const auto & locator : new_atts.builtin .metatrafficUnicastLocatorList )
266
+ {
267
+ participant_data->metatraffic_locators .add_unicast_locator (locator);
268
+ }
269
+ if (!new_atts.builtin .avoid_builtin_multicast ||
270
+ participant_data->metatraffic_locators .unicast .empty ())
271
+ {
272
+ for (const auto & locator : new_atts.builtin .metatrafficMulticastLocatorList )
273
+ {
274
+ participant_data->metatraffic_locators .add_multicast_locator (locator);
275
+ }
276
+ }
277
+
278
+ fastdds::rtps::network::external_locators::add_external_locators (*participant_data,
279
+ new_atts.builtin .metatraffic_external_unicast_locators ,
280
+ new_atts.default_external_unicast_locators );
281
+ }
282
+ }
283
+
284
+ // -- The following is a backport from 3.x of a PDP method
285
+ static void update_endpoint_locators_if_default_nts (
286
+ const std::vector<RTPSWriter*>& writers,
287
+ const std::vector<RTPSReader*>& readers,
288
+ const RTPSParticipantAttributes& old_atts,
289
+ const RTPSParticipantAttributes& new_atts,
290
+ PDP* pdp)
291
+ {
292
+ // Check if default locators have changed
293
+ const auto & old_default_unicast = old_atts.defaultUnicastLocatorList ;
294
+ const auto & old_default_multicast = old_atts.defaultMulticastLocatorList ;
295
+ const auto & new_default_unicast = new_atts.defaultUnicastLocatorList ;
296
+ const auto & new_default_multicast = new_atts.defaultMulticastLocatorList ;
297
+
298
+ // Early return if there is no change in default unicast locators
299
+ if ((old_default_unicast == new_default_unicast) &&
300
+ (old_default_multicast == new_default_multicast))
301
+ {
302
+ return ;
303
+ }
304
+
305
+ // Update proxies of endpoints with default configured locators
306
+ EDP* edp = pdp->getEDP ();
307
+ for (RTPSWriter* writer : writers)
308
+ {
309
+ if ((old_default_multicast == writer->getAttributes ().multicastLocatorList ) &&
310
+ (old_default_unicast == writer->getAttributes ().unicastLocatorList ))
311
+ {
312
+ writer->getAttributes ().multicastLocatorList = new_default_multicast;
313
+ writer->getAttributes ().unicastLocatorList = new_default_unicast;
314
+
315
+ WriterProxyData* wdata = nullptr ;
316
+ GUID_t participant_guid;
317
+ wdata = pdp->addWriterProxyData (writer->getGuid (), participant_guid,
318
+ [](WriterProxyData* proxy, bool is_update,
319
+ const ParticipantProxyData& participant)
320
+ {
321
+ static_cast <void >(is_update);
322
+ assert (is_update);
323
+ proxy->set_locators (participant.default_locators );
324
+ return true ;
325
+ });
326
+ assert (wdata != nullptr );
327
+ edp->processLocalWriterProxyData (writer, wdata);
328
+ }
329
+ }
330
+ for (RTPSReader* reader : readers)
331
+ {
332
+ if ((old_default_multicast == reader->getAttributes ().multicastLocatorList ) &&
333
+ (old_default_unicast == reader->getAttributes ().unicastLocatorList ))
334
+ {
335
+ reader->getAttributes ().multicastLocatorList = new_default_multicast;
336
+ reader->getAttributes ().unicastLocatorList = new_default_unicast;
337
+
338
+ ReaderProxyData* rdata = nullptr ;
339
+ GUID_t participant_guid;
340
+ rdata = pdp->addReaderProxyData (reader->getGuid (), participant_guid,
341
+ [](ReaderProxyData* proxy, bool is_update,
342
+ const ParticipantProxyData& participant)
343
+ {
344
+ static_cast <void >(is_update);
345
+ assert (is_update);
346
+
347
+ proxy->set_locators (participant.default_locators );
348
+ return true ;
349
+ });
350
+ assert (rdata != nullptr );
351
+ edp->processLocalReaderProxyData (reader, rdata);
352
+ }
353
+ }
354
+ }
355
+
235
356
Locator_t& RTPSParticipantImpl::applyLocatorAdaptRule (
236
357
Locator_t& loc)
237
358
{
@@ -1682,121 +1803,13 @@ void RTPSParticipantImpl::update_attributes(
1682
1803
1683
1804
{
1684
1805
std::lock_guard<std::recursive_mutex> lock (*pdp->getMutex ());
1685
-
1686
- // -- The following section corresponds to the 3.x backport of the PDP method
1687
- // local_participant_attributes_update_nts
1688
- auto participant_data = pdp->getLocalParticipantProxyData ();
1689
- participant_data->m_userData .data_vec (temp_atts.userData );
1690
-
1691
- // If we are intraprocess only, we do not need to update locators
1692
- bool announce_locators = !is_intraprocess_only ();
1693
- if (announce_locators)
1694
- {
1695
- // Clear all locators
1696
- participant_data->metatraffic_locators .unicast .clear ();
1697
- participant_data->metatraffic_locators .multicast .clear ();
1698
- participant_data->default_locators .unicast .clear ();
1699
- participant_data->default_locators .multicast .clear ();
1700
-
1701
- // Update default locators
1702
- for (const Locator_t& loc : temp_atts.defaultUnicastLocatorList )
1703
- {
1704
- participant_data->default_locators .add_unicast_locator (loc);
1705
- }
1706
- for (const Locator_t& loc : temp_atts.defaultMulticastLocatorList )
1707
- {
1708
- participant_data->default_locators .add_multicast_locator (loc);
1709
- }
1710
-
1711
- // Update metatraffic locators
1712
- for (const auto & locator : temp_atts.builtin .metatrafficUnicastLocatorList )
1713
- {
1714
- participant_data->metatraffic_locators .add_unicast_locator (locator);
1715
- }
1716
- if (!temp_atts.builtin .avoid_builtin_multicast ||
1717
- participant_data->metatraffic_locators .unicast .empty ())
1718
- {
1719
- for (const auto & locator : temp_atts.builtin .metatrafficMulticastLocatorList )
1720
- {
1721
- participant_data->metatraffic_locators .add_multicast_locator (locator);
1722
- }
1723
- }
1724
-
1725
- fastdds::rtps::network::external_locators::add_external_locators (*participant_data,
1726
- temp_atts.builtin .metatraffic_external_unicast_locators ,
1727
- temp_atts.default_external_unicast_locators );
1728
- }
1729
-
1730
- // -- The following section corresponds to the 3.x backport of the PDP method
1731
- // update_endpoint_locators_if_default_nts
1806
+ local_participant_attributes_update_nts (temp_atts, pdp, this );
1732
1807
1733
1808
if (local_interfaces_changed && internal_default_locators_)
1734
1809
{
1735
1810
std::lock_guard<shared_mutex> _ (endpoints_list_mutex);
1736
- // Check if default locators have changed
1737
- const auto & old_default_unicast = m_att.defaultUnicastLocatorList ;
1738
- const auto & old_default_multicast = m_att.defaultMulticastLocatorList ;
1739
- const auto & new_default_unicast = temp_atts.defaultUnicastLocatorList ;
1740
- const auto & new_default_multicast = temp_atts.defaultMulticastLocatorList ;
1741
-
1742
- // Early return if there is no change in default unicast locators
1743
- if ((old_default_unicast == new_default_unicast) &&
1744
- (old_default_multicast == new_default_multicast))
1745
- {
1746
- return ;
1747
- }
1748
-
1749
- // Update proxies of endpoints with default configured locators
1750
- EDP* edp = pdp->getEDP ();
1751
- for (RTPSWriter* writer : m_userWriterList)
1752
- {
1753
- if ((old_default_multicast == writer->getAttributes ().multicastLocatorList ) &&
1754
- (old_default_unicast == writer->getAttributes ().unicastLocatorList ))
1755
- {
1756
- writer->getAttributes ().multicastLocatorList = new_default_multicast;
1757
- writer->getAttributes ().unicastLocatorList = new_default_unicast;
1758
-
1759
- WriterProxyData* wdata = nullptr ;
1760
- GUID_t participant_guid;
1761
- wdata = pdp->addWriterProxyData (writer->getGuid (), participant_guid,
1762
- [](WriterProxyData* proxy, bool is_update,
1763
- const ParticipantProxyData& participant)
1764
- {
1765
- static_cast <void >(is_update);
1766
- assert (is_update);
1767
- proxy->set_locators (participant.default_locators );
1768
- return true ;
1769
- });
1770
- assert (wdata != nullptr );
1771
- edp->processLocalWriterProxyData (writer, wdata);
1772
- }
1773
- }
1774
- for (RTPSReader* reader : m_userReaderList)
1775
- {
1776
- if ((old_default_multicast == reader->getAttributes ().multicastLocatorList ) &&
1777
- (old_default_unicast == reader->getAttributes ().unicastLocatorList ))
1778
- {
1779
- reader->getAttributes ().multicastLocatorList = new_default_multicast;
1780
- reader->getAttributes ().unicastLocatorList = new_default_unicast;
1781
-
1782
- ReaderProxyData* rdata = nullptr ;
1783
- GUID_t participant_guid;
1784
- rdata = pdp->addReaderProxyData (reader->getGuid (), participant_guid,
1785
- [](ReaderProxyData* proxy, bool is_update,
1786
- const ParticipantProxyData& participant)
1787
- {
1788
- static_cast <void >(is_update);
1789
- assert (is_update);
1790
-
1791
- proxy->set_locators (participant.default_locators );
1792
- return true ;
1793
- });
1794
- assert (rdata != nullptr );
1795
- edp->processLocalReaderProxyData (reader, rdata);
1796
- }
1797
- }
1811
+ update_endpoint_locators_if_default_nts (m_userWriterList, m_userReaderList, m_att, temp_atts, pdp);
1798
1812
}
1799
- // -- end of 3.x backport
1800
1813
1801
1814
if (local_interfaces_changed)
1802
1815
{
0 commit comments