Fix active_transactions stop (#4080)
This commit is contained in:
parent
cc81a45df0
commit
4dad02d264
2 changed files with 12 additions and 7 deletions
|
|
@ -38,6 +38,11 @@ nano::active_transactions::~active_transactions ()
|
||||||
|
|
||||||
void nano::active_transactions::start ()
|
void nano::active_transactions::start ()
|
||||||
{
|
{
|
||||||
|
if (node.flags.disable_request_loop)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
debug_assert (!thread.joinable ());
|
debug_assert (!thread.joinable ());
|
||||||
|
|
||||||
thread = std::thread ([this] () {
|
thread = std::thread ([this] () {
|
||||||
|
|
@ -48,12 +53,12 @@ void nano::active_transactions::start ()
|
||||||
|
|
||||||
void nano::active_transactions::stop ()
|
void nano::active_transactions::stop ()
|
||||||
{
|
{
|
||||||
stopped = true;
|
|
||||||
condition.notify_all ();
|
|
||||||
if (thread.joinable ())
|
|
||||||
{
|
{
|
||||||
thread.join ();
|
nano::lock_guard<nano::mutex> guard{ mutex };
|
||||||
|
stopped = true;
|
||||||
}
|
}
|
||||||
|
condition.notify_all ();
|
||||||
|
nano::join_or_pass (thread);
|
||||||
clear ();
|
clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,7 +337,7 @@ std::vector<std::shared_ptr<nano::election>> nano::active_transactions::list_act
|
||||||
void nano::active_transactions::request_loop ()
|
void nano::active_transactions::request_loop ()
|
||||||
{
|
{
|
||||||
nano::unique_lock<nano::mutex> lock{ mutex };
|
nano::unique_lock<nano::mutex> lock{ mutex };
|
||||||
while (!stopped && !node.flags.disable_request_loop)
|
while (!stopped)
|
||||||
{
|
{
|
||||||
auto const stamp_l = std::chrono::steady_clock::now ();
|
auto const stamp_l = std::chrono::steady_clock::now ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ private: // Elections
|
||||||
std::unordered_map<nano::block_hash, std::shared_ptr<nano::election>> blocks;
|
std::unordered_map<nano::block_hash, std::shared_ptr<nano::election>> blocks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit active_transactions (nano::node &, nano::confirmation_height_processor &);
|
active_transactions (nano::node &, nano::confirmation_height_processor &);
|
||||||
~active_transactions ();
|
~active_transactions ();
|
||||||
|
|
||||||
void start ();
|
void start ();
|
||||||
|
|
@ -233,7 +233,7 @@ private:
|
||||||
int active_hinted_elections_count{ 0 };
|
int active_hinted_elections_count{ 0 };
|
||||||
|
|
||||||
nano::condition_variable condition;
|
nano::condition_variable condition;
|
||||||
std::atomic<bool> stopped{ false };
|
bool stopped{ false };
|
||||||
std::thread thread;
|
std::thread thread;
|
||||||
|
|
||||||
friend class election;
|
friend class election;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue