Tidy up locks and locals.

This commit is contained in:
Tom Ritchford
2015-06-25 14:04:16 -04:00
committed by Vinnie Falco
parent 67f2a5d9d6
commit e3ac1001be
4 changed files with 25 additions and 19 deletions

View File

@@ -466,8 +466,6 @@ void InboundLedger::trigger (Peer::ptr const& peer)
Message::pointer packet (std::make_shared <Message> (
tmBH, protocol::mtGET_OBJECTS));
{
ScopedLockType sl (mLock);
for (PeerSetMap::iterator it = mPeers.begin (), end = mPeers.end ();
it != end; ++it)
{

View File

@@ -1024,8 +1024,9 @@ public:
setFullLedger(ledger, false, false);
mHistLedger = ledger;
if ((mFillInProgress == 0) && (Ledger::getHashByIndex(ledger->getLedgerSeq() - 1) == ledger->getParentHash()))
{ // Previous ledger is in DB
ScopedLockType sl(m_mutex);
{
// Previous ledger is in DB
ScopedLockType lock (m_mutex);
mFillInProgress = ledger->getLedgerSeq();
getApp().getJobQueue().addJob(jtADVANCE, "tryFill", std::bind (
&LedgerMasterImp::tryFill, this,

View File

@@ -277,6 +277,7 @@ SHAMapStoreImp::run()
healthy_ = true;
validatedLedger_.reset();
{
std::unique_lock <std::mutex> lock (mutex_);
if (stop_)
{
@@ -288,7 +289,7 @@ SHAMapStoreImp::run()
validatedLedger_ = std::move (newLedger_);
else
continue;
lock.unlock();
}
LedgerIndex validatedSeq = validatedLedger_->getLedgerSeq();
if (!lastRotated)

View File

@@ -236,12 +236,17 @@ public:
return *this;
}
// be32toh and htobe32 are macros that somehow cause shadowing
// warnings in this header file, so we hide them...
static uint32_t bigendToHost (uint32_t x) { return be32toh(x); }
static uint32_t hostToBigend (uint32_t x) { return htobe32(x); }
base_uint& operator++ ()
{
// prefix operator
for (int i = WIDTH - 1; i >= 0; --i)
{
pn[i] = htobe32 (be32toh (pn[i]) + 1);
pn[i] = hostToBigend (bigendToHost (pn[i]) + 1);
if (pn[i] != 0)
break;
@@ -264,7 +269,7 @@ public:
for (int i = WIDTH - 1; i >= 0; --i)
{
std::uint32_t prev = pn[i];
pn[i] = htobe32 (be32toh (pn[i]) - 1);
pn[i] = hostToBigend (bigendToHost (pn[i]) - 1);
if (prev != 0)
break;
@@ -288,9 +293,10 @@ public:
for (int i = WIDTH; i--;)
{
std::uint64_t n = carry + be32toh (pn[i]) + be32toh (b.pn[i]);
std::uint64_t n = carry + bigendToHost (pn[i]) +
bigendToHost (b.pn[i]);
pn[i] = htobe32 (n & 0xffffffff);
pn[i] = hostToBigend (n & 0xffffffff);
carry = n >> 32;
}