aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-01-14 00:23:11 +0000
committerJustin Clark-Casey (justincc)2012-01-14 00:23:11 +0000
commitb5bb559cc020df0b2e7d77a46f7d47a8fed1bc9f (patch)
treec4516b37b09c2a104019845ef167c262836487e9
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-b5bb559cc020df0b2e7d77a46f7d47a8fed1bc9f.zip
opensim-SC_OLD-b5bb559cc020df0b2e7d77a46f7d47a8fed1bc9f.tar.gz
opensim-SC_OLD-b5bb559cc020df0b2e7d77a46f7d47a8fed1bc9f.tar.bz2
opensim-SC_OLD-b5bb559cc020df0b2e7d77a46f7d47a8fed1bc9f.tar.xz
Register the UrlModule for script engine events OnScriptRemoved and OnObjectRemoved just once in the UrlModule itself, rather than repeatedly for every script.
Doing this in every script is unnecessary since the event trigger is parameterized by the item id. All that would happen is 2000 scripts would trigger 1999 unnecessary calls, and a large number of initialized scripts may eventually trigger a StackOverflowException. Registration moved to UrlModule so that the handler is registered for all script engine implementations. This required moving the OnScriptRemoved and OnObjectRemoved events (only used by UrlModule in core) from IScriptEngine to IScriptModule to avoid circular references.
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs9
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs5
4 files changed, 21 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 67d99e0..93e75b3 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -131,6 +131,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
131 131
132 public void RegionLoaded(Scene scene) 132 public void RegionLoaded(Scene scene)
133 { 133 {
134 IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
135 foreach (IScriptModule scriptModule in scriptModules)
136 {
137 scriptModule.OnScriptRemoved += ScriptRemoved;
138 scriptModule.OnObjectRemoved += ObjectRemoved;
139 }
134 } 140 }
135 141
136 public void RemoveRegion(Scene scene) 142 public void RemoveRegion(Scene scene)
@@ -160,7 +166,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
160 urlData.url = url; 166 urlData.url = url;
161 urlData.urlcode = urlcode; 167 urlData.urlcode = urlcode;
162 urlData.requests = new Dictionary<UUID, RequestData>(); 168 urlData.requests = new Dictionary<UUID, RequestData>();
163
164 169
165 m_UrlMap[url] = urlData; 170 m_UrlMap[url] = urlData;
166 171
@@ -276,6 +281,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
276 281
277 public void ScriptRemoved(UUID itemID) 282 public void ScriptRemoved(UUID itemID)
278 { 283 {
284// m_log.DebugFormat("[URL MODULE]: Removing script {0}", itemID);
285
279 lock (m_UrlMap) 286 lock (m_UrlMap)
280 { 287 {
281 List<string> removeURLs = new List<string>(); 288 List<string> removeURLs = new List<string>();
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 950e4b0..18c45dd 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -31,8 +31,21 @@ using OpenMetaverse;
31 31
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 public delegate void ScriptRemoved(UUID script);
35 public delegate void ObjectRemoved(UUID prim);
36
34 public interface IScriptModule: INonSharedRegionModule 37 public interface IScriptModule: INonSharedRegionModule
35 { 38 {
39 /// <summary>
40 /// Triggered when a script is removed from the script module.
41 /// </summary>
42 event ScriptRemoved OnScriptRemoved;
43
44 /// <summary>
45 /// Triggered when an object is removed via the script module.
46 /// </summary>
47 event ObjectRemoved OnObjectRemoved;
48
36 string ScriptEngineName { get; } 49 string ScriptEngineName { get; }
37 50
38 string GetXMLState(UUID itemID); 51 string GetXMLState(UUID itemID);
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
index 581a9a9..17c2708 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
@@ -42,10 +42,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
42 /// An interface for a script API module to communicate with 42 /// An interface for a script API module to communicate with
43 /// the engine it's running under 43 /// the engine it's running under
44 /// </summary> 44 /// </summary>
45
46 public delegate void ScriptRemoved(UUID script);
47 public delegate void ObjectRemoved(UUID prim);
48
49 public interface IScriptEngine 45 public interface IScriptEngine
50 { 46 {
51 /// <summary> 47 /// <summary>
@@ -57,9 +53,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
57 53
58 IScriptModule ScriptModule { get; } 54 IScriptModule ScriptModule { get; }
59 55
60 event ScriptRemoved OnScriptRemoved;
61 event ObjectRemoved OnObjectRemoved;
62
63 /// <summary> 56 /// <summary>
64 /// Post an event to a single script 57 /// Post an event to a single script
65 /// </summary> 58 /// </summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ab175ba..fb930e0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -126,11 +126,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
126 m_TransferModule = 126 m_TransferModule =
127 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); 127 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
128 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); 128 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
129 if (m_UrlModule != null)
130 {
131 m_ScriptEngine.OnScriptRemoved += m_UrlModule.ScriptRemoved;
132 m_ScriptEngine.OnObjectRemoved += m_UrlModule.ObjectRemoved;
133 }
134 129
135 AsyncCommands = new AsyncCommandManager(ScriptEngine); 130 AsyncCommands = new AsyncCommandManager(ScriptEngine);
136 } 131 }