diff --git a/src/ripple/rpc/handlers/GetCounts.cpp b/src/ripple/rpc/handlers/GetCounts.cpp index 5ec095c331..b5ebdc14ea 100644 --- a/src/ripple/rpc/handlers/GetCounts.cpp +++ b/src/ripple/rpc/handlers/GetCounts.cpp @@ -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)) diff --git a/src/ripple/rpc/handlers/OwnerInfo.cpp b/src/ripple/rpc/handlers/OwnerInfo.cpp index 8e301c6a0f..0096d0ca56 100644 --- a/src/ripple/rpc/handlers/OwnerInfo.cpp +++ b/src/ripple/rpc/handlers/OwnerInfo.cpp @@ -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)) { diff --git a/src/ripple/rpc/handlers/ServerInfo.cpp b/src/ripple/rpc/handlers/ServerInfo.cpp index 61eda4477d..ed2f9a12c1 100644 --- a/src/ripple/rpc/handlers/ServerInfo.cpp +++ b/src/ripple/rpc/handlers/ServerInfo.cpp @@ -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 ( diff --git a/src/ripple/rpc/handlers/ServerState.cpp b/src/ripple/rpc/handlers/ServerState.cpp index d9bd0c35dc..5b9a992e7e 100644 --- a/src/ripple/rpc/handlers/ServerState.cpp +++ b/src/ripple/rpc/handlers/ServerState.cpp @@ -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 ( diff --git a/src/ripple/rpc/handlers/Subscribe.cpp b/src/ripple/rpc/handlers/Subscribe.cpp index 9fff28db55..f55a24295b 100644 --- a/src/ripple/rpc/handlers/Subscribe.cpp +++ b/src/ripple/rpc/handlers/Subscribe.cpp @@ -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) diff --git a/src/ripple/rpc/handlers/Unsubscribe.cpp b/src/ripple/rpc/handlers/Unsubscribe.cpp index 99aac106bb..653bbfb3e3 100644 --- a/src/ripple/rpc/handlers/Unsubscribe.cpp +++ b/src/ripple/rpc/handlers/Unsubscribe.cpp @@ -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)