mirror of
https://github.com/monero-project/monero.git
synced 2025-05-02 17:34:53 -04:00
Fix delayed exit when syncing
This commit is contained in:
parent
c36cb54340
commit
3f7d6fb57d
6 changed files with 49 additions and 4 deletions
|
@ -109,6 +109,7 @@ namespace cryptonote
|
|||
bool is_synchronized(){return m_synchronized;}
|
||||
void log_connections();
|
||||
std::list<connection_info> get_connections();
|
||||
void stop();
|
||||
private:
|
||||
//----------------- commands handlers ----------------------------------------------
|
||||
int handle_notify_new_block(int command, NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& context);
|
||||
|
@ -135,6 +136,7 @@ namespace cryptonote
|
|||
std::atomic<uint32_t> m_syncronized_connections_count;
|
||||
std::atomic<bool> m_synchronized;
|
||||
bool m_one_request = true;
|
||||
std::atomic<bool> m_stopping;
|
||||
|
||||
// static std::ofstream m_logreq;
|
||||
boost::mutex m_buffer_mutex;
|
||||
|
|
|
@ -60,7 +60,8 @@ namespace cryptonote
|
|||
t_cryptonote_protocol_handler<t_core>::t_cryptonote_protocol_handler(t_core& rcore, nodetool::i_p2p_endpoint<connection_context>* p_net_layout):m_core(rcore),
|
||||
m_p2p(p_net_layout),
|
||||
m_syncronized_connections_count(0),
|
||||
m_synchronized(false)
|
||||
m_synchronized(false),
|
||||
m_stopping(false)
|
||||
|
||||
{
|
||||
if(!m_p2p)
|
||||
|
@ -793,6 +794,11 @@ namespace cryptonote
|
|||
size_t count = 0;
|
||||
BOOST_FOREACH(const block_complete_entry& block_entry, arg.blocks)
|
||||
{
|
||||
if (m_stopping)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
++count;
|
||||
block b;
|
||||
if(!parse_and_validate_block_from_blob(block_entry.block, b))
|
||||
|
@ -857,6 +863,12 @@ namespace cryptonote
|
|||
m_core.prepare_handle_incoming_blocks(arg.blocks);
|
||||
BOOST_FOREACH(const block_complete_entry& block_entry, arg.blocks)
|
||||
{
|
||||
if (m_stopping)
|
||||
{
|
||||
m_core.cleanup_handle_incoming_blocks();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// process transactions
|
||||
TIME_MEASURE_START(transactions_process_time);
|
||||
BOOST_FOREACH(auto& tx_blob, block_entry.txs)
|
||||
|
@ -1131,5 +1143,11 @@ namespace cryptonote
|
|||
(*logreq) << "log used" << std::endl;
|
||||
return *logreq;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
void t_cryptonote_protocol_handler<t_core>::stop()
|
||||
{
|
||||
m_stopping = true;
|
||||
m_core.stop();
|
||||
}
|
||||
} // namespace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue