Avoid a race condition during peer status change

This commit is contained in:
JoelKatz
2019-02-22 16:08:39 -08:00
committed by Nik Bougalis
parent 2529edd2b6
commit 9dbf8495ee

View File

@@ -1658,15 +1658,13 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMStatusChange> const& m)
if (m->has_firstseq () && m->has_lastseq())
{
std::lock_guard<std::mutex> sl (recentLock_);
minLedger_ = m->firstseq ();
maxLedger_ = m->lastseq ();
// VFALCO Is this workaround still needed?
// Work around some servers that report sequences incorrectly
if (minLedger_ == 0)
maxLedger_ = 0;
if (maxLedger_ == 0)
minLedger_ = 0;
if ((maxLedger_ < minLedger_) || (minLedger_ == 0) || (maxLedger_ == 0))
minLedger_ = maxLedger_ = 0;
}
if (m->has_ledgerseq() &&