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')
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')
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')
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')
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')
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