New MasterLockType which tracks ownership

This commit is contained in:
Vinnie Falco
2013-07-18 09:22:04 -07:00
parent 8b1592e494
commit 959e0bd512
13 changed files with 899 additions and 761 deletions

View File

@@ -972,9 +972,6 @@
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_RandomNumbers.h">
<Filter>[1] Ripple\ripple_basics\utility</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_ScopedLock.h">
<Filter>[1] Ripple\ripple_basics\utility</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_StringUtilities.h">
<Filter>[1] Ripple\ripple_basics\utility</Filter>
</ClInclude>
@@ -1692,6 +1689,9 @@
<ClInclude Include="..\..\modules\ripple_app\node\ripple_MdbBackendFactory.h">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_ScopedLock.h">
<Filter>[1] Ripple\ripple_basics\utility</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\cpp\ripple\ripple.proto" />

View File

@@ -155,10 +155,10 @@ namespace ripple
#include "src/cpp/ripple/TransactionMaster.h"
#include "src/cpp/ripple/ripple_LocalCredentials.h"
#include "src/cpp/ripple/WSDoor.h"
#include "src/cpp/ripple/ripple_Application.h"
#include "src/cpp/ripple/RPCHandler.h"
#include "src/cpp/ripple/TransactionQueue.h"
#include "ledger/OrderBookDB.h"
#include "src/cpp/ripple/ripple_Application.h"
#include "src/cpp/ripple/CallRPC.h"
#include "src/cpp/ripple/Transactor.h"
#include "src/cpp/ripple/ChangeTransactor.h"

View File

@@ -37,7 +37,7 @@ public:
};
// A class that unlocks on construction and locks on destruction
/*
class ScopedUnlock
{
protected:
@@ -80,5 +80,6 @@ private:
ScopedUnlock (const ScopedUnlock&); // no implementation
ScopedUnlock& operator= (const ScopedUnlock&); // no implementation
};
*/
#endif

View File

@@ -42,8 +42,10 @@ NetworkOPs::NetworkOPs (LedgerMaster* pLedgerMaster)
void NetworkOPs::processNetTimer ()
{
ScopedLock sl (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
// VFALCO NOTE This is for diagnosing a crash on exit
Application& app (getApp ());
ILoadManager& mgr (app.getLoadManager ());
@@ -86,6 +88,7 @@ void NetworkOPs::processNetTimer ()
if (mConsensus)
mConsensus->timerEntry ();
}
}
void NetworkOPs::onDeadlineTimer (DeadlineTimer& timer)
@@ -309,7 +312,8 @@ void NetworkOPs::runTransactionQueue ()
{
LoadEvent::autoptr ev = getApp().getJobQueue ().getLoadEventAP (jtTXN_PROC, "runTxnQ");
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
Transaction::pointer dbtx = getApp().getMasterTransaction ().fetch (txn->getID (), true);
assert (dbtx);
@@ -321,8 +325,8 @@ void NetworkOPs::runTransactionQueue ()
if (isTemMalformed (r)) // malformed, cache bad
getApp().getHashRouter ().setFlag (txn->getID (), SF_BAD);
// else if (isTelLocal (r) || isTerRetry (r)) // can be retried
// getApp().getHashRouter ().setFlag (txn->getID (), SF_RETRY);
// else if (isTelLocal (r) || isTerRetry (r)) // can be retried
// getApp().getHashRouter ().setFlag (txn->getID (), SF_RETRY);
if (isTerRetry (r))
@@ -351,10 +355,9 @@ void NetworkOPs::runTransactionQueue ()
dbtx->setStatus (INVALID);
}
// if (didApply || (mMode != omFULL))
if (didApply)
if (didApply /*|| (mMode != omFULL)*/ )
{
std::set<uint64> peers;
std::set <uint64> peers;
if (getApp().getHashRouter ().swapSet (txn->getID (), peers, SF_RELAYED))
{
@@ -376,6 +379,7 @@ void NetworkOPs::runTransactionQueue ()
txn->doCallbacks (r);
}
}
}
if (getApp().getTxnQueue ().stopProcessing (txn))
getApp().getIOService ().post (BIND_TYPE (&NetworkOPs::runTransactionQueue, this));
@@ -410,7 +414,9 @@ Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans,
getApp().getHashRouter ().setFlag (trans->getID (), SF_SIGGOOD);
}
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
bool didApply;
TER r = mLedgerMaster->doTransaction (trans->getSTransaction (),
bAdmin ? (tapOPEN_LEDGER | tapNO_CHECK_SIGN | tapADMIN) : (tapOPEN_LEDGER | tapNO_CHECK_SIGN), didApply);
@@ -418,11 +424,10 @@ Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans,
if (isTemMalformed (r)) // malformed, cache bad
getApp().getHashRouter ().setFlag (trans->getID (), SF_BAD);
// else if (isTelLocal (r) || isTerRetry (r)) // can be retried
// getApp().getHashRouter ().setFlag (trans->getID (), SF_RETRY);
// else if (isTelLocal (r) || isTerRetry (r)) // can be retried
// getApp().getHashRouter ().setFlag (trans->getID (), SF_RETRY);
#ifdef BEAST_DEBUG
if (r != tesSUCCESS)
{
std::string token, human;
@@ -483,6 +488,7 @@ Transaction::pointer NetworkOPs::processTransaction (Transaction::pointer trans,
getApp().getPeers ().relayMessageBut (peers, packet);
}
}
}
return trans;
}
@@ -958,7 +964,8 @@ uint256 NetworkOPs::getConsensusLCL ()
void NetworkOPs::processTrustedProposal (LedgerProposal::pointer proposal,
boost::shared_ptr<protocol::TMProposeSet> set, RippleAddress nodePublic, uint256 checkLedger, bool sigGood)
{
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
bool relay = true;
@@ -1000,7 +1007,10 @@ void NetworkOPs::processTrustedProposal (LedgerProposal::pointer proposal,
getApp().getPeers ().relayMessageBut (peers, message);
}
else
{
WriteLog (lsINFO, NetworkOPs) << "Not relaying trusted proposal";
}
}
}
SHAMap::pointer NetworkOPs::getTXMap (uint256 const& hash)
@@ -1042,8 +1052,10 @@ SHAMapAddNode NetworkOPs::gotTXData (const boost::shared_ptr<Peer>& peer, uint25
{
boost::shared_ptr<LedgerConsensus> consensus;
{
ScopedLock mlh(getApp().getMasterLock());
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
consensus = mConsensus;
}

View File

@@ -58,7 +58,7 @@ RPCHandler::RPCHandler (NetworkOPs* netOps, InfoSub::pointer infoSub) : mNetOps
;
}
Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool bFailHard, ScopedLock& mlh)
Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool bFailHard, Application::ScopedLockType& mlh)
{
if (getApp().getFeeTrack().isLoadedCluster() && (mRole != ADMIN))
return rpcError(rpcTOO_BUSY);
@@ -595,7 +595,7 @@ Json::Value RPCHandler::accountFromString (Ledger::ref lrLedger, RippleAddress&
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -640,7 +640,7 @@ Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, S
// port: <number>
// }
// XXX Might allow domain for manual connections.
Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (theConfig.RUN_STANDALONE)
return "cannot connect in standalone mode";
@@ -661,7 +661,7 @@ Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, Scope
// {
// key: <string>
// }
Json::Value RPCHandler::doDataDelete (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doDataDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("key"))
return rpcError (rpcINVALID_PARAMS);
@@ -687,7 +687,7 @@ Json::Value RPCHandler::doDataDelete (Json::Value params, LoadType* loadType, Sc
// {
// key: <string>
// }
Json::Value RPCHandler::doDataFetch (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doDataFetch (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("key"))
return rpcError (rpcINVALID_PARAMS);
@@ -711,7 +711,7 @@ Json::Value RPCHandler::doDataFetch (Json::Value params, LoadType* loadType, Sco
// key: <string>
// value: <string>
// }
Json::Value RPCHandler::doDataStore (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doDataStore (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("key")
|| !params.isMember ("value"))
@@ -772,7 +772,7 @@ Json::Value RPCHandler::doNicknameInfo (Json::Value params)
// 'account_index' : <index> // optional
// }
// XXX This would be better if it took the ledger.
Json::Value RPCHandler::doOwnerInfo (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doOwnerInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("account") && !params.isMember ("ident"))
return rpcError (rpcINVALID_PARAMS);
@@ -797,7 +797,7 @@ Json::Value RPCHandler::doOwnerInfo (Json::Value params, LoadType* loadType, Sco
return ret;
}
Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value jvResult (Json::objectValue);
@@ -808,7 +808,7 @@ Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, ScopedLock& Ma
return jvResult;
}
Json::Value RPCHandler::doPing (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doPing (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
return Json::Value (Json::objectValue);
}
@@ -818,7 +818,7 @@ Json::Value RPCHandler::doPing (Json::Value, LoadType* loadType, ScopedLock& Mas
// issuer is the offering account
// --> submit: 'submit|true|false': defaults to false
// Prior to running allow each to have a credit line of what they will be getting from the other account.
Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
/* need to fix now that sharedOfferCreate is gone
int iArgs = params.size();
@@ -910,9 +910,9 @@ Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, Scope
// difficulty: <number> // optional
// secret: <secret> // optional
// }
Json::Value RPCHandler::doProofCreate (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doProofCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
// XXX: Add ability to create proof with arbitrary time
Json::Value jvResult (Json::objectValue);
@@ -955,9 +955,9 @@ Json::Value RPCHandler::doProofCreate (Json::Value params, LoadType* loadType, S
// {
// token: <token>
// }
Json::Value RPCHandler::doProofSolve (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doProofSolve (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
Json::Value jvResult;
@@ -985,9 +985,9 @@ Json::Value RPCHandler::doProofSolve (Json::Value params, LoadType* loadType, Sc
// difficulty: <number> // optional
// secret: <secret> // optional
// }
Json::Value RPCHandler::doProofVerify (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doProofVerify (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
// XXX Add ability to check proof against arbitrary time
Json::Value jvResult;
@@ -1055,7 +1055,7 @@ Json::Value RPCHandler::doProofVerify (Json::Value params, LoadType* loadType, S
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -1067,7 +1067,7 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType,
if (lpLedger->isImmutable ())
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
bUnlocked = true;
}
@@ -1140,7 +1140,7 @@ Json::Value RPCHandler::doAccountLines (Json::Value params, LoadType* loadType,
}
if (!bUnlocked)
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
}
else
{
@@ -1168,7 +1168,7 @@ static void offerAdder (Json::Value& jvLines, SLE::ref offer)
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -1180,7 +1180,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType,
if (lpLedger->isImmutable ())
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
bUnlocked = true;
}
@@ -1212,7 +1212,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType,
lpLedger->visitAccountItems (raAccount.getAccountID (), BIND_TYPE (&offerAdder, boost::ref (jvsOffers), P_1));
if (!bUnlocked)
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
return jvResult;
}
@@ -1227,7 +1227,7 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, LoadType* loadType,
// "limit" : integer, // Optional.
// "proof" : boolean // Defaults to false.
// }
Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (getApp().getJobQueue ().getJobCountGE (jtCLIENT) > 200)
{
@@ -1241,7 +1241,7 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Sc
return jvResult;
if (lpLedger->isImmutable ())
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
if (!params.isMember ("taker_pays") || !params.isMember ("taker_gets") || !params["taker_pays"].isObject () || !params["taker_gets"].isObject ())
return rpcError (rpcINVALID_PARAMS);
@@ -1328,9 +1328,9 @@ Json::Value RPCHandler::doBookOffers (Json::Value params, LoadType* loadType, Sc
// {
// random: <uint256>
// }
Json::Value RPCHandler::doRandom (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doRandom (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
uint256 uRandom;
try
@@ -1349,7 +1349,7 @@ Json::Value RPCHandler::doRandom (Json::Value params, LoadType* loadType, Scoped
}
}
Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("subcommand") || !params["subcommand"].isString ())
return rpcError (rpcINVALID_PARAMS);
@@ -1404,7 +1404,7 @@ Json::Value RPCHandler::doPathFind (Json::Value params, LoadType* loadType, Scop
// - Allows clients to verify path exists.
// - Return canonicalized path.
// - From a trusted server, allows clients to use path without manipulation.
Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
int jc = getApp().getJobQueue ().getJobCountGE (jtCLIENT);
@@ -1487,7 +1487,7 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
*loadType = LT_RPCBurden;
Ledger::pointer lSnapShot = boost::make_shared<Ledger> (boost::ref (*lpLedger), false);
MasterLockHolder.unlock (); // As long as we have a locked copy of the ledger, we can unlock.
masterLockHolder.unlock (); // As long as we have a locked copy of the ledger, we can unlock.
// Fill in currencies destination will accept
Json::Value jvDestCur (Json::arrayValue);
@@ -1636,23 +1636,23 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
// tx_json: <object>,
// secret: <secret>
// }
Json::Value RPCHandler::doSign (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doSign (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
*loadType = LT_RPCBurden;
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
return transactionSign (params, false, bFailHard, MasterLockHolder);
return transactionSign (params, false, bFailHard, masterLockHolder);
}
// {
// tx_json: <object>,
// secret: <secret>
// }
Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("tx_blob"))
{
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
return transactionSign (params, true, bFailHard, MasterLockHolder);
return transactionSign (params, true, bFailHard, masterLockHolder);
}
Json::Value jvResult;
@@ -1710,7 +1710,7 @@ Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Scoped
return jvResult;
}
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
try
{
@@ -1740,7 +1740,7 @@ Json::Value RPCHandler::doSubmit (Json::Value params, LoadType* loadType, Scoped
}
}
Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value ret (Json::objectValue);
@@ -1749,7 +1749,7 @@ Json::Value RPCHandler::doConsensusInfo (Json::Value, LoadType* loadType, Scoped
return ret;
}
Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value ret (Json::objectValue);
@@ -1758,7 +1758,7 @@ Json::Value RPCHandler::doServerInfo (Json::Value, LoadType* loadType, ScopedLoc
return ret;
}
Json::Value RPCHandler::doServerState (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doServerState (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value ret (Json::objectValue);
@@ -1770,9 +1770,9 @@ Json::Value RPCHandler::doServerState (Json::Value, LoadType* loadType, ScopedLo
// {
// start: <index>
// }
Json::Value RPCHandler::doTxHistory (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doTxHistory (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
if (!params.isMember ("start"))
return rpcError (rpcINVALID_PARAMS);
@@ -1807,7 +1807,7 @@ Json::Value RPCHandler::doTxHistory (Json::Value params, LoadType* loadType, Sco
// {
// transaction: <hex>
// }
Json::Value RPCHandler::doTx (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doTx (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("transaction"))
return rpcError (rpcINVALID_PARAMS);
@@ -1873,7 +1873,7 @@ Json::Value RPCHandler::doTx (Json::Value params, LoadType* loadType, ScopedLock
return rpcError (rpcNOT_IMPL);
}
Json::Value RPCHandler::doLedgerClosed (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLedgerClosed (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value jvResult;
@@ -1886,7 +1886,7 @@ Json::Value RPCHandler::doLedgerClosed (Json::Value, LoadType* loadType, ScopedL
return jvResult;
}
Json::Value RPCHandler::doLedgerCurrent (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLedgerCurrent (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value jvResult;
@@ -1900,7 +1900,7 @@ Json::Value RPCHandler::doLedgerCurrent (Json::Value, LoadType* loadType, Scoped
// ledger: 'current' | 'closed' | <uint256> | <number>, // optional
// full: true | false // optional, defaults to false.
// }
Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("ledger") && !params.isMember ("ledger_hash") && !params.isMember ("ledger_index"))
{
@@ -1922,7 +1922,7 @@ Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Scoped
return jvResult;
if (lpLedger->isImmutable ())
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
bool bFull = params.isMember ("full") && params["full"].asBool ();
bool bTransactions = params.isMember ("transactions") && params["transactions"].asBool ();
@@ -1949,7 +1949,7 @@ Json::Value RPCHandler::doLedger (Json::Value params, LoadType* loadType, Scoped
// offset: integer, // optional, defaults to 0
// limit: integer // optional
// }
Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
RippleAddress raAccount;
uint32 offset = params.isMember ("offset") ? params["offset"].asUInt () : 0;
@@ -2018,7 +2018,7 @@ Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loa
try
{
#endif
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
Json::Value ret (Json::objectValue);
@@ -2094,7 +2094,7 @@ Json::Value RPCHandler::doAccountTransactions (Json::Value params, LoadType* loa
// }
//
// This command requires admin access because it makes no sense to ask an untrusted server for this.
Json::Value RPCHandler::doValidationCreate (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doValidationCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
RippleAddress raSeed;
Json::Value obj (Json::objectValue);
@@ -2120,7 +2120,7 @@ Json::Value RPCHandler::doValidationCreate (Json::Value params, LoadType* loadTy
// {
// secret: <string>
// }
Json::Value RPCHandler::doValidationSeed (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doValidationSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value obj (Json::objectValue);
@@ -2191,7 +2191,7 @@ Json::Value RPCHandler::accounts (Ledger::ref lrLedger, const RippleAddress& naM
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doWalletAccounts (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doWalletAccounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -2234,7 +2234,7 @@ Json::Value RPCHandler::doWalletAccounts (Json::Value params, LoadType* loadType
}
}
Json::Value RPCHandler::doLogRotate (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLogRotate (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
return Log::rotateLog ();
}
@@ -2242,9 +2242,9 @@ Json::Value RPCHandler::doLogRotate (Json::Value, LoadType* loadType, ScopedLock
// {
// passphrase: <string>
// }
Json::Value RPCHandler::doWalletPropose (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doWalletPropose (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
RippleAddress naSeed;
RippleAddress naAccount;
@@ -2274,7 +2274,7 @@ Json::Value RPCHandler::doWalletPropose (Json::Value params, LoadType* loadType,
// {
// secret: <string>
// }
Json::Value RPCHandler::doWalletSeed (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doWalletSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
RippleAddress raSeed;
bool bSecret = params.isMember ("secret");
@@ -2313,7 +2313,7 @@ Json::Value RPCHandler::doWalletSeed (Json::Value params, LoadType* loadType, Sc
// username: <string>,
// password: <string>
// }
Json::Value RPCHandler::doLogin (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLogin (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("username")
|| !params.isMember ("password"))
@@ -2351,7 +2351,7 @@ static void textTime (std::string& text, int& seconds, const char* unitName, int
text += "s";
}
Json::Value RPCHandler::doFeature (Json::Value params, LoadType* loadType, ScopedLock& mlh)
Json::Value RPCHandler::doFeature (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh)
{
if (!params.isMember ("feature"))
{
@@ -2380,7 +2380,7 @@ Json::Value RPCHandler::doFeature (Json::Value params, LoadType* loadType, Scope
// {
// min_count: <number> // optional, defaults to 10
// }
Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
int minCount = 10;
@@ -2432,7 +2432,7 @@ Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, Sco
return ret;
}
Json::Value RPCHandler::doLogLevel (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLogLevel (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
// log_level
if (!params.isMember ("severity"))
@@ -2485,7 +2485,7 @@ Json::Value RPCHandler::doLogLevel (Json::Value params, LoadType* loadType, Scop
// node: <domain>|<node_public>,
// comment: <comment> // optional
// }
Json::Value RPCHandler::doUnlAdd (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doUnlAdd (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
std::string strNode = params.isMember ("node") ? params["node"].asString () : "";
std::string strComment = params.isMember ("comment") ? params["comment"].asString () : "";
@@ -2509,7 +2509,7 @@ Json::Value RPCHandler::doUnlAdd (Json::Value params, LoadType* loadType, Scoped
// {
// node: <domain>|<public_key>
// }
Json::Value RPCHandler::doUnlDelete (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doUnlDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("node"))
return rpcError (rpcINVALID_PARAMS);
@@ -2532,7 +2532,7 @@ Json::Value RPCHandler::doUnlDelete (Json::Value params, LoadType* loadType, Sco
}
}
Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value obj (Json::objectValue);
@@ -2542,7 +2542,7 @@ Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, ScopedLock&
}
// Populate the UNL from a local validators.txt file.
Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (theConfig.VALIDATORS_FILE.empty () || !getApp().getUNL ().nodeLoad (theConfig.VALIDATORS_FILE))
{
@@ -2554,7 +2554,7 @@ Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, ScopedLock&
// Populate the UNL from ripple.com's validators.txt file.
Json::Value RPCHandler::doUnlNetwork (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doUnlNetwork (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
getApp().getUNL ().nodeNetwork ();
@@ -2562,7 +2562,7 @@ Json::Value RPCHandler::doUnlNetwork (Json::Value params, LoadType* loadType, Sc
}
// unl_reset
Json::Value RPCHandler::doUnlReset (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doUnlReset (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
getApp().getUNL ().nodeReset ();
@@ -2570,14 +2570,14 @@ Json::Value RPCHandler::doUnlReset (Json::Value params, LoadType* loadType, Scop
}
// unl_score
Json::Value RPCHandler::doUnlScore (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doUnlScore (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
getApp().getUNL ().nodeScore ();
return "scoring requested";
}
Json::Value RPCHandler::doSMS (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doSMS (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (!params.isMember ("text"))
return rpcError (rpcINVALID_PARAMS);
@@ -2586,14 +2586,14 @@ Json::Value RPCHandler::doSMS (Json::Value params, LoadType* loadType, ScopedLoc
return "sms dispatched";
}
Json::Value RPCHandler::doStop (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doStop (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
getApp().stop ();
return SYSTEM_NAME " server stopping";
}
Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Json::Value jvResult;
@@ -2616,7 +2616,7 @@ Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, ScopedL
// ledger_index : <ledger_index>
// }
// XXX In this case, not specify either ledger does not mean ledger current. It means any ledger.
Json::Value RPCHandler::doTransactionEntry (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doTransactionEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -2785,7 +2785,7 @@ Json::Value RPCHandler::lookupLedger (Json::Value params, Ledger::pointer& lpLed
// ledger_index : <ledger_index>
// ...
// }
Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -2794,7 +2794,7 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, S
return jvResult;
if (lpLedger->isImmutable ())
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
uint256 uNodeIndex;
bool bNodeBinary = false;
@@ -2998,7 +2998,7 @@ Json::Value RPCHandler::doLedgerEntry (Json::Value params, LoadType* loadType, S
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// }
Json::Value RPCHandler::doLedgerHeader (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doLedgerHeader (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
Ledger::pointer lpLedger;
Json::Value jvResult = lookupLedger (params, lpLedger);
@@ -3040,7 +3040,7 @@ boost::unordered_set<RippleAddress> RPCHandler::parseAccountIds (const Json::Val
return usnaResult;
}
Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
InfoSub::pointer ispSub;
Json::Value jvResult (Json::objectValue);
@@ -3332,7 +3332,7 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, Sco
}
// FIXME: This leaks RPCSub objects for JSON-RPC. Shouldn't matter for anyone sane.
Json::Value RPCHandler::doUnsubscribe (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doUnsubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
InfoSub::pointer ispSub;
Json::Value jvResult (Json::objectValue);
@@ -3554,7 +3554,7 @@ Json::Value RPCHandler::doRpcCommand (const std::string& strMethod, Json::Value
return jvResult;
}
Json::Value RPCHandler::doInternal (Json::Value params, LoadType* loadType, ScopedLock& MasterLockHolder)
Json::Value RPCHandler::doInternal (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
// Used for debug or special-purpose RPC commands
if (!params.isMember ("internal_command"))
@@ -3676,7 +3676,8 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, LoadTyp
return rpcError (rpcNO_PERMISSION);
}
ScopedLock MasterLockHolder (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
if ((commandsA[i].iOptions & optNetwork) && (mNetOps->getOperatingMode () < NetworkOPs::omSYNCING))
{
@@ -3697,7 +3698,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, LoadTyp
{
try
{
Json::Value jvRaw = (this->* (commandsA[i].dfpFunc)) (params, loadType, MasterLockHolder);
Json::Value jvRaw = (this->* (commandsA[i].dfpFunc)) (params, loadType, lock);
// Regularize result.
if (jvRaw.isObject ())
@@ -3725,6 +3726,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, LoadTyp
return rpcError (rpcINTERNAL);
}
}
}
}
RPCInternalHandler* RPCInternalHandler::sHeadHandler = NULL;

View File

@@ -40,7 +40,7 @@ private:
typedef Json::Value (RPCHandler::*doFuncPtr) (
Json::Value params,
LoadType* loadType,
ScopedLock& MasterLockHolder);
Application::ScopedLockType& MasterLockHolder);
// VFALCO TODO Document these and give the enumeration a label.
enum
@@ -57,7 +57,7 @@ private:
boost::unordered_set <RippleAddress> parseAccountIds (const Json::Value& jvArray);
Json::Value transactionSign (Json::Value jvRequest, bool bSubmit, bool bFailHard, ScopedLock& mlh);
Json::Value transactionSign (Json::Value jvRequest, bool bSubmit, bool bFailHard, Application::ScopedLockType& mlh);
Json::Value lookupLedger (Json::Value jvRequest, Ledger::pointer& lpLedger);
@@ -89,70 +89,70 @@ private:
const int iIndex,
const bool bStrict);
Json::Value doAccountInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doAccountLines (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doAccountOffers (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doAccountTransactions (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doBookOffers (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doConnect (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doConsensusInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doFeature (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doGetCounts (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doInternal (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLedger (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLedgerAccept (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLedgerClosed (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLedgerCurrent (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLedgerEntry (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLedgerHeader (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLogLevel (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLogRotate (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doNicknameInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doOwnerInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doPathFind (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doPeers (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doPing (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doProfile (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doProofCreate (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doProofSolve (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doProofVerify (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doRandom (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doRipplePathFind (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doSMS (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doServerInfo (Json::Value params, LoadType* loadType, ScopedLock& mlh); // for humans
Json::Value doServerState (Json::Value params, LoadType* loadType, ScopedLock& mlh); // for machines
Json::Value doSessionClose (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doSessionOpen (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doSign (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doStop (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doSubmit (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doSubscribe (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doTransactionEntry (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doTx (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doTxHistory (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnlAdd (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnlDelete (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnlFetch (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnlList (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnlLoad (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnlNetwork (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnlReset (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnlScore (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doUnsubscribe (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doValidationCreate (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doValidationSeed (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doWalletAccounts (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doWalletLock (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doWalletPropose (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doWalletSeed (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doWalletUnlock (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doWalletVerify (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doAccountInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doAccountLines (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doAccountOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doAccountTransactions (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doBookOffers (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doConnect (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doConsensusInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doFeature (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doGetCounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doInternal (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLedger (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLedgerAccept (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLedgerClosed (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLedgerCurrent (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLedgerEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLedgerHeader (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLogLevel (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLogRotate (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doNicknameInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doOwnerInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doPathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doPeers (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doPing (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doProfile (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doProofCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doProofSolve (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doProofVerify (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doRandom (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doRipplePathFind (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doSMS (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doServerInfo (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh); // for humans
Json::Value doServerState (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh); // for machines
Json::Value doSessionClose (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doSessionOpen (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doSign (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doStop (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doSubmit (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doSubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doTransactionEntry (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doTx (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doTxHistory (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnlAdd (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnlDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnlFetch (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnlList (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnlLoad (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnlNetwork (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnlReset (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnlScore (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doUnsubscribe (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doValidationCreate (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doValidationSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doWalletAccounts (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doWalletLock (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doWalletPropose (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doWalletSeed (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doWalletUnlock (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doWalletVerify (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
#if ENABLE_INSECURE
Json::Value doDataDelete (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doDataFetch (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doDataStore (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doLogin (Json::Value params, LoadType* loadType, ScopedLock& mlh);
Json::Value doDataDelete (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doDataFetch (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doDataStore (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
Json::Value doLogin (Json::Value params, LoadType* loadType, Application::ScopedLockType& mlh);
#endif
private:

View File

@@ -43,8 +43,8 @@ public:
#endif
, mIOService ((theConfig.NODE_SIZE >= 2) ? 2 : 1)
, mIOWork (mIOService)
, mNetOps (&mLedgerMaster)
, m_rpcServerHandler (mNetOps)
, mNetOps (new NetworkOPs (&mLedgerMaster))
, m_rpcServerHandler (*mNetOps)
, mTempNodeCache ("NodeCache", 16384, 90)
, m_nodeStore (NodeStore::New (
theConfig.NODE_DB,
@@ -84,6 +84,8 @@ public:
~ApplicationImp ()
{
mNetOps = nullptr;
// VFALCO TODO Wrap these in ScopedPointer
delete mTxnDB;
delete mLedgerDB;
@@ -97,7 +99,7 @@ public:
NetworkOPs& getOPs ()
{
return mNetOps;
return *mNetOps;
}
boost::asio::io_service& getIOService ()
@@ -135,7 +137,7 @@ public:
return mJobQueue;
}
boost::recursive_mutex& getMasterLock ()
MasterLockType& getMasterLock ()
{
return mMasterLock;
}
@@ -261,13 +263,13 @@ private:
//
boost::asio::io_service::work mIOWork;
boost::recursive_mutex mMasterLock;
MasterLockType mMasterLock;
LocalCredentials m_localCredentials;
LedgerMaster mLedgerMaster;
InboundLedgers m_inboundLedgers;
TransactionMaster mMasterTransaction;
NetworkOPs mNetOps;
ScopedPointer <NetworkOPs> mNetOps;
RPCServerHandler m_rpcServerHandler;
NodeCache mTempNodeCache;
ScopedPointer <NodeStore> m_nodeStore;
@@ -441,7 +443,7 @@ void ApplicationImp::setup ()
{
// This should probably become the default once we have a stable network
if (!theConfig.RUN_STANDALONE)
mNetOps.needNetworkLedger ();
mNetOps->needNetworkLedger ();
startNewLedger ();
}
@@ -572,13 +574,13 @@ void ApplicationImp::setup ()
{
WriteLog (lsWARNING, Application) << "Running in standalone mode";
mNetOps.setStandAlone ();
mNetOps->setStandAlone ();
}
else
{
// VFALCO NOTE the state timer resets the deadlock detector.
//
mNetOps.setStateTimer ();
mNetOps->setStateTimer ();
}
}
@@ -653,8 +655,8 @@ void ApplicationImp::doSweep(Job& j)
mSLECache.sweep ();
AcceptedLedger::sweep (); // VFALCO NOTE AcceptedLedger is/has a singleton?
SHAMap::sweep (); // VFALCO NOTE SHAMap is/has a singleton?
mNetOps.sweepFetchPack ();
mNetOps->sweepFetchPack ();
// VFALCO NOTE does the call to sweep() happen on another thread?
mSweepTimer.expires_from_now (boost::posix_time::seconds (theConfig.getSize (siSweepInterval)));
mSweepTimer.async_wait (BIND_TYPE (&ApplicationImp::sweep, this));
}
@@ -685,7 +687,7 @@ void ApplicationImp::startNewLedger ()
secondLedger->setAccepted ();
mLedgerMaster.pushLedger (secondLedger, boost::make_shared<Ledger> (true, boost::ref (*secondLedger)), false);
assert (!!secondLedger->getAccountState (rootAddress));
mNetOps.setLastCloseTime (secondLedger->getCloseTimeNC ());
mNetOps->setLastCloseTime (secondLedger->getCloseTimeNC ());
}
}
@@ -753,7 +755,7 @@ bool ApplicationImp::loadOldLedger (const std::string& l, bool bReplay)
Ledger::pointer openLedger = boost::make_shared<Ledger> (false, boost::ref (*loadLedger));
mLedgerMaster.switchLedgers (loadLedger, openLedger);
mLedgerMaster.forceValid(loadLedger);
mNetOps.setLastCloseTime (loadLedger->getCloseTimeNC ());
mNetOps->setLastCloseTime (loadLedger->getCloseTimeNC ());
if (bReplay)
{ // inject transaction from replayLedger into consensus set

View File

@@ -38,8 +38,6 @@ typedef TaggedCache <uint256, SerializedLedgerEntry, UptimeTimerAdapter> SLECach
class Application
{
public:
virtual ~Application () { }
/* VFALCO NOTE
The master lock protects:
@@ -51,7 +49,110 @@ public:
other things
*/
virtual boost::recursive_mutex& getMasterLock () = 0;
#if 1
class ScopedLockType;
class MasterLockType
{
public:
MasterLockType ()
: m_fileName ("")
, m_lineNumber (0)
{
}
// Note that these are not exactly thread safe.
char const* getFileName () const noexcept
{
return m_fileName;
}
int getLineNumber () const noexcept
{
return m_lineNumber;
}
private:
friend class ScopedLockType;
void setOwner (char const* fileName, int lineNumber)
{
m_fileName = fileName;
m_lineNumber = lineNumber;
}
void resetOwner ()
{
m_fileName = "";
m_lineNumber = 0;
}
boost::recursive_mutex m_mutex;
char const* m_fileName;
int m_lineNumber;
};
class ScopedLockType
{
public:
explicit ScopedLockType (MasterLockType& mutex,
char const* fileName,
int lineNumber)
: m_mutex (mutex)
, m_lock (mutex.m_mutex)
{
mutex.setOwner (fileName, lineNumber);
}
~ScopedLockType ()
{
if (m_lock.owns_lock ())
m_mutex.resetOwner ();
}
void unlock ()
{
if (m_lock.owns_lock ())
m_mutex.resetOwner ();
m_lock.unlock ();
}
private:
MasterLockType& m_mutex;
boost::recursive_mutex::scoped_lock m_lock;
};
#else
typedef boost::recursive_mutex MasterLockType;
typedef boost::recursive_mutex::scoped_lock ScopedLockType;
#endif
virtual MasterLockType& getMasterLock () = 0;
public:
struct State
{
// Stuff in here is accessed concurrently and requires a WriteAccess
};
typedef SharedData <State> SharedState;
SharedState& getSharedState () noexcept { return m_sharedState; }
SharedState const& getSharedState () const noexcept { return m_sharedState; }
private:
SharedState m_sharedState;
public:
virtual ~Application () { }
virtual boost::asio::io_service& getIOService () = 0;

View File

@@ -1179,7 +1179,9 @@ void LedgerConsensus::accept (SHAMap::ref set, LoadEvent::pointer)
if (set->getHash ().isNonZero ()) // put our set where others can get it later
getApp().getOPs ().takePosition (mPreviousLedger->getLedgerSeq (), set);
boost::recursive_mutex::scoped_lock masterLock (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
assert (set->getHash () == mOurPosition->getCurrentHash ());
getApp().getOPs ().peekStoredProposals ().clear (); // these are now obsolete
@@ -1327,7 +1329,7 @@ void LedgerConsensus::accept (SHAMap::ref set, LoadEvent::pointer)
WriteLog (lsINFO, LedgerConsensus) << "Our close offset is estimated at " << offset << " (" << closeCount << ")";
getApp().getOPs ().closeTimeOffset (offset);
}
}
}
void LedgerConsensus::endConsensus ()

View File

@@ -250,6 +250,11 @@ private:
static void logDeadlock (int dlTime)
{
WriteLog (lsWARNING, LoadManager) << "Server stalled for " << dlTime << " seconds.";
char const* fileName = getApp ().getMasterLock ().getFileName ();
int lineNumber = getApp ().getMasterLock ().getLineNumber ();
WriteLog (lsWARNING, LoadManager) << "Master lock owned by " << File (fileName).getFileName ().toStdString () << ", line " << lineNumber;
}
private:

View File

@@ -165,12 +165,12 @@ private:
void recvHello (protocol::TMHello & packet);
void recvCluster (protocol::TMCluster & packet);
void recvTransaction (protocol::TMTransaction & packet, ScopedLock & MasterLockHolder);
void recvValidation (const boost::shared_ptr<protocol::TMValidation>& packet, ScopedLock & MasterLockHolder);
void recvTransaction (protocol::TMTransaction & packet, Application::ScopedLockType& masterLockHolder);
void recvValidation (const boost::shared_ptr<protocol::TMValidation>& packet, Application::ScopedLockType& masterLockHolder);
void recvGetValidation (protocol::TMGetValidations & packet);
void recvContact (protocol::TMContact & packet);
void recvGetContacts (protocol::TMGetContacts & packet);
void recvGetPeers (protocol::TMGetPeers & packet, ScopedLock & MasterLockHolder);
void recvGetPeers (protocol::TMGetPeers & packet, Application::ScopedLockType& masterLockHolder);
void recvPeers (protocol::TMPeers & packet);
void recvGetObjectByHash (const boost::shared_ptr<protocol::TMGetObjectByHash>& packet);
void recvPing (protocol::TMPing & packet);
@@ -178,8 +178,8 @@ private:
void recvSearchTransaction (protocol::TMSearchTransaction & packet);
void recvGetAccount (protocol::TMGetAccount & packet);
void recvAccount (protocol::TMAccount & packet);
void recvGetLedger (protocol::TMGetLedger & packet, ScopedLock & MasterLockHolder);
void recvLedger (const boost::shared_ptr<protocol::TMLedgerData>& packet, ScopedLock & MasterLockHolder);
void recvGetLedger (protocol::TMGetLedger & packet, Application::ScopedLockType& masterLockHolder);
void recvLedger (const boost::shared_ptr<protocol::TMLedgerData>& packet, Application::ScopedLockType& masterLockHolder);
void recvStatus (protocol::TMStatusChange & packet);
void recvPropose (const boost::shared_ptr<protocol::TMProposeSet>& packet);
void recvHaveTxSet (protocol::TMHaveTransactionSet & packet);
@@ -630,8 +630,11 @@ void PeerImp::handleReadBody (const boost::system::error_code& error)
WriteLog (lsINFO, Peer) << "Peer: Body: Error: " << getIP () << ": " << error.category ().name () << ": " << error.message () << ": " << error;
}
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
detach ("hrb", true);
}
return;
}
@@ -651,7 +654,8 @@ void PeerImp::processReadBuffer ()
LoadEvent::autoptr event (getApp().getJobQueue ().getLoadEventAP (jtPEER, "PeerImp::read"));
ScopedLock sl (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
// If connected and get a mtHELLO or if not connected and get a non-mtHELLO, wrong message was sent.
if (mHelloed == (type == protocol::mtHELLO))
@@ -740,7 +744,7 @@ void PeerImp::processReadBuffer ()
protocol::TMGetPeers msg;
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
recvGetPeers (msg, sl);
recvGetPeers (msg, lock);
else
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
@@ -800,7 +804,7 @@ void PeerImp::processReadBuffer ()
protocol::TMTransaction msg;
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
recvTransaction (msg, sl);
recvTransaction (msg, lock);
else
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
@@ -836,7 +840,7 @@ void PeerImp::processReadBuffer ()
protocol::TMGetLedger msg;
if (msg.ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
recvGetLedger (msg, sl);
recvGetLedger (msg, lock);
else
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
@@ -848,7 +852,7 @@ void PeerImp::processReadBuffer ()
boost::shared_ptr<protocol::TMLedgerData> msg = boost::make_shared<protocol::TMLedgerData> ();
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
recvLedger (msg, sl);
recvLedger (msg, lock);
else
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
@@ -872,12 +876,12 @@ void PeerImp::processReadBuffer ()
boost::shared_ptr<protocol::TMValidation> msg = boost::make_shared<protocol::TMValidation> ();
if (msg->ParseFromArray (&mReadbuf[PackedMessage::kHeaderBytes], mReadbuf.size () - PackedMessage::kHeaderBytes))
recvValidation (msg, sl);
recvValidation (msg, lock);
else
WriteLog (lsWARNING, Peer) << "parse error: " << type;
}
break;
#if 0
#if 0
case protocol::mtGET_VALIDATION:
{
@@ -890,7 +894,7 @@ void PeerImp::processReadBuffer ()
}
break;
#endif
#endif
case protocol::mtGET_OBJECTS:
{
@@ -923,6 +927,7 @@ void PeerImp::processReadBuffer ()
WriteLog (lsWARNING, Peer) << strHex (&mReadbuf[0], mReadbuf.size ());
}
}
}
}
void PeerImp::recvHello (protocol::TMHello& packet)
@@ -1111,9 +1116,9 @@ static void checkTransaction (Job&, int flags, SerializedTransaction::pointer st
#endif
}
void PeerImp::recvTransaction (protocol::TMTransaction& packet, ScopedLock& MasterLockHolder)
void PeerImp::recvTransaction (protocol::TMTransaction& packet, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
Transaction::pointer tx;
#ifndef TRUST_NETWORK
@@ -1375,9 +1380,9 @@ static void checkValidation (Job&, SerializedValidation::pointer val, uint256 si
#endif
}
void PeerImp::recvValidation (const boost::shared_ptr<protocol::TMValidation>& packet, ScopedLock& MasterLockHolder)
void PeerImp::recvValidation (const boost::shared_ptr<protocol::TMValidation>& packet, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
if (packet->validation ().size () < 50)
{
@@ -1463,9 +1468,9 @@ void PeerImp::recvGetContacts (protocol::TMGetContacts& packet)
// Return a list of your favorite people
// TODO: filter out all the LAN peers
// TODO: filter out the peer you are talking to
void PeerImp::recvGetPeers (protocol::TMGetPeers& packet, ScopedLock& MasterLockHolder)
void PeerImp::recvGetPeers (protocol::TMGetPeers& packet, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
std::vector<std::string> addrs;
getApp().getPeers ().getTopNAddrs (30, addrs);
@@ -1779,7 +1784,7 @@ void PeerImp::recvStatus (protocol::TMStatusChange& packet)
mMaxLedger = packet.lastseq ();
}
void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, ScopedLock& MasterLockHolder)
void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, Application::ScopedLockType& masterLockHolder)
{
SHAMap::pointer map;
protocol::TMLedgerData reply;
@@ -1929,7 +1934,7 @@ void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, ScopedLock& MasterLo
}
if (ledger->isImmutable ())
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
else
{
WriteLog (lsWARNING, Peer) << "Request for data from mutable ledger";
@@ -2063,9 +2068,9 @@ void PeerImp::recvGetLedger (protocol::TMGetLedger& packet, ScopedLock& MasterLo
sendPacket (oPacket, true);
}
void PeerImp::recvLedger (const boost::shared_ptr<protocol::TMLedgerData>& packet_ptr, ScopedLock& MasterLockHolder)
void PeerImp::recvLedger (const boost::shared_ptr<protocol::TMLedgerData>& packet_ptr, Application::ScopedLockType& masterLockHolder)
{
MasterLockHolder.unlock ();
masterLockHolder.unlock ();
protocol::TMLedgerData& packet = *packet_ptr;
if (packet.nodes ().size () <= 0)

View File

@@ -822,6 +822,10 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternalNT (const SHAMapNode& id, uint2
if (!getApp().running ())
return ret;
// These are for diagnosing a crash on exit
Application& app (getApp ());
NodeStore& nodeStore (app.getNodeStore ());
NodeObject::pointer obj (getApp().getNodeStore ().retrieve (hash));
if (!obj)

View File

@@ -18,9 +18,13 @@ TransactionAcquire::TransactionAcquire (uint256 const& hash) : PeerSet (hash, TX
static void TACompletionHandler (uint256 hash, SHAMap::pointer map)
{
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
{
Application::ScopedLockType lock (getApp ().getMasterLock (), __FILE__, __LINE__);
getApp().getOPs ().mapComplete (hash, map);
getApp().getInboundLedgers ().dropLedger (hash);
}
}
void TransactionAcquire::done ()
@@ -50,7 +54,7 @@ void TransactionAcquire::onTimer (bool progress)
{
WriteLog (lsWARNING, TransactionAcquire) << "Ten timeouts on TX set " << getHash ();
{
boost::recursive_mutex::scoped_lock sl (getApp().getMasterLock ());
Application::ScopedLockType lock (getApp().getMasterLock (), __FILE__, __LINE__);
if (getApp().getOPs ().stillNeedTXSet (mHash))
{