From 08e509978d81cb3451c205ed59648e3f5da91344 Mon Sep 17 00:00:00 2001 From: Talun Date: Tue, 10 Apr 2012 21:25:05 +0100 Subject: Mantis 55025 Implement script time. Signed-off-by: nebadon --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 82 +++++++++++++++----------- 1 file changed, 48 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 7712076..b7903d5 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1907,45 +1907,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (!topScripts.ContainsKey(si.LocalID)) topScripts[si.RootLocalID] = 0; -// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; -// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); - - // Execution time of the script adjusted by it's measurement period to make scripts started at - // different times comparable. -// float adjustedExecutionTime -// = (float)si.MeasurementPeriodExecutionTime -// / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod) -// / TimeSpan.TicksPerMillisecond; - - long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; - - // Avoid divide by zerp - if (ticksElapsed == 0) - ticksElapsed = 1; + topScripts[si.RootLocalID] += CalculateAdjustedExectionTime(si, tickNow); + } + } - // Scale execution time to the ideal 55 fps frame time for these reasons. - // - // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no - // 'script execution time per frame', which is the original purpose of this value. - // - // 2) Giving the raw execution times is misleading since scripts start at different times, making - // it impossible to compare scripts. - // - // 3) Scaling the raw execution time to the time that the script has been running is better but - // is still misleading since a script that has just been rezzed may appear to have been running - // for much longer. - // - // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect - // since the figure does not represent actual execution time and very hard running scripts will - // never exceed 18ms (though this is a very high number for script execution so is a warning sign). - float adjustedExecutionTime - = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; + return topScripts; + } - topScripts[si.RootLocalID] += adjustedExecutionTime; + public float GetScriptExecutionTime(List itemIDs) + { + if (itemIDs == null|| itemIDs.Count == 0) + { + return 0.0f; + } + float time = 0.0f; + long tickNow = Util.EnvironmentTickCount(); + IScriptInstance si; + // Calculate the time for all scripts that this engine is executing + // Ignore any others + foreach (UUID id in itemIDs) + { + si = GetInstance(id); + if (si != null && si.Running) + { + time += CalculateAdjustedExectionTime(si, tickNow); } } + return time; + } - return topScripts; + private float CalculateAdjustedExectionTime(IScriptInstance si, long tickNow) + { + long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; + + // Avoid divide by zero + if (ticksElapsed == 0) + ticksElapsed = 1; + + // Scale execution time to the ideal 55 fps frame time for these reasons. + // + // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no + // 'script execution time per frame', which is the original purpose of this value. + // + // 2) Giving the raw execution times is misleading since scripts start at different times, making + // it impossible to compare scripts. + // + // 3) Scaling the raw execution time to the time that the script has been running is better but + // is still misleading since a script that has just been rezzed may appear to have been running + // for much longer. + // + // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect + // since the figure does not represent actual execution time and very hard running scripts will + // never exceed 18ms (though this is a very high number for script execution so is a warning sign). + return ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; } public void SuspendScript(UUID itemID) -- cgit v1.1 From ea73a035531a0e957f54fe897f3a3ff7ca3dc22d Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Apr 2012 20:01:41 +0100 Subject: Don't re-add the assembly resolver for each script if not creating the appdomain --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b7903d5..ad2f12e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1021,11 +1021,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine AppDomain sandbox; if (m_AppDomainLoading) + { sandbox = AppDomain.CreateDomain( m_Scene.RegionInfo.RegionID.ToString(), evidence, appSetup); + m_AppDomains[appDomain].AssemblyResolve += + new ResolveEventHandler( + AssemblyResolver.OnAssemblyResolve); + } else + { sandbox = AppDomain.CurrentDomain; + } //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); @@ -1037,9 +1044,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_AppDomains[appDomain] = sandbox; - m_AppDomains[appDomain].AssemblyResolve += - new ResolveEventHandler( - AssemblyResolver.OnAssemblyResolve); m_DomainScripts[appDomain] = new List(); } catch (Exception e) @@ -1984,4 +1988,4 @@ namespace OpenSim.Region.ScriptEngine.XEngine // m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID); } } -} \ No newline at end of file +} -- cgit v1.1 From beb7b8d189a99b4385392b2209930e20b489a0c9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Apr 2012 23:23:37 +0100 Subject: Fix a logic error in app domain creation --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index ad2f12e..23a4cf9 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1025,7 +1025,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine sandbox = AppDomain.CreateDomain( m_Scene.RegionInfo.RegionID.ToString(), evidence, appSetup); - m_AppDomains[appDomain].AssemblyResolve += + sandbox.AssemblyResolve += new ResolveEventHandler( AssemblyResolver.OnAssemblyResolve); } -- cgit v1.1 From 2f398231acda79e313c2975ecdd5a6015cb71a54 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 15:31:45 +0300 Subject: Minor improvements to logging Eliminated an extra newline in the console if the log line doesn't contain a category (example of a category: "[ASSETS]"). --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 23a4cf9..a9b6e67 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1812,9 +1812,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine // if there already exists a file at that location, it may be locked. m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); } + + string textpath = path + ".text"; try { - using (FileStream fs = File.Create(path + ".text")) + using (FileStream fs = File.Create(textpath)) { using (StreamWriter sw = new StreamWriter(fs)) { @@ -1827,7 +1829,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine catch (IOException ex) { // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", textpath, ex.Message); } } } @@ -1876,7 +1878,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine catch (IOException ex) { // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", mappath, ex.Message); } } -- cgit v1.1 From 07e62df5582e28675275b3f5143ec37e5697d283 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Apr 2012 00:58:54 +0100 Subject: Add regression test for teleporting an agent between separated regions on the same simulator. This involves a large amount of change in test scene setup code to allow test scenes to share shared modules SetupScene is now an instance method that requires an instantiation of SceneHelpers, though other SceneHelpers methods are still static May split these out into separate classes in the future. --- OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index 7d7bd82..a3f848c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests // to AssemblyResolver.OnAssemblyResolve fails. xEngineConfig.Set("AppDomainLoading", "false"); - m_scene = SceneHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, null, configSource); + m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); m_scene.StartScripts(); } -- cgit v1.1 From 8e7032ece87d3e0e75f091ea84d482151e90795e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 19 Jun 2012 01:53:50 +0100 Subject: minor: Add a little more detail to IOException logging in XEngine.SetXMLState() Also removes superflous Close() commands for statements taking place within using() constructs Also adds some comment out debug log messages for future use. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a9b6e67..35c338d 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1743,6 +1743,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine public bool SetXMLState(UUID itemID, string xml) { +// m_log.DebugFormat("[XEngine]: Writing state for script item with ID {0}", itemID); + if (xml == String.Empty) return false; @@ -1803,14 +1805,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine { using (FileStream fs = File.Create(path)) { +// m_log.DebugFormat("[XEngine]: Writing assembly file {0}", path); + fs.Write(filedata, 0, filedata.Length); - fs.Close(); } } catch (IOException ex) { // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); + m_log.ErrorFormat("[XEngine]: Error whilst writing assembly file {0}, {1}", path, ex.Message); } string textpath = path + ".text"; @@ -1820,16 +1823,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine { using (StreamWriter sw = new StreamWriter(fs)) { +// m_log.DebugFormat("[XEngine]: Writing .text file {0}", textpath); + sw.Write(base64); - sw.Close(); } - fs.Close(); } } catch (IOException ex) { // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", textpath, ex.Message); + m_log.ErrorFormat("[XEngine]: Error whilst writing .text file {0}, {1}", textpath, ex.Message); } } } @@ -1843,16 +1846,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine { using (StreamWriter ssw = new StreamWriter(sfs)) { +// m_log.DebugFormat("[XEngine]: Writing state file {0}", statepath); + ssw.Write(stateE.OuterXml); - ssw.Close(); } - sfs.Close(); } } catch (IOException ex) { // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); + m_log.ErrorFormat("[XEngine]: Error whilst writing state file {0}, {1}", statepath, ex.Message); } XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); @@ -1869,16 +1872,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine { using (StreamWriter msw = new StreamWriter(mfs)) { +// m_log.DebugFormat("[XEngine]: Writing linemap file {0}", mappath); + msw.Write(mapE.InnerText); - msw.Close(); } - mfs.Close(); } } catch (IOException ex) { // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", mappath, ex.Message); + m_log.ErrorFormat("[XEngine]: Linemap file {0} already exists! {1}", mappath, ex.Message); } } -- cgit v1.1 From ef686ead37f475ad9e16f637fe1efc41cfbbd6f4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 19 Jun 2012 02:11:46 +0100 Subject: Like the assembly and text files, only write the c#-lsl linemap in XEngine.SetXMLState() if the trust binaries flag is set. This doesn't affect other locations where the map is written, such as on script compilation. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 54 +++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 35c338d..aedf2c1 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1835,6 +1835,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_log.ErrorFormat("[XEngine]: Error whilst writing .text file {0}, {1}", textpath, ex.Message); } } + + XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); + if (mapL.Count > 0) + { + XmlElement mapE = (XmlElement)mapL[0]; + + string mappath = Path.Combine(m_ScriptEnginesPath, World.RegionInfo.RegionID.ToString()); + mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); + + try + { + using (FileStream mfs = File.Create(mappath)) + { + using (StreamWriter msw = new StreamWriter(mfs)) + { + // m_log.DebugFormat("[XEngine]: Writing linemap file {0}", mappath); + + msw.Write(mapE.InnerText); + } + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: Linemap file {0} already exists! {1}", mappath, ex.Message); + } + } } string statepath = Path.Combine(m_ScriptEnginesPath, World.RegionInfo.RegionID.ToString()); @@ -1858,33 +1885,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_log.ErrorFormat("[XEngine]: Error whilst writing state file {0}, {1}", statepath, ex.Message); } - XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); - if (mapL.Count > 0) - { - XmlElement mapE = (XmlElement)mapL[0]; - - string mappath = Path.Combine(m_ScriptEnginesPath, World.RegionInfo.RegionID.ToString()); - mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); - - try - { - using (FileStream mfs = File.Create(mappath)) - { - using (StreamWriter msw = new StreamWriter(mfs)) - { -// m_log.DebugFormat("[XEngine]: Writing linemap file {0}", mappath); - - msw.Write(mapE.InnerText); - } - } - } - catch (IOException ex) - { - // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: Linemap file {0} already exists! {1}", mappath, ex.Message); - } - } - return true; } -- cgit v1.1 From 0fa303b1cf244b3066395413e640318b2122c19f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 20 Jun 2012 00:10:19 +0100 Subject: Log how many scripts are candidates for starting and how many are actually started. Adds DebugLevel infrastructure to XEngine though currently commented out and unused. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 64 ++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index aedf2c1..3f623de 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -62,6 +62,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Control the printing of certain debug messages. + /// + /// + /// If DebugLevel >= 1, then we log every time that a script is started. + /// +// public int DebugLevel { get; set; } + private SmartThreadPool m_ThreadPool; private int m_MaxScriptQueue; private Scene m_Scene; @@ -216,9 +224,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; - m_log.InfoFormat("[XEngine] Initializing scripts in region {0}", - scene.RegionInfo.RegionName); m_Scene = scene; + m_log.InfoFormat("[XEngine]: Initializing scripts in region {0}", m_Scene.RegionInfo.RegionName); m_MinThreads = m_ScriptConfig.GetInt("MinThreads", 2); m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); @@ -321,9 +328,42 @@ namespace OpenSim.Region.ScriptEngine.XEngine "Starts all stopped scripts." + "If a is given then only that script will be started. Otherwise, all suitable scripts are started.", (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); + +// MainConsole.Instance.Commands.AddCommand( +// "Debug", false, "debug xengine", "debug xengine []", +// "Turn on detailed xengine debugging.", +// "If level <= 0, then no extra logging is done.\n" +// + "If level >= 1, then we log every time that a script is started.", +// HandleDebugLevelCommand); } /// + /// Change debug level + /// + /// + /// +// private void HandleDebugLevelCommand(string module, string[] args) +// { +// if (args.Length == 3) +// { +// int newDebug; +// if (int.TryParse(args[2], out newDebug)) +// { +// DebugLevel = newDebug; +// MainConsole.Instance.OutputFormat("Debug level set to {0}", newDebug); +// } +// } +// else if (args.Length == 2) +// { +// MainConsole.Instance.OutputFormat("Current debug level is {0}", DebugLevel); +// } +// else +// { +// MainConsole.Instance.Output("Usage: debug xengine 0..1"); +// } +// } + + /// /// Parse the raw item id into a script instance from the command params if it's present. /// /// @@ -825,8 +865,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine } object[] o; + + int scriptsStarted = 0; + while (m_CompileQueue.Dequeue(out o)) - DoOnRezScript(o); + { + if (DoOnRezScript(o)) + { + scriptsStarted++; + +// if (scriptsStarted % 50 == 0) +// m_log.DebugFormat( +// "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); + } + } + + m_log.DebugFormat( + "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); // NOTE: Despite having a lockless queue, this lock is required // to make sure there is never no compile thread while there @@ -1066,7 +1121,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine part.ParentGroup.RootPart.Name, item.Name, startParam, postOnRez, stateSource, m_MaxScriptQueue); - + +// if (DebugLevel >= 1) m_log.DebugFormat( "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, -- cgit v1.1 From 881e92a7260a5823867b8f93b88c1b706a13cb56 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 20 Jun 2012 00:19:50 +0100 Subject: Raise some IO associated Exception logging in XEngine to error level, in line with other similar cases. Remove more unnecessary Close() calls - these are being triggered by the Dispose() called when exiting the using statement for these sdk io objects. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 3f623de..35b58ee 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1715,14 +1715,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine FileMode.Open, FileAccess.Read)) { tfs.Read(tdata, 0, tdata.Length); - tfs.Close(); } assem = new System.Text.ASCIIEncoding().GetString(tdata); } catch (Exception e) { - m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); + m_log.ErrorFormat( + "[XEngine]: Unable to open script textfile {0}{1}, reason: {2}", + assemName, ".text", e.Message); } } } @@ -1739,16 +1740,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine using (FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read)) { fs.Read(data, 0, data.Length); - fs.Close(); } assem = System.Convert.ToBase64String(data); } catch (Exception e) { - m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); + m_log.ErrorFormat( + "[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); } - } } @@ -1761,9 +1761,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine using (StreamReader msr = new StreamReader(mfs)) { map = msr.ReadToEnd(); - msr.Close(); } - mfs.Close(); } } -- cgit v1.1 From 625e5e913a52b26f9af343d6c5bb33c3f8a4ead8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 20 Jun 2012 00:24:39 +0100 Subject: Comment out recently added log message detailing number of scripts started when compile queue empties for now --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 35b58ee..e961e76 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -880,8 +880,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - m_log.DebugFormat( - "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); // NOTE: Despite having a lockless queue, this lock is required // to make sure there is never no compile thread while there -- cgit v1.1 From f907182ab28cd761bebd398dab38f9a997ecd19d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 22 Jun 2012 01:57:14 +0100 Subject: Eliminate unnecessary extra call to TriggerEmptyScriptCompileQueue in XEngine.DoOnRezScriptQueue() The later invocation of this function will happen on an empty compile queue. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index e961e76..26df758 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -855,13 +855,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine { m_InitialStartup = false; System.Threading.Thread.Sleep(15000); - - if (m_CompileQueue.Count == 0) - { - // No scripts on region, so won't get triggered later - // by the queue becoming empty so we trigger it here - m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty); - } } object[] o; @@ -889,11 +882,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine // due to a race condition // lock (m_CompileQueue) - { m_CurrentCompile = null; - } + m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, m_ScriptErrorMessage); + m_ScriptFailCount = 0; return null; -- cgit v1.1 From 9f3feeff8d3a00b965b2151477df5b0b2de3ff1d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 22 Jun 2012 02:10:27 +0100 Subject: If starting scripts on initial sim start, provide INFO level log feedback each time 50 scripts have been started. This is to provide an indication of what's happening now that the default isn't to report every single script start. Changes XEngine logging level in OpenSim.exe.config from WARN to INFO. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 26df758..40f48e3 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -853,7 +853,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine { if (m_InitialStartup) { - m_InitialStartup = false; + // This delay exists to stop mono problems where script compilation and startup would stop the sim + // working properly for the session. System.Threading.Thread.Sleep(15000); } @@ -867,14 +868,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine { scriptsStarted++; -// if (scriptsStarted % 50 == 0) -// m_log.DebugFormat( -// "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); + if (m_InitialStartup) + if (scriptsStarted % 50 == 0) + m_log.InfoFormat( + "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); } } -// m_log.DebugFormat( -// "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); + if (m_InitialStartup) + m_log.InfoFormat( + "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); // NOTE: Despite having a lockless queue, this lock is required // to make sure there is never no compile thread while there @@ -888,6 +891,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_ScriptErrorMessage); m_ScriptFailCount = 0; + m_InitialStartup = false; return null; } -- cgit v1.1 From 80a41e670dd9bbd2771fbcf250362cefa2797306 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 22 Jun 2012 02:23:25 +0100 Subject: Avoid race condition between m_PrimObjects iteration in XEngine.PostObjectEvent and places where the list is modified by extending the m_PrimObjects lock. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 40f48e3..25b27b9 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1363,22 +1363,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine return false; uuids = m_PrimObjects[localID]; - } - foreach (UUID itemID in uuids) - { - IScriptInstance instance = null; - try - { - if (m_Scripts.ContainsKey(itemID)) - instance = m_Scripts[itemID]; - } - catch { /* ignore race conditions */ } - - if (instance != null) + foreach (UUID itemID in uuids) { - instance.PostEvent(p); - result = true; + IScriptInstance instance = null; + try + { + if (m_Scripts.ContainsKey(itemID)) + instance = m_Scripts[itemID]; + } + catch { /* ignore race conditions */ } + + if (instance != null) + { + instance.PostEvent(p); + result = true; + } } } -- cgit v1.1 From 6d3ee8bb39d47ed7b32e8905fa0b2fc31c5a9f80 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 23 Jun 2012 04:11:31 -0400 Subject: Fix script "Running" behavior Unchecking "Running" box in script editor now persists. This fixes http://opensimulator.org/mantis/view.php?id=6057 --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 25b27b9..06ed9d6 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1503,6 +1503,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + public void SetRunEnable(UUID instanceID, bool enable) + { + IScriptInstance instance = GetInstance(instanceID); + if (instance != null) + instance.Run = enable; + } + public bool GetScriptState(UUID itemID) { IScriptInstance instance = GetInstance(itemID); -- cgit v1.1 From f9769a9fcb84a68622abe23160274796937ae0d4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 28 Jun 2012 00:37:23 +0100 Subject: minor: reuse colon index calculation in XEngine.OnRezScript. The index if a colon is found on the first line will always be the same as for the whole script. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 06ed9d6..73d384d 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -768,12 +768,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine int colon = firstline.IndexOf(':'); if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) { - string engineName = firstline.Substring(2, colon-2); + string engineName = firstline.Substring(2, colon - 2); if (names.Contains(engineName)) { engine = engineName; - script = "//" + script.Substring(script.IndexOf(':')+1); + script = "//" + script.Substring(colon + 1); } else { -- cgit v1.1 From 25baa2d894e9bbbb173eb4e6ebe1478d2e3c1265 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 28 Jun 2012 00:58:36 +0100 Subject: Avoid reporting false positives when a colon is in a comment in the first line of a script where the user was not trying to select a different script engine. This works by only posting the "Selected engine unavailable" message if we're falling back on XEngine and the language is one handled by XEngine. In cases where the language is not handled or not allowed, the user will still be notified by the later compiler error. This avoids the overwhelming majority of false positives where the first line contains a : for other reasons (e.g. source control systems, vim settings, etc.) Ultimately, I think it would be better to detect script language/engine with a mechanism that didn't just rely on : detection (e.g like #! in unix scripts). --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 58 ++++++++++++++++++-------- 1 file changed, 41 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 73d384d..a709be3 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -779,24 +779,48 @@ namespace OpenSim.Region.ScriptEngine.XEngine { if (engine == ScriptEngineName) { - SceneObjectPart part = - m_Scene.GetSceneObjectPart( - localID); - - TaskInventoryItem item = - part.Inventory.GetInventoryItem(itemID); - - ScenePresence presence = - m_Scene.GetScenePresence( - item.OwnerID); - - if (presence != null) + // If we are falling back on XEngine as the default engine, then only complain to the user + // if a script language has been explicitly set and it's one that we recognize. If it's + // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message. + // + // This avoids the overwhelming number of false positives where we're in this code because + // there's a colon in a comment in the first line of a script for entirely + // unrelated reasons (e.g. vim settings). + // + // TODO: A better fix would be to deprecate simple : detection and look for some less likely + // string to begin the comment (like #! in unix shell scripts). + bool scriptExplicitlyInXEngineLanguage = false; + string restOfScript = script.Substring(colon + 1); + + // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs + if (restOfScript.StartsWith("c#") + || restOfScript.StartsWith("vb") + || restOfScript.StartsWith("lsl") + || restOfScript.StartsWith("js") + || restOfScript.StartsWith("yp")) + scriptExplicitlyInXEngineLanguage = true; + + if (scriptExplicitlyInXEngineLanguage) { - presence.ControllingClient.SendAgentAlertMessage( - "Selected engine unavailable. "+ - "Running script on "+ - ScriptEngineName, - false); + SceneObjectPart part = + m_Scene.GetSceneObjectPart( + localID); + + TaskInventoryItem item = + part.Inventory.GetInventoryItem(itemID); + + ScenePresence presence = + m_Scene.GetScenePresence( + item.OwnerID); + + if (presence != null) + { + presence.ControllingClient.SendAgentAlertMessage( + "Selected engine unavailable. "+ + "Running script on "+ + ScriptEngineName, + false); + } } } } -- cgit v1.1 From 972b0b52f9acedf13114fbed2ec35bb63adeea79 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 28 Jun 2012 21:30:36 +0100 Subject: If rest of first line after colon is blank then still warn about running in XEngine if engine specified does not exist. This is to take account of situations where the user was intending to specify a script engine using colon using its default language. This probably generates few false positive as scripts are less likely to end a first line colon with a comment for other purposes. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 29 ++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a709be3..35fac4e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -780,27 +780,34 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (engine == ScriptEngineName) { // If we are falling back on XEngine as the default engine, then only complain to the user - // if a script language has been explicitly set and it's one that we recognize. If it's + // if a script language has been explicitly set and it's one that we recognize or there are + // no non-whitespace characters after the colon. + // + // If the script is // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message. // + // If the colon ends the line then we'll risk the false positive as this is more likely + // to signal a real scriptengine line where the user wants to use the default compile language. + // // This avoids the overwhelming number of false positives where we're in this code because // there's a colon in a comment in the first line of a script for entirely // unrelated reasons (e.g. vim settings). // // TODO: A better fix would be to deprecate simple : detection and look for some less likely // string to begin the comment (like #! in unix shell scripts). - bool scriptExplicitlyInXEngineLanguage = false; - string restOfScript = script.Substring(colon + 1); + bool warnRunningInXEngine = false; + string restOfFirstLine = firstline.Substring(colon + 1); // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs - if (restOfScript.StartsWith("c#") - || restOfScript.StartsWith("vb") - || restOfScript.StartsWith("lsl") - || restOfScript.StartsWith("js") - || restOfScript.StartsWith("yp")) - scriptExplicitlyInXEngineLanguage = true; - - if (scriptExplicitlyInXEngineLanguage) + if (restOfFirstLine.StartsWith("c#") + || restOfFirstLine.StartsWith("vb") + || restOfFirstLine.StartsWith("lsl") + || restOfFirstLine.StartsWith("js") + || restOfFirstLine.StartsWith("yp") + || restOfFirstLine.Length == 0) + warnRunningInXEngine = true; + + if (warnRunningInXEngine) { SceneObjectPart part = m_Scene.GetSceneObjectPart( -- cgit v1.1 From d32cf2157670889c571a34f1a4473d672e29627d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 1 Jul 2012 18:30:59 +0100 Subject: Add preservation of running state of scripts when drag-copying. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 35fac4e..7f3bd76 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -2081,5 +2081,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine // else // m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID); } + + public bool HasScript(UUID itemID, out bool running) + { + running = true; + + IScriptInstance instance = GetInstance(itemID); + if (instance == null) + return false; + + running = instance.Running; + return true; + } } } -- cgit v1.1 From eb5ec4a78698a3b1fd6d581c800ac985d5d946fa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 10 Jul 2012 21:42:51 +0100 Subject: If a script is being stopped manually, then give the scriptpool thread 1 second to finish normally before forcibly aborting. This is to avoid the worst of the problems in mono 2.6, 2.10 where an aborted thread does not always release all its locks. This very short grace period is identical to the existing behaviour when a script is removed from the scene. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 7f3bd76..efcae94 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1574,7 +1574,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine { IScriptInstance instance = GetInstance(itemID); if (instance != null) - instance.Stop(0); + { + // Give the script some time to finish processing its last event. Simply aborting the script thread can + // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort. + instance.Stop(1000); + } } public DetectParams GetDetectParams(UUID itemID, int idx) -- cgit v1.1 From fc2456320646df66b95a06d4cd292c3b2385a8ea Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Jul 2012 21:43:35 +0100 Subject: Add regression TestDetachScriptedAttachmentToInventory() This currently only does a relatively crude check for a ScriptState node in the serialized xml --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index efcae94..e07ae1c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1676,12 +1676,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine public string GetXMLState(UUID itemID) { -// m_log.DebugFormat("[XEngine]: Getting XML state for {0}", itemID); +// m_log.DebugFormat("[XEngine]: Getting XML state for script instance {0}", itemID); IScriptInstance instance = GetInstance(itemID); if (instance == null) { -// m_log.DebugFormat("[XEngine]: Found no script for {0}, returning empty string", itemID); +// m_log.DebugFormat("[XEngine]: Found no script instance for {0}, returning empty string", itemID); return ""; } -- cgit v1.1 From 0e611c47d322e1596d4636e283b9b855c7e58b60 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Jul 2012 21:46:46 +0100 Subject: Remove WorldComm module from the regression TestCompileAndStartScript() since the infrastructure no longer fails if this module isn't present, at least on the tested codepaths --- OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index a3f848c..fe4b0fa 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs @@ -58,9 +58,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests // Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); m_xEngine = new XEngine(); - // Necessary to stop serialization complaining - WorldCommModule wcModule = new WorldCommModule(); - IniConfigSource configSource = new IniConfigSource(); IConfig startupConfig = configSource.AddConfig("Startup"); @@ -74,7 +71,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests xEngineConfig.Set("AppDomainLoading", "false"); m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); - SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); + SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine); m_scene.StartScripts(); } -- cgit v1.1 From 33cff9b9d7c9d742b1cb7064ed78677e3f030e72 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Jul 2012 21:55:18 +0100 Subject: Allow XEngine StartDelay to be configured in the [XEngine] config section. This is only currently meant for use by regression tests that don't have any issues if XEngine is started up quickly, since no other operations will be occuring simultaneously. Therefore, this is not yet documented externally. --- OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | 1 + OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index fe4b0fa..f247a0b 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs @@ -65,6 +65,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests IConfig xEngineConfig = configSource.AddConfig("XEngine"); xEngineConfig.Set("Enabled", "true"); + xEngineConfig.Set("StartDelay", "0"); // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call // to AssemblyResolver.OnAssemblyResolve fails. diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index e07ae1c..f768cf2 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -77,7 +77,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine private IConfigSource m_ConfigSource = null; private ICompiler m_Compiler; private int m_MinThreads; - private int m_MaxThreads ; + private int m_MaxThreads; + + /// + /// Amount of time to delay before starting. + /// + private int m_StartDelay; + private int m_IdleTimeout; private int m_StackSize; private int m_SleepTime; @@ -231,6 +237,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60); string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); + m_StartDelay = m_ScriptConfig.GetInt("StartDelay", 15000); m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; @@ -886,7 +893,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine { // This delay exists to stop mono problems where script compilation and startup would stop the sim // working properly for the session. - System.Threading.Thread.Sleep(15000); + System.Threading.Thread.Sleep(m_StartDelay); } object[] o; -- cgit v1.1 From 916e3bf886ee622e2f18d6eb74f90fee8c630471 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Jul 2012 22:54:22 +0100 Subject: Where possible, use the system Encoding.ASCII and Encoding.UTF8 rather than constructing fresh copies. The encodings are thread-safe and already used in such a manner in other places. This isn't done where Byte Order Mark output is suppressed, since Encoding.UTF8 is constructed to output the BOM. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index f768cf2..20fad05 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1763,7 +1763,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine tfs.Read(tdata, 0, tdata.Length); } - assem = new System.Text.ASCIIEncoding().GetString(tdata); + assem = Encoding.ASCII.GetString(tdata); } catch (Exception e) { -- cgit v1.1