Reduce master lock scope in some RPC functions

This commit is contained in:
JoelKatz
2015-03-08 16:47:18 -07:00
committed by Nik Bougalis
parent 8de1b20bb5
commit 2f32910bef
6 changed files with 12 additions and 11 deletions

View File

@@ -31,8 +31,6 @@ namespace ripple {
// }
Json::Value doGetCounts (RPC::Context& context)
{
auto lock = getApp().masterLock();
int minCount = 10;
if (context.params.isMember (jss::min_count))

View File

@@ -27,7 +27,6 @@ namespace ripple {
// }
Json::Value doOwnerInfo (RPC::Context& context)
{
auto lock = getApp().masterLock();
if (!context.params.isMember (jss::account) &&
!context.params.isMember (jss::ident))
{

View File

@@ -24,7 +24,6 @@ namespace ripple {
Json::Value doServerInfo (RPC::Context& context)
{
auto lock = getApp().masterLock();
Json::Value ret (Json::objectValue);
ret[jss::info] = context.netOps.getServerInfo (

View File

@@ -24,7 +24,6 @@ namespace ripple {
Json::Value doServerState (RPC::Context& context)
{
auto lock = getApp().masterLock();
Json::Value ret (Json::objectValue);
ret[jss::state] = context.netOps.getServerInfo (

View File

@@ -26,11 +26,6 @@ namespace ripple {
Json::Value doSubscribe (RPC::Context& context)
{
auto lock = getApp().masterLock();
// FIXME: This needs to release the master lock immediately
// Subscriptions need to be protected by their own lock
InfoSub::pointer ispSub;
Json::Value jvResult (Json::objectValue);
std::uint32_t uLedgerIndex = context.params.isMember (jss::ledger_index)
@@ -47,6 +42,10 @@ Json::Value doSubscribe (RPC::Context& context)
return rpcError (rpcINVALID_PARAMS);
}
// FIXME:
// Subscriptions need to be protected by their own lock
auto lock = getApp().masterLock();
if (context.params.isMember (jss::url))
{
if (context.role != Role::ADMIN)
@@ -287,6 +286,12 @@ Json::Value doSubscribe (RPC::Context& context)
return rpcError (rpcBAD_MARKET);
}
if (!bHaveMasterLock)
{
lock->lock ();
bHaveMasterLock = true;
}
context.netOps.subBook (ispSub, book);
if (bBoth)

View File

@@ -26,7 +26,6 @@ namespace ripple {
// sane.
Json::Value doUnsubscribe (RPC::Context& context)
{
auto lock = getApp().masterLock();
InfoSub::pointer ispSub;
Json::Value jvResult (Json::objectValue);
@@ -37,6 +36,8 @@ Json::Value doUnsubscribe (RPC::Context& context)
return rpcError (rpcINVALID_PARAMS);
}
auto lock = getApp().masterLock();
if (context.params.isMember (jss::url))
{
if (context.role != Role::ADMIN)