Moving bootstrap_processor thread so it can be joined before the rest of the node is destructed which would sometimes cause a crash on shutdown.
This commit is contained in:
parent
a897a57692
commit
a98e7e1a87
4 changed files with 12 additions and 6 deletions
|
@ -39,6 +39,7 @@ TEST (node, inactive_supply)
|
|||
config.inactive_supply = 10;
|
||||
auto node (std::make_shared <rai::node> (init, *service, path, alarm, config, work));
|
||||
ASSERT_EQ (10, node->ledger.inactive_supply);
|
||||
node->stop ();
|
||||
}
|
||||
|
||||
TEST (node, password_fanout)
|
||||
|
@ -54,6 +55,7 @@ TEST (node, password_fanout)
|
|||
auto node (std::make_shared <rai::node> (init, *service, path, alarm, config, work));
|
||||
auto wallet (node->wallets.create (100));
|
||||
ASSERT_EQ (10, wallet->store.password.values.size ());
|
||||
node->stop ();
|
||||
}
|
||||
|
||||
TEST (node, balance)
|
||||
|
|
|
@ -977,6 +977,7 @@ TEST (rpc, keepalive)
|
|||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
TEST (rpc, payment_init)
|
||||
|
|
|
@ -1063,15 +1063,13 @@ bool rai::rep_crawler::exists (rai::block_hash const & hash_a)
|
|||
rai::block_processor::block_processor (rai::node & node_a) :
|
||||
stopped (false),
|
||||
idle (true),
|
||||
node (node_a),
|
||||
thread ([this] () { process_blocks (); })
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
||||
rai::block_processor::~block_processor ()
|
||||
{
|
||||
stop ();
|
||||
thread.join ();
|
||||
}
|
||||
|
||||
void rai::block_processor::stop ()
|
||||
|
@ -1324,7 +1322,8 @@ application_path (application_path_a),
|
|||
port_mapping (*this),
|
||||
vote_processor (*this),
|
||||
warmed_up (0),
|
||||
block_processor (*this)
|
||||
block_processor (*this),
|
||||
block_processor_thread ([this] () { block_processor.process_blocks (); })
|
||||
{
|
||||
wallets.observer = [this] (rai::account const & account_a, bool active)
|
||||
{
|
||||
|
@ -1782,6 +1781,10 @@ void rai::node::stop ()
|
|||
{
|
||||
BOOST_LOG (log) << "Node stopping";
|
||||
block_processor.stop ();
|
||||
if (block_processor_thread.joinable ())
|
||||
{
|
||||
block_processor_thread.join ();
|
||||
}
|
||||
active.stop ();
|
||||
network.stop ();
|
||||
bootstrap_initiator.stop ();
|
||||
|
|
|
@ -443,15 +443,14 @@ public:
|
|||
void process_receive_many (std::shared_ptr <rai::block>, std::function <void (MDB_txn *, rai::process_return, std::shared_ptr <rai::block>)> = [] (MDB_txn *, rai::process_return, std::shared_ptr <rai::block>) {});
|
||||
void process_receive_many (std::vector <std::shared_ptr <rai::block>>, std::function <void (MDB_txn *, rai::process_return, std::shared_ptr <rai::block>)> = [] (MDB_txn *, rai::process_return, std::shared_ptr <rai::block>) {});
|
||||
rai::process_return process_receive_one (MDB_txn *, std::shared_ptr <rai::block>);
|
||||
private:
|
||||
void process_blocks ();
|
||||
private:
|
||||
bool stopped;
|
||||
bool idle;
|
||||
std::deque <std::pair <std::shared_ptr <rai::block>, std::function <void (MDB_txn *, rai::process_return, std::shared_ptr <rai::block>)>>> blocks;
|
||||
std::mutex mutex;
|
||||
std::condition_variable condition;
|
||||
rai::node & node;
|
||||
std::thread thread;
|
||||
};
|
||||
class node : public std::enable_shared_from_this <rai::node>
|
||||
{
|
||||
|
@ -512,6 +511,7 @@ public:
|
|||
rai::rep_crawler rep_crawler;
|
||||
unsigned warmed_up;
|
||||
rai::block_processor block_processor;
|
||||
std::thread block_processor_thread;
|
||||
rai::block_arrival block_arrival;
|
||||
static double constexpr price_max = 16.0;
|
||||
static double constexpr free_cutoff = 1024.0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue