@@ -303,29 +303,24 @@ void DdsPipe::discovered_endpoint_nts_(
303303 // update the track of the topic to
304304 // add the partition in the reader if it is in the filter
305305
306- // update partitions under bridges_mutex_
306+ const auto bridge_it = bridges_.find (utils::Heritable<DdsTopic>::make_heritable (endpoint.topic ));
307+ // add the specific partition of the endpoint in the bridge topic.
308+ if (bridge_it != bridges_.end ())
307309 {
308- std::lock_guard<std::mutex> lock (bridges_mutex_);
310+ std::ostringstream guid_ss;
311+ guid_ss << endpoint.guid ;
309312
310- const auto bridge_it = bridges_.find (utils::Heritable<DdsTopic>::make_heritable (endpoint.topic ));
311- // add the specific partition of the endpoint in the bridges topic.
312- if (bridge_it != bridges_.end ())
313+ const auto part_it = endpoint.specific_partitions .find (guid_ss.str ());
314+ if (part_it != endpoint.specific_partitions .end ())
313315 {
314- std::ostringstream guid_ss;
315- guid_ss << endpoint.guid ;
316-
317- const auto part_it = endpoint.specific_partitions .find (guid_ss.str ());
318- if (part_it != endpoint.specific_partitions .end ())
319- {
320- bridge_it->second ->add_partition_to_topic (guid_ss.str (), part_it->second );
321- }
316+ bridge_it->second ->add_partition_to_topic (guid_ss.str (), part_it->second );
322317 }
323318 }
324319
325320 // update readers outside the lock
326321 if (!filter_partition_.empty ())
327322 {
328- update_partitions (filter_partition_);
323+ update_partitions_nts_ (filter_partition_);
329324 }
330325 }
331326}
@@ -626,6 +621,14 @@ void DdsPipe::deactivate_all_topics_nts_() noexcept
626621
627622void DdsPipe::update_partitions (
628623 const std::set<std::string>& partitions_set)
624+ {
625+ std::lock_guard<std::mutex> lock (mutex_);
626+
627+ update_partitions_nts_ (partitions_set);
628+ }
629+
630+ void DdsPipe::update_partitions_nts_ (
631+ const std::set<std::string>& partitions_set)
629632{
630633 // TODO.
631634 // In the future it could be interesting to update the partitions
@@ -641,6 +644,8 @@ void DdsPipe::update_content_filter(
641644 const std::string& topic_name,
642645 const std::string& expression)
643646{
647+ std::lock_guard<std::mutex> lock (mutex_);
648+
644649 for (const auto & pair : bridges_)
645650 {
646651 if (pair.first ->m_topic_name == topic_name)
@@ -653,8 +658,7 @@ void DdsPipe::update_content_filter(
653658void DdsPipe::update_filter (
654659 const std::set<std::string> filter_partition_set)
655660{
656- // Avoid possible datarace with partitions filter
657- std::lock_guard<std::mutex> lock (bridges_mutex_);
661+ std::lock_guard<std::mutex> lock (mutex_);
658662
659663 filter_partition_ = std::move (filter_partition_set);
660664}
0 commit comments