From ce1e1854b129c2e223b399857b2e0c1a842c7186 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 28 Jan 2009 09:52:09 +0000 Subject: From: Christopher Yeoh This changeset fixes a race condition where a script (XEngine run) can startup before a reference is added to it in all of the required places in the XEngine class. The effect of this is that a script can sometimes on startup miss script events. For example a script which starts up and initialises itself from a notecard may never receive the dataserver event containing the notecard information. The patch isn't as clean as I'd like - I've split the constructor of ScriptInstance up so it does everything it did before except call Startup and post events like state_entry and on_rez. An Init function has been added which is called after the ScriptInstance object has been added to the necessary data structures in XEngine. Happy to rework it if someone suggests a better way of doing it. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index fc76d0b..a0a0037 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -544,6 +544,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine lock (m_Scripts) { + ScriptInstance instance = null; // Create the object record if ((!m_Scripts.ContainsKey(itemID)) || @@ -596,14 +597,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine } m_DomainScripts[appDomain].Add(itemID); - ScriptInstance instance = - new ScriptInstance(this, part, - itemID, assetID, assembly, - m_AppDomains[appDomain], - part.ParentGroup.RootPart.Name, - item.Name, startParam, postOnRez, - stateSource, m_MaxScriptQueue); - + instance = new ScriptInstance(this, part, + itemID, assetID, assembly, + m_AppDomains[appDomain], + part.ParentGroup.RootPart.Name, + item.Name, startParam, postOnRez, + stateSource, m_MaxScriptQueue); + m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", part.ParentGroup.RootPart.Name, item.Name); @@ -625,6 +625,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (!m_Assemblies.ContainsKey(assetID)) m_Assemblies[assetID] = assembly; + + if (instance!=null) + instance.Init(); } return true; } -- cgit v1.1