Skip to content

Commit

Permalink
Add missing lock guards for discovered_names and discovered_namespaces (
Browse files Browse the repository at this point in the history
#301)

Signed-off-by: ivanpauno <[email protected]>
  • Loading branch information
ivanpauno authored Jul 9, 2019
1 parent 043a110 commit 62b7534
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rmw_fastrtps_shared_cpp/src/rmw_node_info_and_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ rmw_ret_t __get_guid_by_name(
guid = impl->participant->getGuid();
} else {
std::set<GUID_t> nodes_in_desired_namespace;
std::lock_guard<std::mutex> guard(impl->listener->names_mutex_);

auto namespaces = impl->listener->discovered_namespaces;
for (auto & guid_to_namespace : impl->listener->discovered_namespaces) {
if (guid_to_namespace.second == node_namespace) {
Expand Down Expand Up @@ -284,13 +286,15 @@ __log_debug_information(const CustomParticipantInfo & impl)
}
{
std::stringstream ss;
std::lock_guard<std::mutex> guard(impl.listener->names_mutex_);
for (auto & node_pair : impl.listener->discovered_names) {
ss << node_pair.first << " : " << node_pair.second << " ";
}
RCUTILS_LOG_DEBUG_NAMED(kLoggerTag, "Discovered names: %s", ss.str().c_str());
}
{
std::stringstream ss;
std::lock_guard<std::mutex> guard(impl.listener->names_mutex_);
for (auto & node_pair : impl.listener->discovered_namespaces) {
ss << node_pair.first << " : " << node_pair.second << " ";
}
Expand Down

0 comments on commit 62b7534

Please sign in to comment.