Fix delay in stopping the node (#2271)
Co-authored-by: Wesley Shillingford <wezrule@hotmail.com>
This commit is contained in:
parent
6ef9e0ffbe
commit
ded2b26bea
2 changed files with 13 additions and 4 deletions
|
@ -338,7 +338,9 @@ void nano::active_transactions::request_loop ()
|
|||
}
|
||||
const auto extra_delay (std::min (roots.size (), max_broadcast_queue) * node.network.broadcast_interval_ms * 2);
|
||||
const auto wakeup (std::chrono::steady_clock::now () + std::chrono::milliseconds (node.network_params.network.request_interval_ms + extra_delay));
|
||||
condition.wait_until (lock, wakeup, [&wakeup] { return std::chrono::steady_clock::now () >= wakeup; });
|
||||
// clang-format off
|
||||
condition.wait_until (lock, wakeup, [&wakeup, &stopped = stopped] { return stopped || std::chrono::steady_clock::now () >= wakeup; });
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -502,7 +504,10 @@ void nano::active_transactions::prioritize_frontiers_for_confirmation (nano::tra
|
|||
void nano::active_transactions::stop ()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock (mutex);
|
||||
condition.wait (lock, [& started = started] { return started; });
|
||||
if (!started)
|
||||
{
|
||||
condition.wait (lock, [& started = started] { return started; });
|
||||
}
|
||||
stopped = true;
|
||||
lock.unlock ();
|
||||
condition.notify_all ();
|
||||
|
|
|
@ -1689,7 +1689,9 @@ void nano::bootstrap_initiator::bootstrap (nano::endpoint const & endpoint_a, bo
|
|||
if (attempt != nullptr)
|
||||
{
|
||||
attempt->stop ();
|
||||
condition.wait (lock, [attempt = attempt] { return attempt == nullptr; });
|
||||
// clang-format off
|
||||
condition.wait (lock, [attempt = attempt, &stopped = stopped] { return stopped || attempt == nullptr; });
|
||||
// clang-format on
|
||||
}
|
||||
node.stats.inc (nano::stat::type::bootstrap, nano::stat::detail::initiate, nano::stat::dir::out);
|
||||
attempt = std::make_shared<nano::bootstrap_attempt> (node.shared ());
|
||||
|
@ -1707,7 +1709,9 @@ void nano::bootstrap_initiator::bootstrap_lazy (nano::block_hash const & hash_a,
|
|||
if (attempt != nullptr)
|
||||
{
|
||||
attempt->stop ();
|
||||
condition.wait (lock, [attempt = attempt] { return attempt == nullptr; });
|
||||
// clang-format off
|
||||
condition.wait (lock, [attempt = attempt, &stopped = stopped] { return stopped || attempt == nullptr; });
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
node.stats.inc (nano::stat::type::bootstrap, nano::stat::detail::initiate_lazy, nano::stat::dir::out);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue