aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs51
1 files changed, 31 insertions, 20 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 7b19ce3..57042e9 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -73,9 +73,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
73 private bool m_InitialStartup = true; 73 private bool m_InitialStartup = true;
74 private int m_ScriptFailCount; // Number of script fails since compile queue was last empty 74 private int m_ScriptFailCount; // Number of script fails since compile queue was last empty
75 private string m_ScriptErrorMessage; 75 private string m_ScriptErrorMessage;
76 private Dictionary<string, string> m_uniqueScripts = new Dictionary<string, string>();
77 private bool m_AppDomainLoading;
76 78
77// disable warning: need to keep a reference to XEngine.EventManager 79 // disable warning: need to keep a reference to XEngine.EventManager
78// alive to avoid it being garbage collected 80 // alive to avoid it being garbage collected
79#pragma warning disable 414 81#pragma warning disable 414
80 private EventManager m_EventManager; 82 private EventManager m_EventManager;
81#pragma warning restore 414 83#pragma warning restore 414
@@ -201,6 +203,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
201 m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); 203 m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300);
202 m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); 204 m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144);
203 m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; 205 m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000;
206 m_AppDomainLoading = m_ScriptConfig.GetBoolean("AppDomainLoading", true);
204 207
205 m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); 208 m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30);
206 m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); 209 m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false);
@@ -470,6 +473,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
470 if (engine != ScriptEngineName) 473 if (engine != ScriptEngineName)
471 return; 474 return;
472 475
476 // If we've seen this exact script text before, use that reference instead
477 if (m_uniqueScripts.ContainsKey(script))
478 script = m_uniqueScripts[script];
479 else
480 m_uniqueScripts[script] = script;
481
473 Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; 482 Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource};
474 483
475 if (stateSource == (int)StateSource.ScriptedRez) 484 if (stateSource == (int)StateSource.ScriptedRez)
@@ -590,14 +599,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
590 { 599 {
591 lock (m_AddingAssemblies) 600 lock (m_AddingAssemblies)
592 { 601 {
593 assembly = (string)m_Compiler.PerformScriptCompile(script, 602 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
594 assetID.ToString(), item.OwnerID);
595 if (!m_AddingAssemblies.ContainsKey(assembly)) { 603 if (!m_AddingAssemblies.ContainsKey(assembly)) {
596 m_AddingAssemblies[assembly] = 1; 604 m_AddingAssemblies[assembly] = 1;
597 } else { 605 } else {
598 m_AddingAssemblies[assembly]++; 606 m_AddingAssemblies[assembly]++;
599 } 607 }
600 linemap = m_Compiler.LineMap();
601 } 608 }
602 609
603 string[] warnings = m_Compiler.GetWarnings(); 610 string[] warnings = m_Compiler.GetWarnings();
@@ -696,19 +703,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine
696 Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; 703 Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
697 Evidence evidence = new Evidence(baseEvidence); 704 Evidence evidence = new Evidence(baseEvidence);
698 705
699 AppDomain sandbox = 706 AppDomain sandbox;
700 AppDomain.CreateDomain( 707 if (m_AppDomainLoading)
701 m_Scene.RegionInfo.RegionID.ToString(), 708 sandbox = AppDomain.CreateDomain(
702 evidence, appSetup); 709 m_Scene.RegionInfo.RegionID.ToString(),
703/* 710 evidence, appSetup);
704 PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); 711 else
705 AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); 712 sandbox = AppDomain.CurrentDomain;
706 PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); 713 /*
707 PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); 714 PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
708 CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); 715 AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
709 sandboxPolicy.RootCodeGroup = sandboxCodeGroup; 716 PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
710 sandbox.SetAppDomainPolicy(sandboxPolicy); 717 PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
711*/ 718 CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
719 sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
720 sandbox.SetAppDomainPolicy(sandboxPolicy);
721 */
712 m_AppDomains[appDomain] = sandbox; 722 m_AppDomains[appDomain] = sandbox;
713 723
714 m_AppDomains[appDomain].AssemblyResolve += 724 m_AppDomains[appDomain].AssemblyResolve +=
@@ -905,9 +915,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
905 AppDomain domain = m_AppDomains[id]; 915 AppDomain domain = m_AppDomains[id];
906 m_AppDomains.Remove(id); 916 m_AppDomains.Remove(id);
907 917
908 AppDomain.Unload(domain); 918 if (domain != AppDomain.CurrentDomain)
919 AppDomain.Unload(domain);
909 domain = null; 920 domain = null;
910// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); 921 // m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
911 } 922 }
912 } 923 }
913 924