Adds size limits to JsonStore. Adds a separate configuration

variable to enable binding to dynamic attributes.
This commit is contained in:
Mic Bowman
2013-02-08 15:07:43 -08:00
parent 2b5eba9c74
commit e93defd0ca
3 changed files with 70 additions and 2 deletions

View File

@@ -54,6 +54,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
private IConfig m_config = null;
private bool m_enabled = false;
private bool m_enableObjectStore = false;
private int m_maxStringSpace = Int32.MaxValue;
private Scene m_scene = null;
private Dictionary<UUID,JsonStore> m_JsonValueStore;
@@ -90,6 +93,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
m_enabled = m_config.GetBoolean("Enabled", m_enabled);
m_enableObjectStore = m_config.GetBoolean("EnableObjectStore", m_enableObjectStore);
m_maxStringSpace = m_config.GetInt("MaxStringSpace", m_maxStringSpace);
if (m_maxStringSpace == 0)
m_maxStringSpace = Int32.MaxValue;
}
catch (Exception e)
{
@@ -178,6 +185,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
public bool AttachObjectStore(UUID objectID)
{
if (! m_enabled) return false;
if (! m_enableObjectStore) return false;
SceneObjectPart sop = m_scene.GetSceneObjectPart(objectID);
if (sop == null)
@@ -311,7 +319,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
try
{
lock (map)
{
if (map.StringSpace > m_maxStringSpace)
{
m_log.WarnFormat("[JsonStore] {0} exceeded string size; {1} bytes used of {2} limit",
storeID,map.StringSpace,m_maxStringSpace);
return false;
}
return map.SetValue(path,value,useJson);
}
}
catch (Exception e)
{