* Added additional debug testing info to Scene

* Corrected issue with MRMs where it would attempt to overwrite an already loaded DLL. (and thus fail with cryptic UnauthorizedAccessException.)
* Made DrunkenTextAppreciationModule.cs MRM not crash with StackOverflowException
* Added some temporary logging to MRM World.*
This commit is contained in:
Adam Frisby
2009-04-09 13:03:27 +00:00
parent 0af0399198
commit 03984e7304
4 changed files with 57 additions and 6 deletions

View File

@@ -91,8 +91,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
m_log.Info("[MRM] Starting MRM");
mmb.Start();
}
catch (UnauthorizedAccessException e)
{
m_log.Error("[MRM] UAE " + e.Message);
m_log.Error("[MRM] " + e.StackTrace);
if (e.InnerException != null)
m_log.Error("[MRM] " + e.InnerException);
m_scene.Broadcast(delegate(IClientAPI user)
{
user.SendAlertMessage(
"MRM UnAuthorizedAccess: " + e);
});
}
catch (Exception e)
{
m_log.Info("[MRM] Error: " + e);
m_scene.Broadcast(delegate(IClientAPI user)
{
user.SendAlertMessage(
@@ -133,13 +148,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
/// <returns></returns>
internal string CompileFromDotNetText(string Script, string uuid)
{
m_log.Info("MRM 1");
const string ext = ".cs";
const string FilePrefix = "MiniModule";
// Output assembly name
string OutFile = Path.Combine("MiniModules", Path.Combine(
m_scene.RegionInfo.RegionID.ToString(),
FilePrefix + "_compiled_" + uuid + ".dll"));
FilePrefix + "_compiled_" + uuid + "_" +
Util.RandomClass.Next(9000) + ".dll"));
// Create Directories for Assemblies
if (!Directory.Exists("MiniModules"))
@@ -148,10 +165,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
if (!Directory.Exists(tmp))
Directory.CreateDirectory(tmp);
m_log.Info("MRM 2");
try
{
File.Delete(OutFile);
}
catch (UnauthorizedAccessException e)
{
throw new Exception("Unable to delete old existing " +
"script-file before writing new. Compile aborted: " +
e);
}
catch (IOException e)
{
throw new Exception("Unable to delete old existing " +
@@ -159,6 +185,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
e);
}
m_log.Info("MRM 3");
// DEBUG - write source to disk
string srcFileName = FilePrefix + "_source_" +
Path.GetFileNameWithoutExtension(OutFile) + ext;
@@ -176,6 +204,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
srcFileName + "\": " + ex.ToString());
}
m_log.Info("MRM 4");
// Do actual compile
CompilerParameters parameters = new CompilerParameters();
@@ -196,9 +226,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
parameters.IncludeDebugInformation = true;
parameters.TreatWarningsAsErrors = false;
m_log.Info("MRM 5");
CompilerResults results = CScodeProvider.CompileAssemblyFromSource(
parameters, Script);
m_log.Info("MRM 6");
int display = 5;
if (results.Errors.Count > 0)
{
@@ -232,6 +266,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
}
}
m_log.Info("MRM 7");
if (!File.Exists(OutFile))
{
string errtext = String.Empty;
@@ -256,6 +292,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
throw new Exception(errtext);
}
m_log.Info("MRM 8");
// Convert to base64
//
string filetext = Convert.ToBase64String(data);
@@ -264,10 +302,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Byte[] buf = enc.GetBytes(filetext);
m_log.Info("MRM 9");
FileStream sfs = File.Create(OutFile + ".cil.b64");
sfs.Write(buf, 0, buf.Length);
sfs.Close();
m_log.Info("MRM 10");
return OutFile;
}
}