Browse Source

Merge pull request #2623 from arkpar/tq-fix

Fixed deadlock on overbid transaction coming from network
cl-refactor
Gav Wood 10 years ago
parent
commit
4e8eb210f1
  1. 8
      libethereum/Client.cpp
  2. 1
      libethereum/Client.h

8
libethereum/Client.cpp

@ -94,7 +94,7 @@ void Client::init(p2p::Host* _extNet, std::string const& _dbPath, WithExisting _
m_lastGetWork = std::chrono::system_clock::now() - chrono::seconds(30); m_lastGetWork = std::chrono::system_clock::now() - chrono::seconds(30);
m_tqReady = m_tq.onReady([=](){ this->onTransactionQueueReady(); }); // TODO: should read m_tq->onReady(thisThread, syncTransactionQueue); m_tqReady = m_tq.onReady([=](){ this->onTransactionQueueReady(); }); // TODO: should read m_tq->onReady(thisThread, syncTransactionQueue);
m_tqReplaced = m_tq.onReplaced([=](h256 const&){ this->resetState(); }); m_tqReplaced = m_tq.onReplaced([=](h256 const&){ m_needStateReset = true; });
m_bqReady = m_bq.onReady([=](){ this->onBlockQueueReady(); }); // TODO: should read m_bq->onReady(thisThread, syncBlockQueue); m_bqReady = m_bq.onReady([=](){ this->onBlockQueueReady(); }); // TODO: should read m_bq->onReady(thisThread, syncBlockQueue);
m_bq.setOnBad([=](Exception& ex){ this->onBadBlock(ex); }); m_bq.setOnBad([=](Exception& ex){ this->onBadBlock(ex); });
bc().setOnBad([=](Exception& ex){ this->onBadBlock(ex); }); bc().setOnBad([=](Exception& ex){ this->onBadBlock(ex); });
@ -753,6 +753,12 @@ void Client::doWork()
if (m_syncBlockQueue.compare_exchange_strong(t, false)) if (m_syncBlockQueue.compare_exchange_strong(t, false))
syncBlockQueue(); syncBlockQueue();
if (m_needStateReset)
{
resetState();
m_needStateReset = false;
}
t = true; t = true;
if (m_syncTransactionQueue.compare_exchange_strong(t, false) && !m_remoteWorking && !isSyncing()) if (m_syncTransactionQueue.compare_exchange_strong(t, false) && !m_remoteWorking && !isSyncing())
syncTransactionQueue(); syncTransactionQueue();

1
libethereum/Client.h

@ -303,6 +303,7 @@ protected:
BlockInfo m_miningInfo; ///< The header we're attempting to mine on (derived from m_postMine). BlockInfo m_miningInfo; ///< The header we're attempting to mine on (derived from m_postMine).
bool remoteActive() const; ///< Is there an active and valid remote worker? bool remoteActive() const; ///< Is there an active and valid remote worker?
bool m_remoteWorking = false; ///< Has the remote worker recently been reset? bool m_remoteWorking = false; ///< Has the remote worker recently been reset?
std::atomic<bool> m_needStateReset = { false }; ///< Need reset working state to premin on next sync
std::chrono::system_clock::time_point m_lastGetWork; ///< Is there an active and valid remote worker? std::chrono::system_clock::time_point m_lastGetWork; ///< Is there an active and valid remote worker?
std::weak_ptr<EthereumHost> m_host; ///< Our Ethereum Host. Don't do anything if we can't lock. std::weak_ptr<EthereumHost> m_host; ///< Our Ethereum Host. Don't do anything if we can't lock.

Loading…
Cancel
Save