Remove delay exiting node in request processor (#1904)
* Remove delay exiting node * Make stopped atomic
This commit is contained in:
parent
d2ecede34f
commit
adbb93a5c5
2 changed files with 9 additions and 2 deletions
|
@ -2775,7 +2775,7 @@ void nano::active_transactions::confirm_frontiers (nano::transaction const & tra
|
|||
{
|
||||
size_t max_elections (max_broadcast_queue / 4);
|
||||
size_t elections_count (0);
|
||||
for (auto i (node.store.latest_begin (transaction_a, next_frontier_account)), n (node.store.latest_end ()); i != n && elections_count < max_elections; ++i)
|
||||
for (auto i (node.store.latest_begin (transaction_a, next_frontier_account)), n (node.store.latest_end ()); i != n && !stopped && elections_count < max_elections; ++i)
|
||||
{
|
||||
nano::account_info info (i->second);
|
||||
if (info.block_count != info.confirmation_height)
|
||||
|
@ -3070,6 +3070,13 @@ void nano::active_transactions::request_loop ()
|
|||
while (!stopped)
|
||||
{
|
||||
request_confirm (lock);
|
||||
|
||||
// This prevents unnecessary waiting if stopped is set in-between the above check and now
|
||||
if (stopped)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
const auto extra_delay (std::min (roots.size (), max_broadcast_queue) * node.network.broadcast_interval_ms * 2);
|
||||
condition.wait_for (lock, std::chrono::milliseconds (node.network_params.network.request_interval_ms + extra_delay));
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ private:
|
|||
std::chrono::steady_clock::time_point next_frontier_check{ std::chrono::steady_clock::now () };
|
||||
std::condition_variable condition;
|
||||
bool started;
|
||||
bool stopped;
|
||||
std::atomic<bool> stopped;
|
||||
boost::thread thread;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue