aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-29 05:56:37 -0700
committerJohn Hurliman2009-10-29 05:56:37 -0700
commitdd13fa361b12fa2fb1c91c9f74379a305935a87d (patch)
treeff4c2e2d4eef64d20d09a3ccfb002b5d23396209 /OpenSim/Region/ScriptEngine
parentOptimizations (diff)
downloadopensim-SC_OLD-dd13fa361b12fa2fb1c91c9f74379a305935a87d.zip
opensim-SC_OLD-dd13fa361b12fa2fb1c91c9f74379a305935a87d.tar.gz
opensim-SC_OLD-dd13fa361b12fa2fb1c91c9f74379a305935a87d.tar.bz2
opensim-SC_OLD-dd13fa361b12fa2fb1c91c9f74379a305935a87d.tar.xz
* Misc. formatting cleanup for the previous patch
* Added the new AppDomainLoading variable to the [XEngine] section in the example config
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs51
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs18
3 files changed, 40 insertions, 37 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index d781a1a..3080c71 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -174,8 +174,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
174 else 174 else
175 { 175 {
176#if DEBUG 176#if DEBUG
177// m_log.Debug("[Compiler]: " + 177 // m_log.Debug("[Compiler]: " +
178// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); 178 // "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
179#endif 179#endif
180 // LANGUAGE IS IN ALLOW-LIST 180 // LANGUAGE IS IN ALLOW-LIST
181 DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage]; 181 DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage];
@@ -214,12 +214,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
214 catch (Exception ex) 214 catch (Exception ex)
215 { 215 {
216 m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath, 216 m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath,
217 m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString()); 217 m_scriptEngine.World.RegionInfo.RegionID.ToString()) + "\": " + ex.ToString());
218 } 218 }
219 } 219 }
220 220
221 foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath, 221 foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath,
222 m_scriptEngine.World.RegionInfo.RegionID.ToString()),FilePrefix + "_compiled*")) 222 m_scriptEngine.World.RegionInfo.RegionID.ToString()), FilePrefix + "_compiled*"))
223 { 223 {
224 try 224 try
225 { 225 {
@@ -273,8 +273,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
273 /// </summary> 273 /// </summary>
274 /// <param name="Script">LSL script</param> 274 /// <param name="Script">LSL script</param>
275 /// <returns>Filename to .dll assembly</returns> 275 /// <returns>Filename to .dll assembly</returns>
276 public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, 276 public void PerformScriptCompile(string Script, string asset, UUID ownerUUID,
277 out string assembly, out Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>> linemap) 277 out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap)
278 { 278 {
279 linemap = null; 279 linemap = null;
280 m_warnings.Clear(); 280 m_warnings.Clear();
@@ -352,13 +352,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
352 throw new Exception(errtext); 352 throw new Exception(errtext);
353 } 353 }
354 354
355 if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false) { 355 if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false)
356 {
356 // Not allowed to compile to this language! 357 // Not allowed to compile to this language!
357 string errtext = String.Empty; 358 string errtext = String.Empty;
358 errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!"; 359 errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!";
359 throw new Exception(errtext); 360 throw new Exception(errtext);
360 } 361 }
361 362
362 string compileScript = Script; 363 string compileScript = Script;
363 364
364 if (language == enumCompileType.lsl) 365 if (language == enumCompileType.lsl)
@@ -373,7 +374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
373 AddWarning(warning); 374 AddWarning(warning);
374 } 375 }
375 376
376 linemap = ((CSCodeGenerator) LSL_Converter).PositionMap; 377 linemap = ((CSCodeGenerator)LSL_Converter).PositionMap;
377 // Write the linemap to a file and save it in our dictionary for next time. 378 // Write the linemap to a file and save it in our dictionary for next time.
378 m_lineMaps[assembly] = linemap; 379 m_lineMaps[assembly] = linemap;
379 WriteMapFile(assembly + ".map", linemap); 380 WriteMapFile(assembly + ".map", linemap);
@@ -487,7 +488,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
487 } 488 }
488 catch (Exception e) // NOTLEGIT - Should be just FileIOException 489 catch (Exception e) // NOTLEGIT - Should be just FileIOException
489 { 490 {
490 throw new Exception("Unable to delete old existing "+ 491 throw new Exception("Unable to delete old existing " +
491 "script-file before writing new. Compile aborted: " + 492 "script-file before writing new. Compile aborted: " +
492 e.ToString()); 493 e.ToString());
493 } 494 }
@@ -506,7 +507,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
506 } 507 }
507 catch (Exception ex) //NOTLEGIT - Should be just FileIOException 508 catch (Exception ex) //NOTLEGIT - Should be just FileIOException
508 { 509 {
509 m_log.Error("[Compiler]: Exception while "+ 510 m_log.Error("[Compiler]: Exception while " +
510 "trying to write script source to file \"" + 511 "trying to write script source to file \"" +
511 srcFileName + "\": " + ex.ToString()); 512 srcFileName + "\": " + ex.ToString());
512 } 513 }
@@ -547,7 +548,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
547 case enumCompileType.cs: 548 case enumCompileType.cs:
548 case enumCompileType.lsl: 549 case enumCompileType.lsl:
549 bool complete = false; 550 bool complete = false;
550 bool retried = false; 551 bool retried = false;
551 do 552 do
552 { 553 {
553 lock (CScodeProvider) 554 lock (CScodeProvider)
@@ -588,7 +589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
588 parameters, Script); 589 parameters, Script);
589 break; 590 break;
590 default: 591 default:
591 throw new Exception("Compiler is not able to recongnize "+ 592 throw new Exception("Compiler is not able to recongnize " +
592 "language type \"" + lang.ToString() + "\""); 593 "language type \"" + lang.ToString() + "\"");
593 } 594 }
594 595
@@ -641,7 +642,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
641 642
642 if (!File.Exists(assembly)) 643 if (!File.Exists(assembly))
643 { 644 {
644 for (int i=0; i<20 && !File.Exists(assembly); i++) 645 for (int i = 0; i < 20 && !File.Exists(assembly); i++)
645 { 646 {
646 System.Threading.Thread.Sleep(250); 647 System.Threading.Thread.Sleep(250);
647 } 648 }
@@ -654,8 +655,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
654 } 655 }
655 } 656 }
656 657
657// m_log.DebugFormat("[Compiler] Compiled new assembly "+ 658 // m_log.DebugFormat("[Compiler] Compiled new assembly "+
658// "for {0}", asset); 659 // "for {0}", asset);
659 660
660 // Because windows likes to perform exclusive locks, we simply 661 // Because windows likes to perform exclusive locks, we simply
661 // write out a textual representation of the file here 662 // write out a textual representation of the file here
@@ -694,17 +695,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
694 695
695 Byte[] buf = enc.GetBytes(filetext); 696 Byte[] buf = enc.GetBytes(filetext);
696 697
697 FileStream sfs = File.Create(assembly+".text"); 698 FileStream sfs = File.Create(assembly + ".text");
698 sfs.Write(buf, 0, buf.Length); 699 sfs.Write(buf, 0, buf.Length);
699 sfs.Close(); 700 sfs.Close();
700 701
701 return assembly; 702 return assembly;
702 } 703 }
703 704
704 private class kvpSorter : IComparer<KeyValuePair<int,int>> 705 private class kvpSorter : IComparer<KeyValuePair<int, int>>
705 { 706 {
706 public int Compare(KeyValuePair<int,int> a, 707 public int Compare(KeyValuePair<int, int> a,
707 KeyValuePair<int,int> b) 708 KeyValuePair<int, int> b)
708 { 709 {
709 return a.Key.CompareTo(b.Key); 710 return a.Key.CompareTo(b.Key);
710 } 711 }
@@ -723,8 +724,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
723 out ret)) 724 out ret))
724 return ret; 725 return ret;
725 726
726 List<KeyValuePair<int,int>> sorted = 727 List<KeyValuePair<int, int>> sorted =
727 new List<KeyValuePair<int,int>>(positionMap.Keys); 728 new List<KeyValuePair<int, int>>(positionMap.Keys);
728 729
729 sorted.Sort(new kvpSorter()); 730 sorted.Sort(new kvpSorter());
730 731
@@ -791,18 +792,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
791 } 792 }
792 793
793 794
794 private static Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>> ReadMapFile(string filename) 795 private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> ReadMapFile(string filename)
795 { 796 {
796 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; 797 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap;
797 try 798 try
798 { 799 {
799 StreamReader r = File.OpenText(filename); 800 StreamReader r = File.OpenText(filename);
800 linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>(); 801 linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>();
801 802
802 string line; 803 string line;
803 while ((line = r.ReadLine()) != null) 804 while ((line = r.ReadLine()) != null)
804 { 805 {
805 String[] parts = line.Split(new Char[] {','}); 806 String[] parts = line.Split(new Char[] { ',' });
806 int kk = System.Convert.ToInt32(parts[0]); 807 int kk = System.Convert.ToInt32(parts[0]);
807 int kv = System.Convert.ToInt32(parts[1]); 808 int kv = System.Convert.ToInt32(parts[1]);
808 int vk = System.Convert.ToInt32(parts[2]); 809 int vk = System.Convert.ToInt32(parts[2]);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 37ec5df..f16aefc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
93 private StateSource m_stateSource; 93 private StateSource m_stateSource;
94 private bool m_postOnRez; 94 private bool m_postOnRez;
95 private bool m_startedFromSavedState = false; 95 private bool m_startedFromSavedState = false;
96 private int m_CurrentStateHash; 96 private UUID m_CurrentStateHash;
97 private UUID m_RegionID = UUID.Zero; 97 private UUID m_RegionID = UUID.Zero;
98 98
99 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> 99 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
@@ -901,7 +901,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
901 901
902 // Compare hash of the state we just just created with the state last written to disk 902 // Compare hash of the state we just just created with the state last written to disk
903 // If the state is different, update the disk file. 903 // If the state is different, update the disk file.
904 if(xml.GetHashCode() != m_CurrentStateHash) 904 UUID hash = UUID.Parse(Utils.MD5String(xml));
905
906 if(hash != m_CurrentStateHash)
905 { 907 {
906 try 908 try
907 { 909 {
@@ -919,7 +921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
919 //{ 921 //{
920 // throw new Exception("Completed persistence save, but no file was created"); 922 // throw new Exception("Completed persistence save, but no file was created");
921 //} 923 //}
922 m_CurrentStateHash = xml.GetHashCode(); 924 m_CurrentStateHash = hash;
923 } 925 }
924 } 926 }
925 927
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 57042e9..b13e0de 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -710,15 +710,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
710 evidence, appSetup); 710 evidence, appSetup);
711 else 711 else
712 sandbox = AppDomain.CurrentDomain; 712 sandbox = AppDomain.CurrentDomain;
713 /* 713
714 PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); 714 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
715 AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); 715 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
716 PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); 716 //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
717 PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); 717 //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
718 CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); 718 //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
719 sandboxPolicy.RootCodeGroup = sandboxCodeGroup; 719 //sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
720 sandbox.SetAppDomainPolicy(sandboxPolicy); 720 //sandbox.SetAppDomainPolicy(sandboxPolicy);
721 */ 721
722 m_AppDomains[appDomain] = sandbox; 722 m_AppDomains[appDomain] = sandbox;
723 723
724 m_AppDomains[appDomain].AssemblyResolve += 724 m_AppDomains[appDomain].AssemblyResolve +=