Browse Source

Avoid rzce condition.

cl-refactor
Gav Wood 10 years ago
parent
commit
879f443ce1
  1. 8
      libethcore/EthashAux.cpp

8
libethcore/EthashAux.cpp

@ -119,9 +119,11 @@ void EthashAux::killCache(h256 const& _s)
EthashAux::LightType EthashAux::light(h256 const& _seedHash) EthashAux::LightType EthashAux::light(h256 const& _seedHash)
{ {
ReadGuard l(get()->x_lights); UpgradableGuard l(get()->x_lights);
LightType ret = get()->m_lights[_seedHash]; if (get()->m_lights.count(_seedHash))
return ret ? ret : (get()->m_lights[_seedHash] = make_shared<LightAllocation>(_seedHash)); return get()->m_lights.at(_seedHash);
UpgradeGuard l2(l);
return (get()->m_lights[_seedHash] = make_shared<LightAllocation>(_seedHash));
} }
EthashAux::LightAllocation::LightAllocation(h256 const& _seedHash) EthashAux::LightAllocation::LightAllocation(h256 const& _seedHash)

Loading…
Cancel
Save