aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-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