Fix a deadlock reported by cn_smi between the PeerSet lock and the master lock.

This commit is contained in:
JoelKatz
2013-04-17 13:06:41 -07:00
parent 3263693c94
commit bade087b4e

View File

@@ -252,6 +252,15 @@ boost::weak_ptr<PeerSet> LedgerAcquire::pmDowncast()
return boost::shared_polymorphic_downcast<PeerSet>(shared_from_this());
}
static void LADispatch(
Job& job,
LedgerAcquire::pointer la,
std::vector< FUNCTION_TYPE<void (LedgerAcquire::pointer)> > trig)
{
for (unsigned int i = 0; i < trig.size(); ++i)
trig[i](la);
}
void LedgerAcquire::done()
{
if (mSignaled)
@@ -282,9 +291,9 @@ void LedgerAcquire::done()
else
theApp->getMasterLedgerAcquire().logFailure(mHash);
// FIXME: We hold the PeerSet lock
for (unsigned int i = 0; i < triggers.size(); ++i)
triggers[i](shared_from_this());
if (!triggers.empty()) // We hold the PeerSet lock, so must dispatch
theApp->getJobQueue().addJob(jtLEDGER_DATA, "triggers",
BIND_TYPE(LADispatch, P_1, shared_from_this(), triggers));
}
bool LedgerAcquire::addOnComplete(FUNCTION_TYPE<void (LedgerAcquire::pointer)> trigger)