aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorSean Dague2009-02-05 16:12:51 +0000
committerSean Dague2009-02-05 16:12:51 +0000
commitefcf00ee60c48b81d88ea48e31162e4fd97575f5 (patch)
tree5a1e9502c7e124120857ce9a83d1081e039f3dad /OpenSim/Region/ScriptEngine
parent* Add the second version of the experimental ObjectAdd Cap. It will handle ... (diff)
downloadopensim-SC-efcf00ee60c48b81d88ea48e31162e4fd97575f5.zip
opensim-SC-efcf00ee60c48b81d88ea48e31162e4fd97575f5.tar.gz
opensim-SC-efcf00ee60c48b81d88ea48e31162e4fd97575f5.tar.bz2
opensim-SC-efcf00ee60c48b81d88ea48e31162e4fd97575f5.tar.xz
From: Christopher Yeoh <yeohc@au1.ibm.com>
This patch fixes the problem where if an object containing a script is deleted at the same time as an object containing the same script is rezzed, it can result in the assembly file being deleted after the second object script initialisation has found it but not started using it yet, resulting in the script not starting up.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs63
1 files changed, 46 insertions, 17 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 7a52205..f0f867b 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -100,6 +100,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
100 private Dictionary<UUID, string> m_Assemblies = 100 private Dictionary<UUID, string> m_Assemblies =
101 new Dictionary<UUID, string>(); 101 new Dictionary<UUID, string>();
102 102
103 private Dictionary<string, int> m_AddingAssemblies =
104 new Dictionary<string, int>();
105
103 // This will list AppDomains by script asset 106 // This will list AppDomains by script asset
104 107
105 private Dictionary<UUID, AppDomain> m_AppDomains = 108 private Dictionary<UUID, AppDomain> m_AppDomains =
@@ -509,8 +512,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
509 512
510 try 513 try
511 { 514 {
512 assembly = m_Compiler.PerformScriptCompile(script, 515 lock (m_AddingAssemblies)
513 assetID.ToString()); 516 {
517 assembly = m_Compiler.PerformScriptCompile(script,
518 assetID.ToString());
519 if (!m_AddingAssemblies.ContainsKey(assembly)) {
520 m_AddingAssemblies[assembly] = 1;
521 } else {
522 m_AddingAssemblies[assembly]++;
523 }
524 }
514 } 525 }
515 catch (Exception e) 526 catch (Exception e)
516 { 527 {
@@ -592,6 +603,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
592 m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); 603 m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString());
593 m_ScriptErrorMessage += "Exception creating app domain:\n"; 604 m_ScriptErrorMessage += "Exception creating app domain:\n";
594 m_ScriptFailCount++; 605 m_ScriptFailCount++;
606 lock (m_AddingAssemblies)
607 {
608 m_AddingAssemblies[assembly]--;
609 }
595 return false; 610 return false;
596 } 611 }
597 } 612 }
@@ -626,6 +641,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
626 if (!m_Assemblies.ContainsKey(assetID)) 641 if (!m_Assemblies.ContainsKey(assetID))
627 m_Assemblies[assetID] = assembly; 642 m_Assemblies[assetID] = assembly;
628 643
644 lock (m_AddingAssemblies)
645 {
646 m_AddingAssemblies[assembly]--;
647 }
648
629 if (instance!=null) 649 if (instance!=null)
630 instance.Init(); 650 instance.Init();
631 } 651 }
@@ -710,24 +730,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine
710 assetIDList.Remove(i.AssetID); 730 assetIDList.Remove(i.AssetID);
711 } 731 }
712 732
713 foreach (UUID assetID in assetIDList) 733 lock (m_AddingAssemblies)
714 { 734 {
715// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]); 735 foreach (UUID assetID in assetIDList)
716 try
717 {
718 if (File.Exists(m_Assemblies[assetID]))
719 File.Delete(m_Assemblies[assetID]);
720
721 if (File.Exists(m_Assemblies[assetID]+".state"))
722 File.Delete(m_Assemblies[assetID]+".state");
723
724 if (File.Exists(m_Assemblies[assetID]+".mdb"))
725 File.Delete(m_Assemblies[assetID]+".mdb");
726 }
727 catch (Exception)
728 { 736 {
737 // Do not remove assembly files if another instance of the script
738 // is currently initialising
739 if (!m_AddingAssemblies.ContainsKey(m_Assemblies[assetID])
740 || m_AddingAssemblies[m_Assemblies[assetID]] == 0)
741 {
742// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]);
743 try
744 {
745 if (File.Exists(m_Assemblies[assetID]))
746 File.Delete(m_Assemblies[assetID]);
747
748 if (File.Exists(m_Assemblies[assetID]+".state"))
749 File.Delete(m_Assemblies[assetID]+".state");
750
751 if (File.Exists(m_Assemblies[assetID]+".mdb"))
752 File.Delete(m_Assemblies[assetID]+".mdb");
753 }
754 catch (Exception)
755 {
756 }
757 m_Assemblies.Remove(assetID);
758 }
729 } 759 }
730 m_Assemblies.Remove(assetID);
731 } 760 }
732 } 761 }
733 762