Fetch pack bugfixes.

This commit is contained in:
JoelKatz
2013-04-22 10:29:54 -07:00
parent 965f33e222
commit 94838b0db7
4 changed files with 26 additions and 4 deletions

View File

@@ -368,8 +368,6 @@ void LedgerAcquire::trigger(Peer::ref peer)
ripple::TMGetObjectByHash tmBH; ripple::TMGetObjectByHash tmBH;
tmBH.set_query(true); tmBH.set_query(true);
tmBH.set_ledgerhash(mHash.begin(), mHash.size()); tmBH.set_ledgerhash(mHash.begin(), mHash.size());
if (mHaveBase)
tmBH.set_seq(mLedger->getLedgerSeq());
bool typeSet = false; bool typeSet = false;
BOOST_FOREACH(neededHash_t& p, need) BOOST_FOREACH(neededHash_t& p, need)
{ {

View File

@@ -1264,6 +1264,12 @@ Json::Value NetworkOPs::getServerInfo(bool human, bool admin)
info["complete_ledgers"] = theApp->getLedgerMaster().getCompleteLedgers(); info["complete_ledgers"] = theApp->getLedgerMaster().getCompleteLedgers();
size_t fp = mFetchPack.getCacheSize();
if (fp != 0)
info["fetch_pack"] = Json::UInt(fp);
info["peers"] = theApp->getConnectionPool().getPeerCount(); info["peers"] = theApp->getConnectionPool().getPeerCount();
Json::Value lastClose = Json::objectValue; Json::Value lastClose = Json::objectValue;
@@ -2008,6 +2014,7 @@ void NetworkOPs::makeFetchPack(Job&, boost::weak_ptr<Peer> wPeer, boost::shared_
if (request->has_seq()) if (request->has_seq())
reply.set_seq(request->seq()); reply.set_seq(request->seq());
reply.set_ledgerhash(reply.ledgerhash()); reply.set_ledgerhash(reply.ledgerhash());
reply.set_type(ripple::TMGetObjectByHash::otFETCH_PACK);
do do
{ {
@@ -2061,6 +2068,7 @@ bool NetworkOPs::getFetchPack(const uint256& hash, std::vector<unsigned char>& d
bool ret = mFetchPack.retrieve(hash, data); bool ret = mFetchPack.retrieve(hash, data);
if (!ret) if (!ret)
return false; return false;
mFetchPack.del(hash, false);
if (hash != Serializer::getSHA512Half(data)) if (hash != Serializer::getSHA512Half(data))
{ {
cLog(lsWARNING) << "Bad entry in fetch pack"; cLog(lsWARNING) << "Bad entry in fetch pack";

View File

@@ -506,6 +506,22 @@ std::list<SHAMap::fetchPackEntry_t> SHAMap::getFetchPack(SHAMap* have, bool incl
{ {
std::list<fetchPackEntry_t> ret; std::list<fetchPackEntry_t> ret;
boost::recursive_mutex::scoped_lock ul1(mLock);
UPTR_T< boost::unique_lock<boost::recursive_mutex> > ul2;
if (have)
{
UPTR_T< boost::unique_lock<boost::recursive_mutex> > ul3(
new boost::unique_lock<boost::recursive_mutex>(have->mLock, boost::try_to_lock));
if (!(*ul3))
{
cLog(lsINFO) << "Unable to create pack due to lock";
return ret;
}
ul2.swap(ul3);
}
if (root->isLeaf()) if (root->isLeaf())
{ {
if (includeLeaves && !root->getNodeHash().isZero() && if (includeLeaves && !root->getNodeHash().isZero() &&
@@ -566,7 +582,7 @@ std::list<SHAMap::fetchPackEntry_t> SHAMap::getFetchPack(SHAMap* have, bool incl
break; break;
} }
cLog(lsINFO) << "Fetch pack has " << ret.size() << " entries"; cLog(lsINFO) << "Made pack with " << ret.size() << " entries";
return ret; return ret;
} }

View File

@@ -232,7 +232,7 @@ template<typename c_Key, typename c_Data> bool TaggedCache<c_Key, c_Data>::del(c
if (!valid || entry.isExpired()) if (!valid || entry.isExpired())
mCache.erase(cit); mCache.erase(cit);
return true; return ret;
} }
template<typename c_Key, typename c_Data> template<typename c_Key, typename c_Data>