aboutsummaryrefslogtreecommitdiff
path: root/src/rpcserver.cpp
diff options
context:
space:
mode:
authorForrest Voight <forrest@forre.st>2015-07-01 21:34:31 -0400
committerForrest Voight <forrest@forre.st>2015-07-01 21:55:08 -0400
commit72b9452b1d5ff8761466e9810facfd50103cc63b (patch)
treebe7c69f872fb57e78a0784f8780ff8749754f450 /src/rpcserver.cpp
parent6bcb0a21c5435738e2fccd589636de8db4989992 (diff)
downloadbitcoin-72b9452b1d5ff8761466e9810facfd50103cc63b.tar.xz
When processing RPC commands during warmup phase, parse the
request object before returning an error so that id value can be used in the response. Prior to this commit, RPC commands sent during Bitcoin's warmup/startup phase were responded to with a JSON-RPC error with an id of null, which violated the JSON-RPC 2.0 spec: id: This member is REQUIRED. It MUST be the same as the value of the id member in the Request Object. If there was an error in detecting the id in the Request object (e.g. Parse error/Invalid Request), it MUST be Null.
Diffstat (limited to 'src/rpcserver.cpp')
-rw-r--r--src/rpcserver.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index 840bf57c21..b76575fc4a 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -930,13 +930,6 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
if (!valRequest.read(strRequest))
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
- // Return immediately if in warmup
- {
- LOCK(cs_rpcWarmup);
- if (fRPCInWarmup)
- throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
- }
-
string strReply;
// singleton request
@@ -1008,6 +1001,13 @@ void ServiceConnection(AcceptedConnection *conn)
UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params) const
{
+ // Return immediately if in warmup
+ {
+ LOCK(cs_rpcWarmup);
+ if (fRPCInWarmup)
+ throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
+ }
+
// Find method
const CRPCCommand *pcmd = tableRPC[strMethod];
if (!pcmd)