Merge branch 'bug/384/ungraceful_shutdown_on_CTRL+C' into 'develop'
Cancel the thread for sync blocks See merge request PBSA/peerplays!124
This commit is contained in:
commit
b05c36b4fe
2 changed files with 12 additions and 1 deletions
|
|
@ -48,6 +48,7 @@
|
|||
#include <boost/range/algorithm/reverse.hpp>
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
|
||||
#include <fc/log/file_appender.hpp>
|
||||
|
|
@ -107,6 +108,7 @@ public:
|
|||
fc::optional<fc::temp_file> _lock_file;
|
||||
bool _is_block_producer = false;
|
||||
bool _force_validate = false;
|
||||
std::atomic_bool _running{true};
|
||||
|
||||
void reset_p2p_node(const fc::path &data_dir) {
|
||||
try {
|
||||
|
|
@ -450,6 +452,12 @@ public:
|
|||
*/
|
||||
virtual bool handle_block(const graphene::net::block_message &blk_msg, bool sync_mode,
|
||||
std::vector<fc::uint160_t> &contained_transaction_message_ids) override {
|
||||
|
||||
// check point for the threads which may be cancled on application shutdown
|
||||
if(!_running.load()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
auto latency = fc::time_point::now() - blk_msg.block.timestamp;
|
||||
FC_ASSERT((latency.count() / 1000) > -5000, "Rejecting block with timestamp in the future");
|
||||
|
|
@ -1012,6 +1020,7 @@ void application::shutdown_plugins() {
|
|||
return;
|
||||
}
|
||||
void application::shutdown() {
|
||||
my->_running.store(false);
|
||||
if (my->_p2p_network)
|
||||
my->_p2p_network->close();
|
||||
if (my->_chain_db)
|
||||
|
|
|
|||
|
|
@ -895,7 +895,7 @@ namespace graphene { namespace net { namespace detail {
|
|||
void node_impl::p2p_network_connect_loop()
|
||||
{
|
||||
VERIFY_CORRECT_THREAD();
|
||||
while (!_p2p_network_connect_loop_done.canceled())
|
||||
while (!_p2p_network_connect_loop_done.canceled() && !_node_is_shutting_down)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -4051,6 +4051,8 @@ namespace graphene { namespace net { namespace detail {
|
|||
{
|
||||
VERIFY_CORRECT_THREAD();
|
||||
|
||||
_node_is_shutting_down = true;
|
||||
|
||||
try
|
||||
{
|
||||
_potential_peer_db.close();
|
||||
|
|
|
|||
Loading…
Reference in a new issue