mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Can't call 'done' from the constructor of an InboundLedger
This commit is contained in:
@@ -26,16 +26,18 @@ InboundLedger::InboundLedger (uint256 const& hash, uint32 seq)
|
|||||||
#ifdef LA_DEBUG
|
#ifdef LA_DEBUG
|
||||||
WriteLog (lsTRACE, InboundLedger) << "Acquiring ledger " << mHash;
|
WriteLog (lsTRACE, InboundLedger) << "Acquiring ledger " << mHash;
|
||||||
#endif
|
#endif
|
||||||
if (tryLocal ())
|
|
||||||
done();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InboundLedger::checkLocal ()
|
bool InboundLedger::checkLocal ()
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||||
|
|
||||||
if (!isDone () && tryLocal())
|
if (!isDone () && tryLocal())
|
||||||
|
{
|
||||||
done();
|
done();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InboundLedger::tryLocal ()
|
bool InboundLedger::tryLocal ()
|
||||||
@@ -232,6 +234,7 @@ static void LADispatch (
|
|||||||
{
|
{
|
||||||
if (la->isComplete() && !la->isFailed())
|
if (la->isComplete() && !la->isFailed())
|
||||||
getApp().getLedgerMaster().checkAccept(la->getLedger()->getHash(), la->getLedger()->getLedgerSeq());
|
getApp().getLedgerMaster().checkAccept(la->getLedger()->getHash(), la->getLedger()->getLedgerSeq());
|
||||||
|
getApp().getLedgerMaster().tryAdvance();
|
||||||
for (unsigned int i = 0; i < trig.size (); ++i)
|
for (unsigned int i = 0; i < trig.size (); ++i)
|
||||||
trig[i] (la);
|
trig[i] (la);
|
||||||
}
|
}
|
||||||
@@ -244,9 +247,7 @@ void InboundLedger::done ()
|
|||||||
mSignaled = true;
|
mSignaled = true;
|
||||||
touch ();
|
touch ();
|
||||||
|
|
||||||
#ifdef LA_DEBUG
|
|
||||||
WriteLog (lsTRACE, InboundLedger) << "Done acquiring ledger " << mHash;
|
WriteLog (lsTRACE, InboundLedger) << "Done acquiring ledger " << mHash;
|
||||||
#endif
|
|
||||||
|
|
||||||
assert (isComplete () || isFailed ());
|
assert (isComplete () || isFailed ());
|
||||||
|
|
||||||
@@ -268,7 +269,6 @@ void InboundLedger::done ()
|
|||||||
// We hold the PeerSet lock, so must dispatch
|
// We hold the PeerSet lock, so must dispatch
|
||||||
getApp().getJobQueue ().addJob (jtLEDGER_DATA, "triggers",
|
getApp().getJobQueue ().addJob (jtLEDGER_DATA, "triggers",
|
||||||
BIND_TYPE (LADispatch, P_1, shared_from_this (), triggers));
|
BIND_TYPE (LADispatch, P_1, shared_from_this (), triggers));
|
||||||
getApp().getLedgerMaster().tryAdvance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InboundLedger::addOnComplete (FUNCTION_TYPE<void (InboundLedger::pointer)> trigger)
|
bool InboundLedger::addOnComplete (FUNCTION_TYPE<void (InboundLedger::pointer)> trigger)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
void addPeers ();
|
void addPeers ();
|
||||||
void awaitData ();
|
void awaitData ();
|
||||||
void noAwaitData ();
|
void noAwaitData ();
|
||||||
void checkLocal ();
|
bool checkLocal ();
|
||||||
|
|
||||||
typedef std::pair <protocol::TMGetObjectByHash::ObjectType, uint256> neededHash_t;
|
typedef std::pair <protocol::TMGetObjectByHash::ObjectType, uint256> neededHash_t;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
|
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
||||||
|
|
||||||
InboundLedger::pointer InboundLedgers::findCreate (uint256 const& hash, uint32 seq)
|
InboundLedger::pointer InboundLedgers::findCreate (uint256 const& hash, uint32 seq)
|
||||||
{
|
{
|
||||||
assert (hash.isNonZero ());
|
assert (hash.isNonZero ());
|
||||||
@@ -11,29 +13,32 @@ InboundLedger::pointer InboundLedgers::findCreate (uint256 const& hash, uint32 s
|
|||||||
|
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock sl (mLock);
|
boost::mutex::scoped_lock sl (mLock);
|
||||||
InboundLedger::pointer& ptr = mLedgers[hash];
|
|
||||||
|
|
||||||
if (ptr)
|
boost::unordered_map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (hash);
|
||||||
{ // FIXME: Should set the sequence if it's not set
|
if (it != mLedgers.end ())
|
||||||
ptr->touch ();
|
{
|
||||||
ret = ptr;
|
ret = it->second;
|
||||||
|
ret->touch ();
|
||||||
|
// FIXME: Should set the sequence if it's not set
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptr = ret = boost::make_shared<InboundLedger> (hash, seq);
|
ret = boost::make_shared<InboundLedger> (hash, seq);
|
||||||
|
assert (ret);
|
||||||
|
mLedgers.insert (std::make_pair (hash, ret));
|
||||||
|
|
||||||
if (!ret->isDone ())
|
if (!ret->tryLocal())
|
||||||
{
|
{
|
||||||
ret->addPeers ();
|
ret->addPeers ();
|
||||||
ret->setTimer (); // Cannot call in constructor
|
ret->setTimer (); // Cannot call in constructor
|
||||||
}
|
}
|
||||||
else if (ret->isComplete ())
|
else if (!ret->isFailed ())
|
||||||
{
|
{
|
||||||
|
WriteLog (lsDEBUG, InboundLedger) << "Acquiring ledger we already have locally: " << hash;
|
||||||
Ledger::pointer ledger = ret->getLedger ();
|
Ledger::pointer ledger = ret->getLedger ();
|
||||||
ledger->setClosed ();
|
ledger->setClosed ();
|
||||||
ledger->setImmutable ();
|
ledger->setImmutable ();
|
||||||
getApp().getLedgerMaster ().storeLedger (ledger);
|
getApp().getLedgerMaster ().storeLedger (ledger);
|
||||||
WriteLog (lsDEBUG, InboundLedger) << "Acquiring ledger we already have locally: " << hash;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,6 +80,7 @@ void InboundLedgers::dropLedger (uint256 const& hash)
|
|||||||
|
|
||||||
boost::mutex::scoped_lock sl (mLock);
|
boost::mutex::scoped_lock sl (mLock);
|
||||||
mLedgers.erase (hash);
|
mLedgers.erase (hash);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InboundLedgers::awaitLedgerData (uint256 const& ledgerHash)
|
bool InboundLedgers::awaitLedgerData (uint256 const& ledgerHash)
|
||||||
@@ -239,7 +245,6 @@ int InboundLedgers::getFetchCount (int& timeoutCount)
|
|||||||
timeoutCount = 0;
|
timeoutCount = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
|
||||||
std::vector<u256_acq_pair> inboundLedgers;
|
std::vector<u256_acq_pair> inboundLedgers;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -270,7 +275,6 @@ void InboundLedgers::gotFetchPack (Job&)
|
|||||||
boost::mutex::scoped_lock sl (mLock);
|
boost::mutex::scoped_lock sl (mLock);
|
||||||
|
|
||||||
acquires.reserve (mLedgers.size ());
|
acquires.reserve (mLedgers.size ());
|
||||||
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
|
||||||
BOOST_FOREACH (const u256_acq_pair & it, mLedgers)
|
BOOST_FOREACH (const u256_acq_pair & it, mLedgers)
|
||||||
{
|
{
|
||||||
assert (it.second);
|
assert (it.second);
|
||||||
@@ -296,7 +300,6 @@ Json::Value InboundLedgers::getInfo()
|
|||||||
{
|
{
|
||||||
Json::Value ret(Json::objectValue);
|
Json::Value ret(Json::objectValue);
|
||||||
|
|
||||||
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
|
||||||
std::vector<u256_acq_pair> acquires;
|
std::vector<u256_acq_pair> acquires;
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock sl (mLock);
|
boost::mutex::scoped_lock sl (mLock);
|
||||||
|
|||||||
Reference in New Issue
Block a user