aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-12-31 08:18:06 +0200
committerRiccardo Spagni <ric@spagni.net>2015-12-31 08:18:06 +0200
commit76a765c967145e1ed26712376814bd695f42153a (patch)
tree1e3f666d1b6a5646543d258c2962d8ffe35b705f /src/cryptonote_core/blockchain.cpp
parent91001aa4460a59a42dc14a32c8e90717fd29dbd2 (diff)
parent576effe11a513507b14275c7a2e6fc3b18de5e17 (diff)
downloadmonzero-core-76a765c967145e1ed26712376814bd695f42153a.tar.gz
monzero-core-76a765c967145e1ed26712376814bd695f42153a.tar.xz
monzero-core-76a765c967145e1ed26712376814bd695f42153a.zip
Merge pull request #579
576effe blockchain: kill ioservice on scope end, rather than manually (moneromooo-monero) ed5d017 miner: minor fixes on stop (moneromooo-monero) b245215 core_tests: deinit core before destroying it (moneromooo-monero) bc8a52e wallet: add a rescan_bc command and rescan_blockchain RPC (moneromooo-monero) 92ef6b5 wallet: protect against exceptions in the block pull thread (moneromooo-monero) af21061 net_peerlist: move a couple functions from public to private (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 141a42f49..e4d3d57fc 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -2078,6 +2078,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc
boost::asio::io_service ioservice;
boost::thread_group threadpool;
+ bool ioservice_active = false;
std::unique_ptr < boost::asio::io_service::work > work(new boost::asio::io_service::work(ioservice));
if(threads > 1)
@@ -2086,15 +2087,19 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc
{
threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioservice));
}
+ ioservice_active = true;
}
#define KILL_IOSERVICE() \
- if(threads > 1) \
+ if(ioservice_active) \
{ \
work.reset(); \
threadpool.join_all(); \
ioservice.stop(); \
- } \
+ ioservice_active = false; \
+ }
+
+ epee::misc_utils::auto_scope_leave_caller ioservice_killer = epee::misc_utils::create_scope_leave_handler([&]() { KILL_IOSERVICE(); });
for (const auto& txin : tx.vin)
{
@@ -2109,7 +2114,6 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc
if(have_tx_keyimg_as_spent(in_to_key.k_image))
{
LOG_PRINT_L1("Key image already spent in blockchain: " << epee::string_tools::pod_to_hex(in_to_key.k_image));
- KILL_IOSERVICE();
return false;
}
@@ -2123,7 +2127,6 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc
if(!itk->second)
{
LOG_PRINT_L1("Failed ring signature for tx " << get_transaction_hash(tx) << " vin key with k_image: " << in_to_key.k_image << " sig_index: " << sig_index);
- KILL_IOSERVICE();
return false;
}
@@ -2145,7 +2148,6 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc
LOG_PRINT_L1(" *pmax_used_block_height: " << *pmax_used_block_height);
}
- KILL_IOSERVICE();
return false;
}
@@ -2168,7 +2170,6 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc
LOG_PRINT_L1("*pmax_used_block_height: " << *pmax_used_block_height);
}
- KILL_IOSERVICE();
return false;
}
it->second[in_to_key.k_image] = true;