Permalink
Browse files

[fix] partial fix for leaks of JSONRPC meta-data. There are circular …

…shared_ptr references that need to be sorted out before this will work properly.
  • Loading branch information...
1 parent 57db519 commit ad21d78d8b4a913bc5003b2c783353c78d93b411 Jim Carroll committed Dec 16, 2012
@@ -102,6 +102,12 @@ void CJSONRPC::Initialize()
CLog::Log(LOGINFO, "JSONRPC v%s: Successfully initialized", CJSONServiceDescription::GetVersion());
}
+void CJSONRPC::Cleanup()
+{
+ CJSONServiceDescription::Cleanup();
+ m_initialized = false;
+}
+
JSONRPC_STATUS CJSONRPC::Introspect(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant& parameterObject, CVariant &result)
{
return CJSONServiceDescription::Print(result, transport, client,
@@ -47,6 +47,8 @@ namespace JSONRPC
*/
static void Initialize();
+ static void Cleanup();
+
/*
\brief Handles an incoming JSON-RPC request
\param inputString received JSON-RPC request
@@ -1332,6 +1332,15 @@ JSONRPC_STATUS JsonRpcMethod::checkParameter(const CVariant &requestParameters,
return OK;
}
+void CJSONServiceDescription::Cleanup()
+{
+ // reset all of the static data
+ m_notifications.clear();
+ m_actionMap.clear();
+ m_types.clear();
+ m_incompleteDefinitions.clear();
+}
+
bool CJSONServiceDescription::prepareDescription(std::string &description, CVariant &descriptionObject, std::string &name)
{
if (description.empty())
@@ -1966,6 +1975,11 @@ CJSONServiceDescription::CJsonRpcMethodMap::CJsonRpcMethodMap()
m_actionmap = std::map<std::string, JsonRpcMethod>();
}
+void CJSONServiceDescription::CJsonRpcMethodMap::clear()
+{
+ m_actionmap.clear();
+}
+
void CJSONServiceDescription::CJsonRpcMethodMap::add(const JsonRpcMethod &method)
{
CStdString name = method.name;
@@ -392,6 +392,8 @@ namespace JSONRPC
static JSONSchemaTypeDefinitionPtr GetType(const std::string &identification);
+ static void Cleanup();
+
private:
static bool prepareDescription(std::string &description, CVariant &descriptionObject, std::string &name);
static bool addMethod(const std::string &jsonMethod, MethodCall method);
@@ -413,6 +415,8 @@ namespace JSONRPC
JsonRpcMethodIterator begin() const;
JsonRpcMethodIterator find(const std::string& key) const;
JsonRpcMethodIterator end() const;
+
+ void clear();
private:
std::map<std::string, JsonRpcMethod> m_actionmap;
};

0 comments on commit ad21d78

Please sign in to comment.