Browse Source

Avoid deadlock when have past future blocks.

cl-refactor
Gav Wood 10 years ago
parent
commit
de13806962
  1. 33
      libethereum/BlockQueue.cpp

33
libethereum/BlockQueue.cpp

@ -136,27 +136,28 @@ bool BlockQueue::doneDrain(h256s const& _bad)
void BlockQueue::tick(BlockChain const& _bc)
{
UpgradableGuard l(m_lock);
if (m_future.empty())
return;
vector<bytes> todo;
{
UpgradableGuard l(m_lock);
if (m_future.empty())
return;
cblockq << "Checking past-future blocks...";
cblockq << "Checking past-future blocks...";
unsigned t = time(0);
if (t <= m_future.begin()->first)
return;
unsigned t = time(0);
if (t <= m_future.begin()->first)
return;
cblockq << "Past-future blocks ready.";
cblockq << "Past-future blocks ready.";
vector<bytes> todo;
{
UpgradeGuard l2(l);
auto end = m_future.lower_bound(t);
for (auto i = m_future.begin(); i != end; ++i)
todo.push_back(move(i->second));
m_future.erase(m_future.begin(), end);
{
UpgradeGuard l2(l);
auto end = m_future.lower_bound(t);
for (auto i = m_future.begin(); i != end; ++i)
todo.push_back(move(i->second));
m_future.erase(m_future.begin(), end);
}
}
cblockq << "Importing" << todo.size() << "past-future blocks.";
for (auto const& b: todo)

Loading…
Cancel
Save