Locking fixes.

This commit is contained in:
JoelKatz
2012-11-20 15:20:43 -08:00
parent 0f010f0445
commit 8e520e8816
2 changed files with 17 additions and 7 deletions

View File

@@ -49,12 +49,15 @@ Json::Value WSConnection::invokeCommand(Json::Value& jvRequest)
Json::Value jvResult(Json::objectValue); Json::Value jvResult(Json::objectValue);
// Regular RPC command // Regular RPC command
jvResult["result"] = mRPCHandler.doCommand( {
jvRequest["command"].asString(), boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
jvRequest.isMember("params") jvResult["result"] = mRPCHandler.doCommand(
? jvRequest["params"] jvRequest["command"].asString(),
: jvRequest, jvRequest.isMember("params")
mHandler->getPublic() ? RPCHandler::GUEST : RPCHandler::ADMIN); ? jvRequest["params"]
: jvRequest,
mHandler->getPublic() ? RPCHandler::GUEST : RPCHandler::ADMIN);
}
// Currently we will simply unwrap errors returned by the RPC // Currently we will simply unwrap errors returned by the RPC
// API, in the future maybe we can make the responses // API, in the future maybe we can make the responses

View File

@@ -116,7 +116,14 @@ public:
} }
else else
{ {
send(cpClient, mMap[cpClient]->invokeCommand(jvRequest)); boost::shared_ptr<WSConnection> conn;
{
boost::mutex::scoped_lock sl(mMapLock);
conn = mMap[cpClient];
}
if (!conn)
return;
send(cpClient, conn->invokeCommand(jvRequest));
} }
} }