* Misc. formatting cleanup for the previous patch

* Added the new AppDomainLoading variable to the [XEngine] section in the example config
0.6.8-post-fixes
John Hurliman 2009-10-29 05:56:37 -07:00
parent 33448e4ba8
commit dd13fa361b
4 changed files with 47 additions and 37 deletions

View File

@ -174,8 +174,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
else else
{ {
#if DEBUG #if DEBUG
// m_log.Debug("[Compiler]: " + // m_log.Debug("[Compiler]: " +
// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); // "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
#endif #endif
// LANGUAGE IS IN ALLOW-LIST // LANGUAGE IS IN ALLOW-LIST
DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage]; DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage];
@ -214,12 +214,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
catch (Exception ex) catch (Exception ex)
{ {
m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath, m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath,
m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString()); m_scriptEngine.World.RegionInfo.RegionID.ToString()) + "\": " + ex.ToString());
} }
} }
foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath, foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath,
m_scriptEngine.World.RegionInfo.RegionID.ToString()),FilePrefix + "_compiled*")) m_scriptEngine.World.RegionInfo.RegionID.ToString()), FilePrefix + "_compiled*"))
{ {
try try
{ {
@ -273,8 +273,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
/// </summary> /// </summary>
/// <param name="Script">LSL script</param> /// <param name="Script">LSL script</param>
/// <returns>Filename to .dll assembly</returns> /// <returns>Filename to .dll assembly</returns>
public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, public void PerformScriptCompile(string Script, string asset, UUID ownerUUID,
out string assembly, out Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>> linemap) out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap)
{ {
linemap = null; linemap = null;
m_warnings.Clear(); m_warnings.Clear();
@ -352,13 +352,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
throw new Exception(errtext); throw new Exception(errtext);
} }
if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false) { if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false)
{
// Not allowed to compile to this language! // Not allowed to compile to this language!
string errtext = String.Empty; string errtext = String.Empty;
errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!"; errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!";
throw new Exception(errtext); throw new Exception(errtext);
} }
string compileScript = Script; string compileScript = Script;
if (language == enumCompileType.lsl) if (language == enumCompileType.lsl)
@ -373,7 +374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
AddWarning(warning); AddWarning(warning);
} }
linemap = ((CSCodeGenerator) LSL_Converter).PositionMap; linemap = ((CSCodeGenerator)LSL_Converter).PositionMap;
// Write the linemap to a file and save it in our dictionary for next time. // Write the linemap to a file and save it in our dictionary for next time.
m_lineMaps[assembly] = linemap; m_lineMaps[assembly] = linemap;
WriteMapFile(assembly + ".map", linemap); WriteMapFile(assembly + ".map", linemap);
@ -487,7 +488,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
} }
catch (Exception e) // NOTLEGIT - Should be just FileIOException catch (Exception e) // NOTLEGIT - Should be just FileIOException
{ {
throw new Exception("Unable to delete old existing "+ throw new Exception("Unable to delete old existing " +
"script-file before writing new. Compile aborted: " + "script-file before writing new. Compile aborted: " +
e.ToString()); e.ToString());
} }
@ -506,7 +507,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
} }
catch (Exception ex) //NOTLEGIT - Should be just FileIOException catch (Exception ex) //NOTLEGIT - Should be just FileIOException
{ {
m_log.Error("[Compiler]: Exception while "+ m_log.Error("[Compiler]: Exception while " +
"trying to write script source to file \"" + "trying to write script source to file \"" +
srcFileName + "\": " + ex.ToString()); srcFileName + "\": " + ex.ToString());
} }
@ -547,7 +548,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
case enumCompileType.cs: case enumCompileType.cs:
case enumCompileType.lsl: case enumCompileType.lsl:
bool complete = false; bool complete = false;
bool retried = false; bool retried = false;
do do
{ {
lock (CScodeProvider) lock (CScodeProvider)
@ -588,7 +589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
parameters, Script); parameters, Script);
break; break;
default: default:
throw new Exception("Compiler is not able to recongnize "+ throw new Exception("Compiler is not able to recongnize " +
"language type \"" + lang.ToString() + "\""); "language type \"" + lang.ToString() + "\"");
} }
@ -641,7 +642,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
if (!File.Exists(assembly)) if (!File.Exists(assembly))
{ {
for (int i=0; i<20 && !File.Exists(assembly); i++) for (int i = 0; i < 20 && !File.Exists(assembly); i++)
{ {
System.Threading.Thread.Sleep(250); System.Threading.Thread.Sleep(250);
} }
@ -654,8 +655,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
} }
} }
// m_log.DebugFormat("[Compiler] Compiled new assembly "+ // m_log.DebugFormat("[Compiler] Compiled new assembly "+
// "for {0}", asset); // "for {0}", asset);
// Because windows likes to perform exclusive locks, we simply // Because windows likes to perform exclusive locks, we simply
// write out a textual representation of the file here // write out a textual representation of the file here
@ -694,17 +695,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
Byte[] buf = enc.GetBytes(filetext); Byte[] buf = enc.GetBytes(filetext);
FileStream sfs = File.Create(assembly+".text"); FileStream sfs = File.Create(assembly + ".text");
sfs.Write(buf, 0, buf.Length); sfs.Write(buf, 0, buf.Length);
sfs.Close(); sfs.Close();
return assembly; return assembly;
} }
private class kvpSorter : IComparer<KeyValuePair<int,int>> private class kvpSorter : IComparer<KeyValuePair<int, int>>
{ {
public int Compare(KeyValuePair<int,int> a, public int Compare(KeyValuePair<int, int> a,
KeyValuePair<int,int> b) KeyValuePair<int, int> b)
{ {
return a.Key.CompareTo(b.Key); return a.Key.CompareTo(b.Key);
} }
@ -723,8 +724,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
out ret)) out ret))
return ret; return ret;
List<KeyValuePair<int,int>> sorted = List<KeyValuePair<int, int>> sorted =
new List<KeyValuePair<int,int>>(positionMap.Keys); new List<KeyValuePair<int, int>>(positionMap.Keys);
sorted.Sort(new kvpSorter()); sorted.Sort(new kvpSorter());
@ -791,18 +792,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
} }
private static Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>> ReadMapFile(string filename) private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> ReadMapFile(string filename)
{ {
Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap;
try try
{ {
StreamReader r = File.OpenText(filename); StreamReader r = File.OpenText(filename);
linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>(); linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>();
string line; string line;
while ((line = r.ReadLine()) != null) while ((line = r.ReadLine()) != null)
{ {
String[] parts = line.Split(new Char[] {','}); String[] parts = line.Split(new Char[] { ',' });
int kk = System.Convert.ToInt32(parts[0]); int kk = System.Convert.ToInt32(parts[0]);
int kv = System.Convert.ToInt32(parts[1]); int kv = System.Convert.ToInt32(parts[1]);
int vk = System.Convert.ToInt32(parts[2]); int vk = System.Convert.ToInt32(parts[2]);

View File

@ -93,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
private StateSource m_stateSource; private StateSource m_stateSource;
private bool m_postOnRez; private bool m_postOnRez;
private bool m_startedFromSavedState = false; private bool m_startedFromSavedState = false;
private int m_CurrentStateHash; private UUID m_CurrentStateHash;
private UUID m_RegionID = UUID.Zero; private UUID m_RegionID = UUID.Zero;
private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
@ -901,7 +901,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
// Compare hash of the state we just just created with the state last written to disk // Compare hash of the state we just just created with the state last written to disk
// If the state is different, update the disk file. // If the state is different, update the disk file.
if(xml.GetHashCode() != m_CurrentStateHash) UUID hash = UUID.Parse(Utils.MD5String(xml));
if(hash != m_CurrentStateHash)
{ {
try try
{ {
@ -919,7 +921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
//{ //{
// throw new Exception("Completed persistence save, but no file was created"); // throw new Exception("Completed persistence save, but no file was created");
//} //}
m_CurrentStateHash = xml.GetHashCode(); m_CurrentStateHash = hash;
} }
} }

View File

@ -710,15 +710,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
evidence, appSetup); evidence, appSetup);
else else
sandbox = AppDomain.CurrentDomain; sandbox = AppDomain.CurrentDomain;
/*
PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
sandboxPolicy.RootCodeGroup = sandboxCodeGroup; //sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
sandbox.SetAppDomainPolicy(sandboxPolicy); //sandbox.SetAppDomainPolicy(sandboxPolicy);
*/
m_AppDomains[appDomain] = sandbox; m_AppDomains[appDomain] = sandbox;
m_AppDomains[appDomain].AssemblyResolve += m_AppDomains[appDomain].AssemblyResolve +=

View File

@ -940,6 +940,13 @@
; Stack size per thread created ; Stack size per thread created
ThreadStackSize = 262144 ThreadStackSize = 262144
; Set this to true (the default) to load each script into a separate
; AppDomain. Setting this to false will load all script assemblies into the
; current AppDomain, which will reduce the per-script overhead at the
; expense of reduced security and the inability to garbage collect the
; script assemblies
AppDomainLoading = true
; Rate to poll for asynchronous command replies (ms) ; Rate to poll for asynchronous command replies (ms)
; currently unused ; currently unused