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.iar_mods
parent
a30a02e7ae
commit
b5bb559cc0
|
@ -131,6 +131,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
|
|||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
|
||||
foreach (IScriptModule scriptModule in scriptModules)
|
||||
{
|
||||
scriptModule.OnScriptRemoved += ScriptRemoved;
|
||||
scriptModule.OnObjectRemoved += ObjectRemoved;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
|
@ -160,7 +166,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
|
|||
urlData.url = url;
|
||||
urlData.urlcode = urlcode;
|
||||
urlData.requests = new Dictionary<UUID, RequestData>();
|
||||
|
||||
|
||||
m_UrlMap[url] = urlData;
|
||||
|
||||
|
@ -276,6 +281,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
|
|||
|
||||
public void ScriptRemoved(UUID itemID)
|
||||
{
|
||||
// m_log.DebugFormat("[URL MODULE]: Removing script {0}", itemID);
|
||||
|
||||
lock (m_UrlMap)
|
||||
{
|
||||
List<string> removeURLs = new List<string>();
|
||||
|
|
|
@ -31,8 +31,21 @@ using OpenMetaverse;
|
|||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
public delegate void ScriptRemoved(UUID script);
|
||||
public delegate void ObjectRemoved(UUID prim);
|
||||
|
||||
public interface IScriptModule: INonSharedRegionModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Triggered when a script is removed from the script module.
|
||||
/// </summary>
|
||||
event ScriptRemoved OnScriptRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an object is removed via the script module.
|
||||
/// </summary>
|
||||
event ObjectRemoved OnObjectRemoved;
|
||||
|
||||
string ScriptEngineName { get; }
|
||||
|
||||
string GetXMLState(UUID itemID);
|
||||
|
|
|
@ -42,10 +42,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
|||
/// An interface for a script API module to communicate with
|
||||
/// the engine it's running under
|
||||
/// </summary>
|
||||
|
||||
public delegate void ScriptRemoved(UUID script);
|
||||
public delegate void ObjectRemoved(UUID prim);
|
||||
|
||||
public interface IScriptEngine
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -57,9 +53,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
|||
|
||||
IScriptModule ScriptModule { get; }
|
||||
|
||||
event ScriptRemoved OnScriptRemoved;
|
||||
event ObjectRemoved OnObjectRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Post an event to a single script
|
||||
/// </summary>
|
||||
|
|
|
@ -126,11 +126,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_TransferModule =
|
||||
m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
|
||||
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
|
||||
if (m_UrlModule != null)
|
||||
{
|
||||
m_ScriptEngine.OnScriptRemoved += m_UrlModule.ScriptRemoved;
|
||||
m_ScriptEngine.OnObjectRemoved += m_UrlModule.ObjectRemoved;
|
||||
}
|
||||
|
||||
AsyncCommands = new AsyncCommandManager(ScriptEngine);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue