Skip to content

Commit

Permalink
Fix issue where unchecked_map::entries was being accessed for contain…
Browse files Browse the repository at this point in the history
…er information without acquiring the entries_mutex.
  • Loading branch information
clemahieu committed Sep 2, 2024
1 parent aad0b4b commit d9b8593
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions nano/node/unchecked_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,14 @@ void nano::unchecked_map::query_impl (nano::block_hash const & hash)

std::unique_ptr<nano::container_info_component> nano::unchecked_map::collect_container_info (const std::string & name)
{
nano::lock_guard<nano::mutex> lock{ mutex };

auto composite = std::make_unique<container_info_composite> (name);
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "entries", entries.size (), sizeof (decltype (entries)::value_type) }));
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "queries", buffer.size (), sizeof (decltype (buffer)::value_type) }));
{
std::lock_guard guard{ entries_mutex };
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "entries", entries.size (), sizeof (decltype (entries)::value_type) }));
}
{
nano::lock_guard<nano::mutex> lock{ mutex };
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "queries", buffer.size (), sizeof (decltype (buffer)::value_type) }));
}
return composite;
}

0 comments on commit d9b8593

Please sign in to comment.