Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scope issue when setting thread names in the multi-threaded signature checker #1674

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ void nano::signature_checker::verify (nano::signature_check_set & check_a)
{
{
// Don't process anything else if we have stopped
std::lock_guard<std::mutex> guard (stopped_mutex);
std::lock_guard<std::mutex> guard (mutex);
if (stopped)
{
return;
Expand Down Expand Up @@ -1426,7 +1426,7 @@ void nano::signature_checker::verify (nano::signature_check_set & check_a)

void nano::signature_checker::stop ()
{
std::lock_guard<std::mutex> guard (stopped_mutex);
std::lock_guard<std::mutex> guard (mutex);
if (!stopped)
{
stopped = true;
Expand All @@ -1436,7 +1436,7 @@ void nano::signature_checker::stop ()

void nano::signature_checker::flush ()
{
std::lock_guard<std::mutex> guard (stopped_mutex);
std::lock_guard<std::mutex> guard (mutex);
while (!stopped && tasks_remaining != 0)
;
}
Expand Down Expand Up @@ -1482,7 +1482,6 @@ void nano::signature_checker::set_thread_names (unsigned num_threads)
auto ready = false;
auto pending = num_threads;
std::condition_variable cv;
std::mutex mutex_l;
std::vector<std::promise<void>> promises (num_threads);
std::vector<std::future<void>> futures;
futures.reserve (num_threads);
Expand All @@ -1493,8 +1492,8 @@ void nano::signature_checker::set_thread_names (unsigned num_threads)
for (auto i = 0u; i < num_threads; ++i)
{
// clang-format off
boost::asio::post (thread_pool, [&cv, &ready, &pending, &mutex_l, &promise = promises[i]]() {
std::unique_lock<std::mutex> lk (mutex_l);
boost::asio::post (thread_pool, [&cv, &ready, &pending, &mutex = mutex, &promise = promises[i]]() {
std::unique_lock<std::mutex> lk (mutex);
nano::thread_role::set (nano::thread_role::name::signature_checking);
if (--pending == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion nano/node/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class signature_checker final
static constexpr size_t batch_size = 256;
const bool single_threaded;
unsigned num_threads;
std::mutex stopped_mutex;
std::mutex mutex;
bool stopped{ false };
};

Expand Down