aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Corallo <matt@bluematt.me>2012-06-28 18:34:11 +0200
committerMatt Corallo <matt@bluematt.me>2012-06-28 18:34:11 +0200
commit4e97a9d9eb91f87e0611c31f28e2e02a07cea8aa (patch)
treeb0c5b0eae5fe90d24ed1108a6e3fa510f8b9c34e /src
parent7cf3d2ccb960a1c8e81622d46b38cf253893d9af (diff)
Lock vnThreadsRunning[THREAD_RPCHANDLER].
Diffstat (limited to 'src')
-rw-r--r--src/bitcoinrpc.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 82bab36dc8..48c5a738b5 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -2913,10 +2913,15 @@ void ThreadRPCServer2(void* parg)
StopRequests();
}
+static CCriticalSection cs_THREAD_RPCHANDLER;
+
void ThreadRPCServer3(void* parg)
{
IMPLEMENT_RANDOMIZE_STACK(ThreadRPCServer3(parg));
- vnThreadsRunning[THREAD_RPCHANDLER]++;
+ {
+ LOCK(cs_THREAD_RPCHANDLER);
+ vnThreadsRunning[THREAD_RPCHANDLER]++;
+ }
AcceptedConnection *conn = (AcceptedConnection *) parg;
bool fRun = true;
@@ -2925,7 +2930,10 @@ void ThreadRPCServer3(void* parg)
{
conn->close();
delete conn;
- --vnThreadsRunning[THREAD_RPCHANDLER];
+ {
+ LOCK(cs_THREAD_RPCHANDLER);
+ --vnThreadsRunning[THREAD_RPCHANDLER];
+ }
return;
}
map<string, string> mapHeaders;
@@ -3005,7 +3013,10 @@ void ThreadRPCServer3(void* parg)
}
delete conn;
- vnThreadsRunning[THREAD_RPCHANDLER]--;
+ {
+ LOCK(cs_THREAD_RPCHANDLER);
+ vnThreadsRunning[THREAD_RPCHANDLER]--;
+ }
}
json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_spirit::Array &params) const