diff options
author | Melanie | 2014-01-28 21:02:20 +0000 |
---|---|---|
committer | Melanie | 2014-01-28 21:02:20 +0000 |
commit | c6e9db58669d773c85041db99b19b942f70324f7 (patch) | |
tree | 99f69fb669332cff69a45ce6f7473aed6d965a0d /OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'justincc-master' (diff) | |
download | opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.zip opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.gz opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.bz2 opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Framework/RegionSettings.cs
OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 1bb5aee..9fbfb66 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -59,7 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
59 | 59 | ||
60 | private IScriptModuleComms m_comms; | 60 | private IScriptModuleComms m_comms; |
61 | private IJsonStoreModule m_store; | 61 | private IJsonStoreModule m_store; |
62 | 62 | ||
63 | private Dictionary<UUID,HashSet<UUID>> m_scriptStores = new Dictionary<UUID,HashSet<UUID>>(); | ||
64 | |||
63 | #region Region Module interface | 65 | #region Region Module interface |
64 | 66 | ||
65 | // ----------------------------------------------------------------- | 67 | // ----------------------------------------------------------------- |
@@ -126,6 +128,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
126 | // ----------------------------------------------------------------- | 128 | // ----------------------------------------------------------------- |
127 | public void AddRegion(Scene scene) | 129 | public void AddRegion(Scene scene) |
128 | { | 130 | { |
131 | scene.EventManager.OnScriptReset += HandleScriptReset; | ||
132 | scene.EventManager.OnRemoveScript += HandleScriptReset; | ||
129 | } | 133 | } |
130 | 134 | ||
131 | // ----------------------------------------------------------------- | 135 | // ----------------------------------------------------------------- |
@@ -134,12 +138,34 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
134 | // ----------------------------------------------------------------- | 138 | // ----------------------------------------------------------------- |
135 | public void RemoveRegion(Scene scene) | 139 | public void RemoveRegion(Scene scene) |
136 | { | 140 | { |
141 | scene.EventManager.OnScriptReset -= HandleScriptReset; | ||
142 | scene.EventManager.OnRemoveScript -= HandleScriptReset; | ||
143 | |||
137 | // need to remove all references to the scene in the subscription | 144 | // need to remove all references to the scene in the subscription |
138 | // list to enable full garbage collection of the scene object | 145 | // list to enable full garbage collection of the scene object |
139 | } | 146 | } |
140 | 147 | ||
141 | // ----------------------------------------------------------------- | 148 | // ----------------------------------------------------------------- |
142 | /// <summary> | 149 | /// <summary> |
150 | /// </summary> | ||
151 | // ----------------------------------------------------------------- | ||
152 | private void HandleScriptReset(uint localID, UUID itemID) | ||
153 | { | ||
154 | HashSet<UUID> stores; | ||
155 | |||
156 | lock (m_scriptStores) | ||
157 | { | ||
158 | if (! m_scriptStores.TryGetValue(itemID, out stores)) | ||
159 | return; | ||
160 | m_scriptStores.Remove(itemID); | ||
161 | } | ||
162 | |||
163 | foreach (UUID id in stores) | ||
164 | m_store.DestroyStore(id); | ||
165 | } | ||
166 | |||
167 | // ----------------------------------------------------------------- | ||
168 | /// <summary> | ||
143 | /// Called when all modules have been added for a region. This is | 169 | /// Called when all modules have been added for a region. This is |
144 | /// where we hook up events | 170 | /// where we hook up events |
145 | /// </summary> | 171 | /// </summary> |
@@ -250,6 +276,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
250 | if (! m_store.CreateStore(value, ref uuid)) | 276 | if (! m_store.CreateStore(value, ref uuid)) |
251 | GenerateRuntimeError("Failed to create Json store"); | 277 | GenerateRuntimeError("Failed to create Json store"); |
252 | 278 | ||
279 | lock (m_scriptStores) | ||
280 | { | ||
281 | if (! m_scriptStores.ContainsKey(scriptID)) | ||
282 | m_scriptStores[scriptID] = new HashSet<UUID>(); | ||
283 | |||
284 | m_scriptStores[scriptID].Add(uuid); | ||
285 | } | ||
253 | return uuid; | 286 | return uuid; |
254 | } | 287 | } |
255 | 288 | ||
@@ -261,6 +294,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
261 | [ScriptInvocation] | 294 | [ScriptInvocation] |
262 | public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID) | 295 | public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID) |
263 | { | 296 | { |
297 | lock(m_scriptStores) | ||
298 | { | ||
299 | if (m_scriptStores.ContainsKey(scriptID)) | ||
300 | m_scriptStores[scriptID].Remove(storeID); | ||
301 | } | ||
302 | |||
264 | return m_store.DestroyStore(storeID) ? 1 : 0; | 303 | return m_store.DestroyStore(storeID) ? 1 : 0; |
265 | } | 304 | } |
266 | 305 | ||