aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine
diff options
context:
space:
mode:
authorDr Scofield2009-01-28 09:52:09 +0000
committerDr Scofield2009-01-28 09:52:09 +0000
commitce1e1854b129c2e223b399857b2e0c1a842c7186 (patch)
treef751c3dced33f681eacf1cac5d2fd96ee6058680 /OpenSim/Region/ScriptEngine/XEngine
parentFrom: Christopher Yeoh <yeohc@au1.ibm.com> (diff)
downloadopensim-SC_OLD-ce1e1854b129c2e223b399857b2e0c1a842c7186.zip
opensim-SC_OLD-ce1e1854b129c2e223b399857b2e0c1a842c7186.tar.gz
opensim-SC_OLD-ce1e1854b129c2e223b399857b2e0c1a842c7186.tar.bz2
opensim-SC_OLD-ce1e1854b129c2e223b399857b2e0c1a842c7186.tar.xz
From: Christopher Yeoh <yeohc@au1.ibm.com>
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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs19
1 files changed, 11 insertions, 8 deletions
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
544 544
545 lock (m_Scripts) 545 lock (m_Scripts)
546 { 546 {
547 ScriptInstance instance = null;
547 // Create the object record 548 // Create the object record
548 549
549 if ((!m_Scripts.ContainsKey(itemID)) || 550 if ((!m_Scripts.ContainsKey(itemID)) ||
@@ -596,14 +597,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
596 } 597 }
597 m_DomainScripts[appDomain].Add(itemID); 598 m_DomainScripts[appDomain].Add(itemID);
598 599
599 ScriptInstance instance = 600 instance = new ScriptInstance(this, part,
600 new ScriptInstance(this, part, 601 itemID, assetID, assembly,
601 itemID, assetID, assembly, 602 m_AppDomains[appDomain],
602 m_AppDomains[appDomain], 603 part.ParentGroup.RootPart.Name,
603 part.ParentGroup.RootPart.Name, 604 item.Name, startParam, postOnRez,
604 item.Name, startParam, postOnRez, 605 stateSource, m_MaxScriptQueue);
605 stateSource, m_MaxScriptQueue); 606
606
607 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", 607 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}",
608 part.ParentGroup.RootPart.Name, item.Name); 608 part.ParentGroup.RootPart.Name, item.Name);
609 609
@@ -625,6 +625,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
625 625
626 if (!m_Assemblies.ContainsKey(assetID)) 626 if (!m_Assemblies.ContainsKey(assetID))
627 m_Assemblies[assetID] = assembly; 627 m_Assemblies[assetID] = assembly;
628
629 if (instance!=null)
630 instance.Init();
628 } 631 }
629 return true; 632 return true;
630 } 633 }