aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
diff options
context:
space:
mode:
authorDahlia Trimble2009-01-10 09:15:23 +0000
committerDahlia Trimble2009-01-10 09:15:23 +0000
commit630ce5b26446883043aa5e6541a4550d0e918659 (patch)
tree5128485b0d8e94c96593b352a421623cbd053acb /OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
parentInclude the changes from StrawBerryFride's patch to (diff)
downloadopensim-SC_OLD-630ce5b26446883043aa5e6541a4550d0e918659.zip
opensim-SC_OLD-630ce5b26446883043aa5e6541a4550d0e918659.tar.gz
opensim-SC_OLD-630ce5b26446883043aa5e6541a4550d0e918659.tar.bz2
opensim-SC_OLD-630ce5b26446883043aa5e6541a4550d0e918659.tar.xz
Revert progressive texture patch from r8001 until issues can be addressed
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs102
1 files changed, 46 insertions, 56 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 3431309..61b16f4 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -63,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
63 private IConfig m_ScriptConfig; 63 private IConfig m_ScriptConfig;
64 private ICompiler m_Compiler; 64 private ICompiler m_Compiler;
65 private int m_MinThreads; 65 private int m_MinThreads;
66 private int m_MaxThreads ; 66 private int m_MaxThreads;
67 private int m_IdleTimeout; 67 private int m_IdleTimeout;
68 private int m_StackSize; 68 private int m_StackSize;
69 private int m_SleepTime; 69 private int m_SleepTime;
@@ -72,8 +72,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
72 private bool m_Enabled = false; 72 private bool m_Enabled = false;
73 private bool m_InitialStartup = true; 73 private bool m_InitialStartup = true;
74 74
75// disable warning: need to keep a reference to XEngine.EventManager 75 // disable warning: need to keep a reference to XEngine.EventManager
76// alive to avoid it being garbage collected 76 // alive to avoid it being garbage collected
77#pragma warning disable 414 77#pragma warning disable 414
78 private EventManager m_EventManager; 78 private EventManager m_EventManager;
79#pragma warning restore 414 79#pragma warning restore 414
@@ -85,8 +85,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
85 85
86 // Maps the local id to the script inventory items in it 86 // Maps the local id to the script inventory items in it
87 87
88 private Dictionary<uint, List<UUID> > m_PrimObjects = 88 private Dictionary<uint, List<UUID>> m_PrimObjects =
89 new Dictionary<uint, List<UUID> >(); 89 new Dictionary<uint, List<UUID>>();
90 90
91 // Maps the UUID above to the script instance 91 // Maps the UUID above to the script instance
92 92
@@ -105,8 +105,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
105 105
106 // List the scripts running in each appdomain 106 // List the scripts running in each appdomain
107 107
108 private Dictionary<UUID, List<UUID> > m_DomainScripts = 108 private Dictionary<UUID, List<UUID>> m_DomainScripts =
109 new Dictionary<UUID, List<UUID> >(); 109 new Dictionary<UUID, List<UUID>>();
110 110
111 private Queue m_CompileQueue = new Queue(100); 111 private Queue m_CompileQueue = new Queue(100);
112 IWorkItemResult m_CurrentCompile = null; 112 IWorkItemResult m_CurrentCompile = null;
@@ -152,7 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
152 152
153 if (m_ScriptConfig == null) 153 if (m_ScriptConfig == null)
154 { 154 {
155// m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled"); 155 // m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled");
156 return; 156 return;
157 } 157 }
158 158
@@ -172,7 +172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
172 m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); 172 m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
173 m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60); 173 m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60);
174 string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); 174 string priority = m_ScriptConfig.GetString("Priority", "BelowNormal");
175 m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); 175 m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue", 300);
176 m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); 176 m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144);
177 m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; 177 m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000;
178 178
@@ -239,7 +239,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
239 if (m_SleepTime > 0) 239 if (m_SleepTime > 0)
240 { 240 {
241 m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), 241 m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
242 new Object[]{ m_SleepTime }); 242 new Object[] { m_SleepTime });
243 } 243 }
244 244
245 if (m_SaveTime > 0) 245 if (m_SaveTime > 0)
@@ -268,7 +268,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
268 if (saveTime > 0) 268 if (saveTime > 0)
269 System.Threading.Thread.Sleep(saveTime); 269 System.Threading.Thread.Sleep(saveTime);
270 270
271// m_log.Debug("[XEngine] Backing up script states"); 271 // m_log.Debug("[XEngine] Backing up script states");
272 272
273 List<IScriptInstance> instances = new List<IScriptInstance>(); 273 List<IScriptInstance> instances = new List<IScriptInstance>();
274 274
@@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
319 System.Threading.Thread.Sleep(sleepTime); 319 System.Threading.Thread.Sleep(sleepTime);
320 320
321 m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), 321 m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
322 new Object[]{ sleepTime }); 322 new Object[] { sleepTime });
323 323
324 return 0; 324 return 0;
325 } 325 }
@@ -351,12 +351,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
351 int colon = firstline.IndexOf(':'); 351 int colon = firstline.IndexOf(':');
352 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) 352 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1)
353 { 353 {
354 string engineName = firstline.Substring(2, colon-2); 354 string engineName = firstline.Substring(2, colon - 2);
355 355
356 if (names.Contains(engineName)) 356 if (names.Contains(engineName))
357 { 357 {
358 engine = engineName; 358 engine = engineName;
359 script = "//" + script.Substring(script.IndexOf(':')+1); 359 script = "//" + script.Substring(script.IndexOf(':') + 1);
360 } 360 }
361 else 361 else
362 { 362 {
@@ -365,21 +365,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
365 SceneObjectPart part = 365 SceneObjectPart part =
366 m_Scene.GetSceneObjectPart( 366 m_Scene.GetSceneObjectPart(
367 localID); 367 localID);
368 368
369 TaskInventoryItem item = 369 TaskInventoryItem item =
370 part.Inventory.GetInventoryItem(itemID); 370 part.Inventory.GetInventoryItem(itemID);
371 371
372 ScenePresence presence = 372 ScenePresence presence =
373 m_Scene.GetScenePresence( 373 m_Scene.GetScenePresence(
374 item.OwnerID); 374 item.OwnerID);
375 375
376 if (presence != null) 376 if (presence != null)
377 { 377 {
378 presence.ControllingClient.SendAgentAlertMessage( 378 presence.ControllingClient.SendAgentAlertMessage(
379 "Selected engine unavailable. "+ 379 "Selected engine unavailable. " +
380 "Running script on "+ 380 "Running script on " +
381 ScriptEngineName, 381 ScriptEngineName,
382 false); 382 false);
383 } 383 }
384 } 384 }
385 } 385 }
@@ -389,7 +389,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
389 if (engine != ScriptEngineName) 389 if (engine != ScriptEngineName)
390 return; 390 return;
391 391
392 Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; 392 Object[] parms = new Object[] { localID, itemID, script, startParam, postOnRez, (StateSource)stateSource };
393 393
394 if (stateSource == (int)StateSource.ScriptedRez) 394 if (stateSource == (int)StateSource.ScriptedRez)
395 { 395 {
@@ -453,7 +453,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
453 Object[] p = (Object[])parm; 453 Object[] p = (Object[])parm;
454 uint localID = (uint)p[0]; 454 uint localID = (uint)p[0];
455 UUID itemID = (UUID)p[1]; 455 UUID itemID = (UUID)p[1];
456 string script =(string)p[2]; 456 string script = (string)p[2];
457 int startParam = (int)p[3]; 457 int startParam = (int)p[3];
458 bool postOnRez = (bool)p[4]; 458 bool postOnRez = (bool)p[4];
459 StateSource stateSource = (StateSource)p[5]; 459 StateSource stateSource = (StateSource)p[5];
@@ -469,7 +469,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
469 { 469 {
470 Log.Error("[Script] SceneObjectPart unavailable. Script NOT started."); 470 Log.Error("[Script] SceneObjectPart unavailable. Script NOT started.");
471 return false; 471 return false;
472 } 472 }
473 473
474 TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID); 474 TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID);
475 if (item == null) 475 if (item == null)
@@ -477,8 +477,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
477 477
478 UUID assetID = item.AssetID; 478 UUID assetID = item.AssetID;
479 479
480// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})", 480 // m_log.DebugFormat("[XEngine] Compiling script {0} ({1})",
481// item.Name, itemID.ToString()); 481 // item.Name, itemID.ToString());
482 482
483 ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); 483 ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID);
484 484
@@ -509,7 +509,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
509 } 509 }
510 catch (Exception e2) // LEGIT: User Scripting 510 catch (Exception e2) // LEGIT: User Scripting
511 { 511 {
512 m_log.Error("[XEngine]: "+ 512 m_log.Error("[XEngine]: " +
513 "Error displaying error in-world: " + 513 "Error displaying error in-world: " +
514 e2.ToString()); 514 e2.ToString());
515 m_log.Error("[XEngine]: " + 515 m_log.Error("[XEngine]: " +
@@ -537,27 +537,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
537 try 537 try
538 { 538 {
539 AppDomainSetup appSetup = new AppDomainSetup(); 539 AppDomainSetup appSetup = new AppDomainSetup();
540// appSetup.ApplicationBase = Path.Combine( 540 // appSetup.ApplicationBase = Path.Combine(
541// "ScriptEngines", 541 // "ScriptEngines",
542// m_Scene.RegionInfo.RegionID.ToString()); 542 // m_Scene.RegionInfo.RegionID.ToString());
543 543
544 Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; 544 Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
545 Evidence evidence = new Evidence(baseEvidence); 545 Evidence evidence = new Evidence(baseEvidence);
546 546
547 AppDomain sandbox = 547 m_AppDomains[appDomain] =
548 AppDomain.CreateDomain( 548 AppDomain.CreateDomain(
549 m_Scene.RegionInfo.RegionID.ToString(), 549 m_Scene.RegionInfo.RegionID.ToString(),
550 evidence, appSetup); 550 evidence, appSetup);
551
552 PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
553 AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
554 PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
555 PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
556 CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
557 sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
558 sandbox.SetAppDomainPolicy(sandboxPolicy);
559
560 m_AppDomains[appDomain] = sandbox;
561 551
562 m_AppDomains[appDomain].AssemblyResolve += 552 m_AppDomains[appDomain].AssemblyResolve +=
563 new ResolveEventHandler( 553 new ResolveEventHandler(
@@ -613,7 +603,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
613 if (!m_Scripts.ContainsKey(itemID)) 603 if (!m_Scripts.ContainsKey(itemID))
614 return; 604 return;
615 605
616 IScriptInstance instance=m_Scripts[itemID]; 606 IScriptInstance instance = m_Scripts[itemID];
617 m_Scripts.Remove(itemID); 607 m_Scripts.Remove(itemID);
618 608
619 instance.ClearQueue(); 609 instance.ClearQueue();
@@ -685,17 +675,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
685 675
686 foreach (UUID assetID in assetIDList) 676 foreach (UUID assetID in assetIDList)
687 { 677 {
688// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]); 678 // m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]);
689 try 679 try
690 { 680 {
691 if (File.Exists(m_Assemblies[assetID])) 681 if (File.Exists(m_Assemblies[assetID]))
692 File.Delete(m_Assemblies[assetID]); 682 File.Delete(m_Assemblies[assetID]);
693 683
694 if (File.Exists(m_Assemblies[assetID]+".state")) 684 if (File.Exists(m_Assemblies[assetID] + ".state"))
695 File.Delete(m_Assemblies[assetID]+".state"); 685 File.Delete(m_Assemblies[assetID] + ".state");
696 686
697 if (File.Exists(m_Assemblies[assetID]+".mdb")) 687 if (File.Exists(m_Assemblies[assetID] + ".mdb"))
698 File.Delete(m_Assemblies[assetID]+".mdb"); 688 File.Delete(m_Assemblies[assetID] + ".mdb");
699 } 689 }
700 catch (Exception) 690 catch (Exception)
701 { 691 {
@@ -713,7 +703,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
713 703
714 AppDomain.Unload(domain); 704 AppDomain.Unload(domain);
715 domain = null; 705 domain = null;
716// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); 706 // m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
717 } 707 }
718 } 708 }
719 709
@@ -745,8 +735,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
745 return new XWorkItem(m_ThreadPool.QueueWorkItem( 735 return new XWorkItem(m_ThreadPool.QueueWorkItem(
746 new WorkItemCallback(this.ProcessEventHandler), 736 new WorkItemCallback(this.ProcessEventHandler),
747 parms)); 737 parms));
748 } 738 }
749 739
750 /// <summary> 740 /// <summary>
751 /// Process a previously posted script event. 741 /// Process a previously posted script event.
752 /// </summary> 742 /// </summary>
@@ -757,8 +747,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
757 CultureInfo USCulture = new CultureInfo("en-US"); 747 CultureInfo USCulture = new CultureInfo("en-US");
758 Thread.CurrentThread.CurrentCulture = USCulture; 748 Thread.CurrentThread.CurrentCulture = USCulture;
759 749
760 IScriptInstance instance = (ScriptInstance) parms; 750 IScriptInstance instance = (ScriptInstance)parms;
761 751
762 //m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance); 752 //m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance);
763 753
764 return instance.EventProcessor(); 754 return instance.EventProcessor();
@@ -773,13 +763,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
773 public bool PostObjectEvent(uint localID, EventParams p) 763 public bool PostObjectEvent(uint localID, EventParams p)
774 { 764 {
775 bool result = false; 765 bool result = false;
776 766
777 lock (m_PrimObjects) 767 lock (m_PrimObjects)
778 { 768 {
779 if (!m_PrimObjects.ContainsKey(localID)) 769 if (!m_PrimObjects.ContainsKey(localID))
780 return false; 770 return false;
781 771
782 772
783 foreach (UUID itemID in m_PrimObjects[localID]) 773 foreach (UUID itemID in m_PrimObjects[localID])
784 { 774 {
785 if (m_Scripts.ContainsKey(itemID)) 775 if (m_Scripts.ContainsKey(itemID))
@@ -831,7 +821,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
831 foreach (string s in pathList) 821 foreach (string s in pathList)
832 { 822 {
833 string path = Path.Combine(Directory.GetCurrentDirectory(), 823 string path = Path.Combine(Directory.GetCurrentDirectory(),
834 Path.Combine(s, assemblyName))+".dll"; 824 Path.Combine(s, assemblyName)) + ".dll";
835 825
836 if (File.Exists(path)) 826 if (File.Exists(path))
837 return Assembly.LoadFrom(path); 827 return Assembly.LoadFrom(path);
@@ -969,7 +959,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
969 i.Running = prevRunning; 959 i.Running = prevRunning;
970 } 960 }
971 961
972 DoBackup(new Object[] {0}); 962 DoBackup(new Object[] { 0 });
973 } 963 }
974 964
975 public IScriptApi GetApi(UUID itemID, string name) 965 public IScriptApi GetApi(UUID itemID, string name)