diff --git a/nano/node/confirming_set.cpp b/nano/node/confirming_set.cpp index 9a8f436e77..f668655b87 100644 --- a/nano/node/confirming_set.cpp +++ b/nano/node/confirming_set.cpp @@ -133,10 +133,14 @@ void nano::confirming_set::run_batch (std::unique_lock & lock) notification.already_cemented.swap (already); // Wait for the worker thread if too many notifications are queued - while (notification_workers.num_queued_tasks () >= config.max_queued_notifications) + std::unique_lock lock{ mutex }; + bool stopped_l; + condition.wait (lock, [this, &stopped_l] { + return (stopped_l = stopped) || notification_workers.num_queued_tasks () < config.max_queued_notifications; + }); + if (stopped_l) { - stats.inc (nano::stat::type::confirming_set, nano::stat::detail::cooldown); - std::this_thread::sleep_for (100ms); + return; } notification_workers.push_task ([this, notification = std::move (notification)] () {