aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs51
8 files changed, 86 insertions, 20 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index b04f6b6..0cef550 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -114,6 +114,16 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
114 UUID AssetID { get; } 114 UUID AssetID { get; }
115 Queue EventQueue { get; } 115 Queue EventQueue { get; }
116 116
117 /// <summary>
118 /// Number of events queued for processing.
119 /// </summary>
120 long EventsQueued { get; }
121
122 /// <summary>
123 /// Number of events processed by this script instance.
124 /// </summary>
125 long EventsProcessed { get; }
126
117 void ClearQueue(); 127 void ClearQueue();
118 int StartParam { get; set; } 128 int StartParam { get; set; }
119 129
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 771db0c..538cb8b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -174,6 +174,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
174 174
175 public Queue EventQueue { get; private set; } 175 public Queue EventQueue { get; private set; }
176 176
177 public long EventsQueued
178 {
179 get
180 {
181 lock (EventQueue)
182 return EventQueue.Count;
183 }
184 }
185
186 public long EventsProcessed { get; private set; }
187
177 public int StartParam { get; set; } 188 public int StartParam { get; set; }
178 189
179 public TaskInventoryItem ScriptTask { get; private set; } 190 public TaskInventoryItem ScriptTask { get; private set; }
@@ -776,6 +787,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
776 ChatTypeEnum.DebugChannel, 2147483647, 787 ChatTypeEnum.DebugChannel, 2147483647,
777 part.AbsolutePosition, 788 part.AbsolutePosition,
778 part.Name, part.UUID, false); 789 part.Name, part.UUID, false);
790
791
792 m_log.DebugFormat(
793 "[SCRIPT INSTANCE]: Runtime error in script {0}, part {1} {2} at {3} in {4}, displayed error {5}, actual exception {6}",
794 ScriptName,
795 PrimName,
796 part.UUID,
797 part.AbsolutePosition,
798 part.ParentGroup.Scene.Name,
799 text.Replace("\n", "\\n"),
800 e.InnerException);
779 } 801 }
780 catch (Exception) 802 catch (Exception)
781 { 803 {
@@ -810,6 +832,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
810 // script engine to run the next event. 832 // script engine to run the next event.
811 lock (EventQueue) 833 lock (EventQueue)
812 { 834 {
835 EventsProcessed++;
836
813 if (EventQueue.Count > 0 && Running && !ShuttingDown) 837 if (EventQueue.Count > 0 && Running && !ShuttingDown)
814 { 838 {
815 m_CurrentWorkItem = Engine.QueueEventHandler(this); 839 m_CurrentWorkItem = Engine.QueueEventHandler(this);
@@ -1015,7 +1039,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1015 "({0}): {1}", scriptLine - 1, 1039 "({0}): {1}", scriptLine - 1,
1016 e.InnerException.Message); 1040 e.InnerException.Message);
1017 1041
1018 System.Console.WriteLine(e.ToString()+"\n");
1019 return message; 1042 return message;
1020 } 1043 }
1021 } 1044 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
index 2c9d9e8..cb7291a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
@@ -57,8 +57,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
57 protected XEngine.XEngine m_engine; 57 protected XEngine.XEngine m_engine;
58 58
59 [SetUp] 59 [SetUp]
60 public void SetUp() 60 public override void SetUp()
61 { 61 {
62 base.SetUp();
63
62 IConfigSource initConfigSource = new IniConfigSource(); 64 IConfigSource initConfigSource = new IniConfigSource();
63 IConfig config = initConfigSource.AddConfig("XEngine"); 65 IConfig config = initConfigSource.AddConfig("XEngine");
64 config.Set("Enabled", "true"); 66 config.Set("Enabled", "true");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
index 57f19b9..d9b17d7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
@@ -62,8 +62,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
62 protected XEngine.XEngine m_engine; 62 protected XEngine.XEngine m_engine;
63 63
64 [SetUp] 64 [SetUp]
65 public void SetUp() 65 public override void SetUp()
66 { 66 {
67 base.SetUp();
68
67 IConfigSource initConfigSource = new IniConfigSource(); 69 IConfigSource initConfigSource = new IniConfigSource();
68 IConfig config = initConfigSource.AddConfig("XEngine"); 70 IConfig config = initConfigSource.AddConfig("XEngine");
69 config.Set("Enabled", "true"); 71 config.Set("Enabled", "true");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
index 182b07b..98017d8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
@@ -51,8 +51,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
51 private LSL_Api m_lslApi; 51 private LSL_Api m_lslApi;
52 52
53 [SetUp] 53 [SetUp]
54 public void SetUp() 54 public override void SetUp()
55 { 55 {
56 base.SetUp();
57
56 IConfigSource initConfigSource = new IniConfigSource(); 58 IConfigSource initConfigSource = new IniConfigSource();
57 IConfig config = initConfigSource.AddConfig("XEngine"); 59 IConfig config = initConfigSource.AddConfig("XEngine");
58 config.Set("Enabled", "true"); 60 config.Set("Enabled", "true");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index 213f33f..1381d2b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -57,8 +57,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
57 protected XEngine.XEngine m_engine; 57 protected XEngine.XEngine m_engine;
58 58
59 [SetUp] 59 [SetUp]
60 public void SetUp() 60 public override void SetUp()
61 { 61 {
62 base.SetUp();
63
62 IConfigSource initConfigSource = new IniConfigSource(); 64 IConfigSource initConfigSource = new IniConfigSource();
63 IConfig config = initConfigSource.AddConfig("XEngine"); 65 IConfig config = initConfigSource.AddConfig("XEngine");
64 config.Set("Enabled", "true"); 66 config.Set("Enabled", "true");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index b49bcc2..d6c82f1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -127,12 +127,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
127 OSSL_Api osslApi = new OSSL_Api(); 127 OSSL_Api osslApi = new OSSL_Api();
128 osslApi.Initialize(m_engine, so.RootPart, null); 128 osslApi.Initialize(m_engine, so.RootPart, null);
129 129
130 string npcRaw;
131 bool gotExpectedException = false; 130 bool gotExpectedException = false;
132 try 131 try
133 { 132 {
134 npcRaw 133 osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
135 = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
136 } 134 }
137 catch (ScriptException) 135 catch (ScriptException)
138 { 136 {
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 9f05666..05ba890 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Diagnostics; //for [DebuggerNonUserCode] 31using System.Diagnostics; //for [DebuggerNonUserCode]
32using System.Globalization; 32using System.Globalization;
33using System.IO; 33using System.IO;
34using System.Linq;
34using System.Reflection; 35using System.Reflection;
35using System.Security; 36using System.Security;
36using System.Security.Policy; 37using System.Security.Policy;
@@ -445,9 +446,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
445 /// </summary> 446 /// </summary>
446 /// <param name="cmdparams"></param> 447 /// <param name="cmdparams"></param>
447 /// <param name="instance"></param> 448 /// <param name="instance"></param>
448 /// <returns>true if we're okay to proceed, false if not.</returns> 449 /// <param name="comparer">Basis on which to sort output. Can be null if no sort needs to take place</param>
449 private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action) 450 private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action)
450 { 451 {
452 HandleScriptsAction<object>(cmdparams, action, null);
453 }
454
455 /// <summary>
456 /// Parse the raw item id into a script instance from the command params if it's present.
457 /// </summary>
458 /// <param name="cmdparams"></param>
459 /// <param name="instance"></param>
460 /// <param name="keySelector">Basis on which to sort output. Can be null if no sort needs to take place</param>
461 private void HandleScriptsAction<TKey>(
462 string[] cmdparams, Action<IScriptInstance> action, Func<IScriptInstance, TKey> keySelector)
463 {
451 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) 464 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
452 return; 465 return;
453 466
@@ -458,7 +471,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
458 471
459 if (cmdparams.Length == 2) 472 if (cmdparams.Length == 2)
460 { 473 {
461 foreach (IScriptInstance instance in m_Scripts.Values) 474 IEnumerable<IScriptInstance> scripts = m_Scripts.Values;
475
476 if (keySelector != null)
477 scripts = scripts.OrderBy<IScriptInstance, TKey>(keySelector);
478
479 foreach (IScriptInstance instance in scripts)
462 action(instance); 480 action(instance);
463 481
464 return; 482 return;
@@ -505,9 +523,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
505 StringBuilder sb = new StringBuilder(); 523 StringBuilder sb = new StringBuilder();
506 sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); 524 sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName);
507 525
526 long scriptsLoaded, eventsQueued = 0, eventsProcessed = 0;
527
508 lock (m_Scripts) 528 lock (m_Scripts)
509 sb.AppendFormat("Scripts loaded : {0}\n", m_Scripts.Count); 529 {
530 scriptsLoaded = m_Scripts.Count;
510 531
532 foreach (IScriptInstance si in m_Scripts.Values)
533 {
534 eventsQueued += si.EventsQueued;
535 eventsProcessed += si.EventsProcessed;
536 }
537 }
538
539 sb.AppendFormat("Scripts loaded : {0}\n", scriptsLoaded);
511 sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count); 540 sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count);
512 sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); 541 sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count);
513 sb.AppendFormat("Max threads : {0}\n", m_ThreadPool.MaxThreads); 542 sb.AppendFormat("Max threads : {0}\n", m_ThreadPool.MaxThreads);
@@ -516,6 +545,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
516 sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); 545 sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads);
517 sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); 546 sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks);
518// sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); 547// sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count);
548 sb.AppendFormat("Events queued : {0}\n", eventsQueued);
549 sb.AppendFormat("Events processed : {0}\n", eventsProcessed);
519 550
520 SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(this); 551 SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(this);
521 sb.AppendFormat("Sensors : {0}\n", sr != null ? sr.SensorsCount : 0); 552 sb.AppendFormat("Sensors : {0}\n", sr != null ? sr.SensorsCount : 0);
@@ -546,7 +577,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
546 } 577 }
547 } 578 }
548 579
549 HandleScriptsAction(cmdparams, HandleShowScript); 580 HandleScriptsAction<long>(cmdparams, HandleShowScript, si => si.EventsProcessed);
550 } 581 }
551 582
552 private void HandleShowScript(IScriptInstance instance) 583 private void HandleShowScript(IScriptInstance instance)
@@ -576,10 +607,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
576 607
577 sb.AppendFormat("Script name : {0}\n", instance.ScriptName); 608 sb.AppendFormat("Script name : {0}\n", instance.ScriptName);
578 sb.AppendFormat("Status : {0}\n", status); 609 sb.AppendFormat("Status : {0}\n", status);
579 610 sb.AppendFormat("Queued events : {0}\n", instance.EventsQueued);
580 lock (eq) 611 sb.AppendFormat("Processed events : {0}\n", instance.EventsProcessed);
581 sb.AppendFormat("Queued events : {0}\n", eq.Count);
582
583 sb.AppendFormat("Item UUID : {0}\n", instance.ItemID); 612 sb.AppendFormat("Item UUID : {0}\n", instance.ItemID);
584 sb.AppendFormat("Containing part name: {0}\n", instance.PrimName); 613 sb.AppendFormat("Containing part name: {0}\n", instance.PrimName);
585 sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID); 614 sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID);
@@ -1089,8 +1118,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1089 1118
1090 string assembly = ""; 1119 string assembly = "";
1091 1120
1092 CultureInfo USCulture = new CultureInfo("en-US"); 1121 Culture.SetCurrentCulture();
1093 Thread.CurrentThread.CurrentCulture = USCulture;
1094 1122
1095 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; 1123 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap;
1096 1124
@@ -1504,8 +1532,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1504 /// <returns></returns> 1532 /// <returns></returns>
1505 private object ProcessEventHandler(object parms) 1533 private object ProcessEventHandler(object parms)
1506 { 1534 {
1507 CultureInfo USCulture = new CultureInfo("en-US"); 1535 Culture.SetCurrentCulture();
1508 Thread.CurrentThread.CurrentCulture = USCulture;
1509 1536
1510 IScriptInstance instance = (ScriptInstance) parms; 1537 IScriptInstance instance = (ScriptInstance) parms;
1511 1538