diff options
author | Diva Canto | 2012-12-06 20:04:59 -0800 |
---|---|---|
committer | Diva Canto | 2012-12-06 20:04:59 -0800 |
commit | 3c9f8c9c46546da0944632b853313aa52f38cc00 (patch) | |
tree | 548bef5b08feb9e6df9e136de5e4a4fd4ca3c549 /OpenSim/Region/ScriptEngine | |
parent | Trying to prevent old route of sending attachments, simulator version unknown... (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-3c9f8c9c46546da0944632b853313aa52f38cc00.zip opensim-SC-3c9f8c9c46546da0944632b853313aa52f38cc00.tar.gz opensim-SC-3c9f8c9c46546da0944632b853313aa52f38cc00.tar.bz2 opensim-SC-3c9f8c9c46546da0944632b853313aa52f38cc00.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
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 5793cc9..5ad6eeb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -173,6 +173,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
173 | 173 | ||
174 | public Queue EventQueue { get; private set; } | 174 | public Queue EventQueue { get; private set; } |
175 | 175 | ||
176 | public long EventsQueued | ||
177 | { | ||
178 | get | ||
179 | { | ||
180 | lock (EventQueue) | ||
181 | return EventQueue.Count; | ||
182 | } | ||
183 | } | ||
184 | |||
185 | public long EventsProcessed { get; private set; } | ||
186 | |||
176 | public int StartParam { get; set; } | 187 | public int StartParam { get; set; } |
177 | 188 | ||
178 | public TaskInventoryItem ScriptTask { get; private set; } | 189 | public TaskInventoryItem ScriptTask { get; private set; } |
@@ -774,6 +785,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
774 | ChatTypeEnum.DebugChannel, 2147483647, | 785 | ChatTypeEnum.DebugChannel, 2147483647, |
775 | part.AbsolutePosition, | 786 | part.AbsolutePosition, |
776 | part.Name, part.UUID, false); | 787 | part.Name, part.UUID, false); |
788 | |||
789 | |||
790 | m_log.DebugFormat( | ||
791 | "[SCRIPT INSTANCE]: Runtime error in script {0}, part {1} {2} at {3} in {4}, displayed error {5}, actual exception {6}", | ||
792 | ScriptName, | ||
793 | PrimName, | ||
794 | part.UUID, | ||
795 | part.AbsolutePosition, | ||
796 | part.ParentGroup.Scene.Name, | ||
797 | text.Replace("\n", "\\n"), | ||
798 | e.InnerException); | ||
777 | } | 799 | } |
778 | catch (Exception) | 800 | catch (Exception) |
779 | { | 801 | { |
@@ -808,6 +830,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
808 | // script engine to run the next event. | 830 | // script engine to run the next event. |
809 | lock (EventQueue) | 831 | lock (EventQueue) |
810 | { | 832 | { |
833 | EventsProcessed++; | ||
834 | |||
811 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 835 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
812 | { | 836 | { |
813 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | 837 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
@@ -1013,7 +1037,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1013 | "({0}): {1}", scriptLine - 1, | 1037 | "({0}): {1}", scriptLine - 1, |
1014 | e.InnerException.Message); | 1038 | e.InnerException.Message); |
1015 | 1039 | ||
1016 | System.Console.WriteLine(e.ToString()+"\n"); | ||
1017 | return message; | 1040 | return message; |
1018 | } | 1041 | } |
1019 | } | 1042 | } |
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 0460f22..965101a 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -30,6 +30,7 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Linq; | ||
33 | using System.Reflection; | 34 | using System.Reflection; |
34 | using System.Security; | 35 | using System.Security; |
35 | using System.Security.Policy; | 36 | using System.Security.Policy; |
@@ -377,9 +378,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
377 | /// </summary> | 378 | /// </summary> |
378 | /// <param name="cmdparams"></param> | 379 | /// <param name="cmdparams"></param> |
379 | /// <param name="instance"></param> | 380 | /// <param name="instance"></param> |
380 | /// <returns>true if we're okay to proceed, false if not.</returns> | 381 | /// <param name="comparer">Basis on which to sort output. Can be null if no sort needs to take place</param> |
381 | private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action) | 382 | private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action) |
382 | { | 383 | { |
384 | HandleScriptsAction<object>(cmdparams, action, null); | ||
385 | } | ||
386 | |||
387 | /// <summary> | ||
388 | /// Parse the raw item id into a script instance from the command params if it's present. | ||
389 | /// </summary> | ||
390 | /// <param name="cmdparams"></param> | ||
391 | /// <param name="instance"></param> | ||
392 | /// <param name="keySelector">Basis on which to sort output. Can be null if no sort needs to take place</param> | ||
393 | private void HandleScriptsAction<TKey>( | ||
394 | string[] cmdparams, Action<IScriptInstance> action, Func<IScriptInstance, TKey> keySelector) | ||
395 | { | ||
383 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) | 396 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) |
384 | return; | 397 | return; |
385 | 398 | ||
@@ -390,7 +403,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
390 | 403 | ||
391 | if (cmdparams.Length == 2) | 404 | if (cmdparams.Length == 2) |
392 | { | 405 | { |
393 | foreach (IScriptInstance instance in m_Scripts.Values) | 406 | IEnumerable<IScriptInstance> scripts = m_Scripts.Values; |
407 | |||
408 | if (keySelector != null) | ||
409 | scripts = scripts.OrderBy<IScriptInstance, TKey>(keySelector); | ||
410 | |||
411 | foreach (IScriptInstance instance in scripts) | ||
394 | action(instance); | 412 | action(instance); |
395 | 413 | ||
396 | return; | 414 | return; |
@@ -437,9 +455,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
437 | StringBuilder sb = new StringBuilder(); | 455 | StringBuilder sb = new StringBuilder(); |
438 | sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); | 456 | sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); |
439 | 457 | ||
458 | long scriptsLoaded, eventsQueued = 0, eventsProcessed = 0; | ||
459 | |||
440 | lock (m_Scripts) | 460 | lock (m_Scripts) |
441 | sb.AppendFormat("Scripts loaded : {0}\n", m_Scripts.Count); | 461 | { |
462 | scriptsLoaded = m_Scripts.Count; | ||
442 | 463 | ||
464 | foreach (IScriptInstance si in m_Scripts.Values) | ||
465 | { | ||
466 | eventsQueued += si.EventsQueued; | ||
467 | eventsProcessed += si.EventsProcessed; | ||
468 | } | ||
469 | } | ||
470 | |||
471 | sb.AppendFormat("Scripts loaded : {0}\n", scriptsLoaded); | ||
443 | sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count); | 472 | sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count); |
444 | sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); | 473 | sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); |
445 | sb.AppendFormat("Max threads : {0}\n", m_ThreadPool.MaxThreads); | 474 | sb.AppendFormat("Max threads : {0}\n", m_ThreadPool.MaxThreads); |
@@ -448,6 +477,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
448 | sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); | 477 | sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); |
449 | sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); | 478 | sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); |
450 | // sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); | 479 | // sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); |
480 | sb.AppendFormat("Events queued : {0}\n", eventsQueued); | ||
481 | sb.AppendFormat("Events processed : {0}\n", eventsProcessed); | ||
451 | 482 | ||
452 | SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(this); | 483 | SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(this); |
453 | sb.AppendFormat("Sensors : {0}\n", sr != null ? sr.SensorsCount : 0); | 484 | sb.AppendFormat("Sensors : {0}\n", sr != null ? sr.SensorsCount : 0); |
@@ -478,7 +509,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
478 | } | 509 | } |
479 | } | 510 | } |
480 | 511 | ||
481 | HandleScriptsAction(cmdparams, HandleShowScript); | 512 | HandleScriptsAction<long>(cmdparams, HandleShowScript, si => si.EventsProcessed); |
482 | } | 513 | } |
483 | 514 | ||
484 | private void HandleShowScript(IScriptInstance instance) | 515 | private void HandleShowScript(IScriptInstance instance) |
@@ -508,10 +539,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
508 | 539 | ||
509 | sb.AppendFormat("Script name : {0}\n", instance.ScriptName); | 540 | sb.AppendFormat("Script name : {0}\n", instance.ScriptName); |
510 | sb.AppendFormat("Status : {0}\n", status); | 541 | sb.AppendFormat("Status : {0}\n", status); |
511 | 542 | sb.AppendFormat("Queued events : {0}\n", instance.EventsQueued); | |
512 | lock (eq) | 543 | sb.AppendFormat("Processed events : {0}\n", instance.EventsProcessed); |
513 | sb.AppendFormat("Queued events : {0}\n", eq.Count); | ||
514 | |||
515 | sb.AppendFormat("Item UUID : {0}\n", instance.ItemID); | 544 | sb.AppendFormat("Item UUID : {0}\n", instance.ItemID); |
516 | sb.AppendFormat("Containing part name: {0}\n", instance.PrimName); | 545 | sb.AppendFormat("Containing part name: {0}\n", instance.PrimName); |
517 | sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID); | 546 | sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID); |
@@ -1018,8 +1047,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1018 | 1047 | ||
1019 | string assembly = ""; | 1048 | string assembly = ""; |
1020 | 1049 | ||
1021 | CultureInfo USCulture = new CultureInfo("en-US"); | 1050 | Culture.SetCurrentCulture(); |
1022 | Thread.CurrentThread.CurrentCulture = USCulture; | ||
1023 | 1051 | ||
1024 | Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; | 1052 | Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; |
1025 | 1053 | ||
@@ -1415,8 +1443,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1415 | /// <returns></returns> | 1443 | /// <returns></returns> |
1416 | private object ProcessEventHandler(object parms) | 1444 | private object ProcessEventHandler(object parms) |
1417 | { | 1445 | { |
1418 | CultureInfo USCulture = new CultureInfo("en-US"); | 1446 | Culture.SetCurrentCulture(); |
1419 | Thread.CurrentThread.CurrentCulture = USCulture; | ||
1420 | 1447 | ||
1421 | IScriptInstance instance = (ScriptInstance) parms; | 1448 | IScriptInstance instance = (ScriptInstance) parms; |
1422 | 1449 | ||