Skip to content

Commit c7dd0f3

Browse files
committed
[#24061] Recovered lock in DdsPipe + solved error in Windows
Signed-off-by: danipiza <dpizarrogallego@gmail.com>
1 parent 3fd07e2 commit c7dd0f3

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

ddspipe_core/src/cpp/core/DdsPipe.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,22 @@ 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-
const auto bridge_it = bridges_.find(utils::Heritable<DdsTopic>::make_heritable(endpoint.topic));
307-
// add the specific partition of the endpoint in the bridges topic.
308-
if (bridge_it != bridges_.end())
306+
// update partitions under bridges_mutex_
309307
{
310-
std::ostringstream guid_ss;
311-
guid_ss << endpoint.guid;
308+
std::lock_guard<std::mutex> lock(bridges_mutex_);
312309

313-
const auto part_it = endpoint.specific_partitions.find(guid_ss.str());
314-
if (part_it != endpoint.specific_partitions.end())
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())
315313
{
316-
bridge_it->second->add_partition_to_topic(guid_ss.str(), part_it->second);
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+
}
317322
}
318323
}
319324

@@ -648,6 +653,9 @@ void DdsPipe::update_content_filter(
648653
void DdsPipe::update_filter(
649654
const std::set<std::string> filter_partition_set)
650655
{
656+
// Avoid possible datarace with partitions filter
657+
std::lock_guard<std::mutex> lock(bridges_mutex_);
658+
651659
filter_partition_ = std::move(filter_partition_set);
652660
}
653661

0 commit comments

Comments
 (0)