message: Fix crash during exiting process
diff: @@ -115,7 +115,7 @@ chain_controller::chain_controller( const chain_controller::controller_config& c
  _spinup_db();
  _spinup_fork_db();
  -
  +#if 0
  std::thread *cc1 = new std::thread(&chain_controller::process_transaction_async, this);
  std::thread *c1 = new std::thread(&chain_controller::preprocess_transaction_async, this);
  @@ -124,13 +124,16 @@ chain_controller::chain_controller( const chain_controller::controller_config& c
  std::thread *c4 = new std::thread(&chain_controller::preprocess_transaction_async, this);
  std::thread *c5 = new std::thread(&chain_controller::organize_transaction_async, this);
  -
  +#endif
  // if (_block_log.read_head() && head_block_num() < _block_log.read_head()->block_num())
  // replay();
  } /// chain_controller::chain_controller
  chain_controller::~chain_controller() {
  + finished = true;
  + cnin.notify_all();
  + cnout.notify_all();
  clear_pending();
  _db.flush();
  }
  @@ -419,9 +422,12 @@ bool chain_controller::push_transaction_async( const packed_transaction& trx, ui
  }
  bool chain_controller::preprocess_transaction_async() {
  - while (true) {
  + while (!finished) {
  std::unique_lock<std::mutex> lk(mxin);
  cnin.wait(lk, []{ return finished || !qin.empty(); });
  + if (finished) {
  + break;
  + }
  qin_item item = std::move(qin.front());
  qin.pop();
  lk.unlock();
  @@ -503,7 +509,9 @@ bool chain_controller::process_transaction_async() {
  }
  return false;
  });
  -
  + if (finished) {
  + break;
  + }
  out_sequence += 1;
  auto iter = bad_sequence.find(out_sequence);
  if (iter != bad_sequence.end()) {
  @@ -554,10 +562,13 @@ bool chain_controller::process_transaction_async() {
  }
  bool chain_controller::organize_transaction_async() {
  - while (true) {
  + while (!finished) {
  {
  boost::this_thread::sleep_for(boost::chrono::milliseconds(2));
  std::lock_guard<std::mutex> lk(mxout);
  + if (finished) {
  + break;
  + }
  bool found = false;
  if (bad_sequence.find(out_sequence+1) != bad_sequence.end()) {
  found = true;
  