diff options
author | Teravus Ovares | 2009-01-19 17:11:57 +0000 |
---|---|---|
committer | Teravus Ovares | 2009-01-19 17:11:57 +0000 |
commit | 8e01f75784bd7b719a6957de40daf949eb01fcdf (patch) | |
tree | 4d1a703e7417093f7d75fc0f6f588e01b295ca9c /OpenSim/Region/ScriptEngine/XEngine | |
parent | * Remove unused prims.ParentID field from SQLite and MySQL (diff) | |
download | opensim-SC-8e01f75784bd7b719a6957de40daf949eb01fcdf.zip opensim-SC-8e01f75784bd7b719a6957de40daf949eb01fcdf.tar.gz opensim-SC-8e01f75784bd7b719a6957de40daf949eb01fcdf.tar.bz2 opensim-SC-8e01f75784bd7b719a6957de40daf949eb01fcdf.tar.xz |
* Progressive texture patch + PriorityQueue put into the LLClient namespace.
* Updates LibOMV to r2362
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 102 |
1 files changed, 56 insertions, 46 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 61b16f4..30ce79b 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,17 +537,27 @@ 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 | m_AppDomains[appDomain] = | 547 | AppDomain sandbox = |
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; | ||
551 | 561 | ||
552 | m_AppDomains[appDomain].AssemblyResolve += | 562 | m_AppDomains[appDomain].AssemblyResolve += |
553 | new ResolveEventHandler( | 563 | new ResolveEventHandler( |
@@ -603,7 +613,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
603 | if (!m_Scripts.ContainsKey(itemID)) | 613 | if (!m_Scripts.ContainsKey(itemID)) |
604 | return; | 614 | return; |
605 | 615 | ||
606 | IScriptInstance instance = m_Scripts[itemID]; | 616 | IScriptInstance instance=m_Scripts[itemID]; |
607 | m_Scripts.Remove(itemID); | 617 | m_Scripts.Remove(itemID); |
608 | 618 | ||
609 | instance.ClearQueue(); | 619 | instance.ClearQueue(); |
@@ -675,17 +685,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
675 | 685 | ||
676 | foreach (UUID assetID in assetIDList) | 686 | foreach (UUID assetID in assetIDList) |
677 | { | 687 | { |
678 | // m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]); | 688 | // m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]); |
679 | try | 689 | try |
680 | { | 690 | { |
681 | if (File.Exists(m_Assemblies[assetID])) | 691 | if (File.Exists(m_Assemblies[assetID])) |
682 | File.Delete(m_Assemblies[assetID]); | 692 | File.Delete(m_Assemblies[assetID]); |
683 | 693 | ||
684 | if (File.Exists(m_Assemblies[assetID] + ".state")) | 694 | if (File.Exists(m_Assemblies[assetID]+".state")) |
685 | File.Delete(m_Assemblies[assetID] + ".state"); | 695 | File.Delete(m_Assemblies[assetID]+".state"); |
686 | 696 | ||
687 | if (File.Exists(m_Assemblies[assetID] + ".mdb")) | 697 | if (File.Exists(m_Assemblies[assetID]+".mdb")) |
688 | File.Delete(m_Assemblies[assetID] + ".mdb"); | 698 | File.Delete(m_Assemblies[assetID]+".mdb"); |
689 | } | 699 | } |
690 | catch (Exception) | 700 | catch (Exception) |
691 | { | 701 | { |
@@ -703,7 +713,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
703 | 713 | ||
704 | AppDomain.Unload(domain); | 714 | AppDomain.Unload(domain); |
705 | domain = null; | 715 | domain = null; |
706 | // m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); | 716 | // m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); |
707 | } | 717 | } |
708 | } | 718 | } |
709 | 719 | ||
@@ -735,8 +745,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
735 | return new XWorkItem(m_ThreadPool.QueueWorkItem( | 745 | return new XWorkItem(m_ThreadPool.QueueWorkItem( |
736 | new WorkItemCallback(this.ProcessEventHandler), | 746 | new WorkItemCallback(this.ProcessEventHandler), |
737 | parms)); | 747 | parms)); |
738 | } | 748 | } |
739 | 749 | ||
740 | /// <summary> | 750 | /// <summary> |
741 | /// Process a previously posted script event. | 751 | /// Process a previously posted script event. |
742 | /// </summary> | 752 | /// </summary> |
@@ -747,8 +757,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
747 | CultureInfo USCulture = new CultureInfo("en-US"); | 757 | CultureInfo USCulture = new CultureInfo("en-US"); |
748 | Thread.CurrentThread.CurrentCulture = USCulture; | 758 | Thread.CurrentThread.CurrentCulture = USCulture; |
749 | 759 | ||
750 | IScriptInstance instance = (ScriptInstance)parms; | 760 | IScriptInstance instance = (ScriptInstance) parms; |
751 | 761 | ||
752 | //m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance); | 762 | //m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance); |
753 | 763 | ||
754 | return instance.EventProcessor(); | 764 | return instance.EventProcessor(); |
@@ -763,13 +773,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
763 | public bool PostObjectEvent(uint localID, EventParams p) | 773 | public bool PostObjectEvent(uint localID, EventParams p) |
764 | { | 774 | { |
765 | bool result = false; | 775 | bool result = false; |
766 | 776 | ||
767 | lock (m_PrimObjects) | 777 | lock (m_PrimObjects) |
768 | { | 778 | { |
769 | if (!m_PrimObjects.ContainsKey(localID)) | 779 | if (!m_PrimObjects.ContainsKey(localID)) |
770 | return false; | 780 | return false; |
771 | 781 | ||
772 | 782 | ||
773 | foreach (UUID itemID in m_PrimObjects[localID]) | 783 | foreach (UUID itemID in m_PrimObjects[localID]) |
774 | { | 784 | { |
775 | if (m_Scripts.ContainsKey(itemID)) | 785 | if (m_Scripts.ContainsKey(itemID)) |
@@ -821,7 +831,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
821 | foreach (string s in pathList) | 831 | foreach (string s in pathList) |
822 | { | 832 | { |
823 | string path = Path.Combine(Directory.GetCurrentDirectory(), | 833 | string path = Path.Combine(Directory.GetCurrentDirectory(), |
824 | Path.Combine(s, assemblyName)) + ".dll"; | 834 | Path.Combine(s, assemblyName))+".dll"; |
825 | 835 | ||
826 | if (File.Exists(path)) | 836 | if (File.Exists(path)) |
827 | return Assembly.LoadFrom(path); | 837 | return Assembly.LoadFrom(path); |
@@ -959,7 +969,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
959 | i.Running = prevRunning; | 969 | i.Running = prevRunning; |
960 | } | 970 | } |
961 | 971 | ||
962 | DoBackup(new Object[] { 0 }); | 972 | DoBackup(new Object[] {0}); |
963 | } | 973 | } |
964 | 974 | ||
965 | public IScriptApi GetApi(UUID itemID, string name) | 975 | public IScriptApi GetApi(UUID itemID, string name) |