aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2020-06-29 19:03:18 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2020-06-29 19:16:18 +0200
commit2af56d6d5c387c3208d3d5aae8d428a3d610446f (patch)
treed59d378c8dd76231b8097cf45ff84d12644af6ef /src
parent8d3187fd0d6d2a2c9dd6d6d2c2d5b2128f6a74f6 (diff)
parent6fdfeebcc79df62c8bf1cf4b6e9e97d6aefb3eb3 (diff)
downloadbitcoin-2af56d6d5c387c3208d3d5aae8d428a3d610446f.tar.xz
Merge #19399: refactor: Replace RecursiveMutex with Mutex in rpc/server.cpp
6fdfeebcc79df62c8bf1cf4b6e9e97d6aefb3eb3 refactor: Replace RecursiveMutex with Mutex in rpc/server.cpp (Hennadii Stepanov) Pull request description: The functions that could lock this mutex, i.e., `SetRPCWarmupStatus()`, `SetRPCWarmupFinished()`, `RPCIsInWarmup()`, `CRPCTable::execute()`, do not call itself recursively, and do not call each other either directly or indirectly. Therefore, the `g_rpc_warmup_mutex` could be a non-recursive mutex. Related to #19303. ACKs for top commit: laanwj: ACK 6fdfeebcc79df62c8bf1cf4b6e9e97d6aefb3eb3 MarcoFalke: ACK 6fdfeebcc79df62c8bf1cf4b6e9e97d6aefb3eb3 Tree-SHA512: 05a8ac58c0cd6a3c9afad9e06ad78059642e3e97715e129f379c0bf6dccdb58e70d05d965f23e7432fd3f02d7f97967a778ffb8e424837891d9d785a9e98964c
Diffstat (limited to 'src')
-rw-r--r--src/rpc/server.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 844f62cbc6..de8791a935 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -20,10 +20,10 @@
#include <mutex>
#include <unordered_map>
-static RecursiveMutex cs_rpcWarmup;
+static Mutex g_rpc_warmup_mutex;
static std::atomic<bool> g_rpc_running{false};
-static bool fRPCInWarmup GUARDED_BY(cs_rpcWarmup) = true;
-static std::string rpcWarmupStatus GUARDED_BY(cs_rpcWarmup) = "RPC server started";
+static bool fRPCInWarmup GUARDED_BY(g_rpc_warmup_mutex) = true;
+static std::string rpcWarmupStatus GUARDED_BY(g_rpc_warmup_mutex) = "RPC server started";
/* Timer-creating functions */
static RPCTimerInterface* timerInterface = nullptr;
/* Map of name to timer. */
@@ -327,20 +327,20 @@ void RpcInterruptionPoint()
void SetRPCWarmupStatus(const std::string& newStatus)
{
- LOCK(cs_rpcWarmup);
+ LOCK(g_rpc_warmup_mutex);
rpcWarmupStatus = newStatus;
}
void SetRPCWarmupFinished()
{
- LOCK(cs_rpcWarmup);
+ LOCK(g_rpc_warmup_mutex);
assert(fRPCInWarmup);
fRPCInWarmup = false;
}
bool RPCIsInWarmup(std::string *outStatus)
{
- LOCK(cs_rpcWarmup);
+ LOCK(g_rpc_warmup_mutex);
if (outStatus)
*outStatus = rpcWarmupStatus;
return fRPCInWarmup;
@@ -439,7 +439,7 @@ UniValue CRPCTable::execute(const JSONRPCRequest &request) const
{
// Return immediately if in warmup
{
- LOCK(cs_rpcWarmup);
+ LOCK(g_rpc_warmup_mutex);
if (fRPCInWarmup)
throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
}