mirror of
https://github.com/opensim/opensim.git
synced 2026-07-18 13:45:37 +08:00
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.
This commit is contained in:
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user