mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Reduce master lock scope in some RPC functions
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user