aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Util.cs86
1 files changed, 43 insertions, 43 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 89cf045..6d679f2 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Framework
59{ 59{
60 [Flags] 60 [Flags]
61 public enum PermissionMask : uint 61 public enum PermissionMask : uint
62 { 62 {
63 None = 0, 63 None = 0,
64 64
65 // folded perms 65 // folded perms
@@ -112,7 +112,7 @@ namespace OpenSim.Framework
112 public STPStartInfo STPStartInfo { get; set; } 112 public STPStartInfo STPStartInfo { get; set; }
113 public WIGStartInfo WIGStartInfo { get; set; } 113 public WIGStartInfo WIGStartInfo { get; set; }
114 public bool IsIdle { get; set; } 114 public bool IsIdle { get; set; }
115 public bool IsShuttingDown { get; set; } 115 public bool IsShuttingDown { get; set; }
116 public int MaxThreads { get; set; } 116 public int MaxThreads { get; set; }
117 public int MinThreads { get; set; } 117 public int MinThreads { get; set; }
118 public int InUseThreads { get; set; } 118 public int InUseThreads { get; set; }
@@ -230,7 +230,7 @@ namespace OpenSim.Framework
230 public static Encoding UTF8NoBomEncoding = new UTF8Encoding(false); 230 public static Encoding UTF8NoBomEncoding = new UTF8Encoding(false);
231 231
232 /// <value> 232 /// <value>
233 /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) 233 /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards)
234 /// </value> 234 /// </value>
235 public static UUID BLANK_TEXTURE_UUID = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); 235 public static UUID BLANK_TEXTURE_UUID = new UUID("5748decc-f629-461c-9a36-a35a221fe21f");
236 236
@@ -280,7 +280,7 @@ namespace OpenSim.Framework
280 /// </summary> 280 /// </summary>
281 /// <param name="a">A 3d vector</param> 281 /// <param name="a">A 3d vector</param>
282 /// <returns>A new vector which is normalized form of the vector</returns> 282 /// <returns>A new vector which is normalized form of the vector</returns>
283 283
284 public static Vector3 GetNormalizedVector(Vector3 a) 284 public static Vector3 GetNormalizedVector(Vector3 a)
285 { 285 {
286 Vector3 v = new Vector3(a.X, a.Y, a.Z); 286 Vector3 v = new Vector3(a.X, a.Y, a.Z);
@@ -371,7 +371,7 @@ namespace OpenSim.Framework
371 // Regions are identified with a 'handle' made up of its world coordinates packed into a ulong. 371 // Regions are identified with a 'handle' made up of its world coordinates packed into a ulong.
372 // Region handles are based on the coordinate of the region corner with lower X and Y 372 // Region handles are based on the coordinate of the region corner with lower X and Y
373 // var regions need more work than this to get that right corner from a generic world position 373 // var regions need more work than this to get that right corner from a generic world position
374 // this corner must be on a grid point 374 // this corner must be on a grid point
375 public static ulong RegionWorldLocToHandle(uint X, uint Y) 375 public static ulong RegionWorldLocToHandle(uint X, uint Y)
376 { 376 {
377 ulong handle = X & 0xffffff00; // make sure it matchs grid coord points. 377 ulong handle = X & 0xffffff00; // make sure it matchs grid coord points.
@@ -450,7 +450,7 @@ namespace OpenSim.Framework
450 450
451 string host; 451 string host;
452 uint port = 80; 452 uint port = 80;
453 453
454 string[] parts = inputName.Split(new char[] { ':' }); 454 string[] parts = inputName.Split(new char[] { ':' });
455 int indx; 455 int indx;
456 if(parts.Length == 0) 456 if(parts.Length == 0)
@@ -470,7 +470,7 @@ namespace OpenSim.Framework
470 else 470 else
471 { 471 {
472 host = parts[0]; 472 host = parts[0];
473 473
474 if (parts.Length >= 2) 474 if (parts.Length >= 2)
475 { 475 {
476 indx = parts[1].IndexOf('/'); 476 indx = parts[1].IndexOf('/');
@@ -875,8 +875,8 @@ namespace OpenSim.Framework
875 /// <param name="newx">New region x-coord</param> 875 /// <param name="newx">New region x-coord</param>
876 /// <param name="oldy">Old region y-coord</param> 876 /// <param name="oldy">Old region y-coord</param>
877 /// <param name="newy">New region y-coord</param> 877 /// <param name="newy">New region y-coord</param>
878 /// <returns></returns> 878 /// <returns></returns>
879 public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy, 879 public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy,
880 int oldsizex, int oldsizey, int newsizex, int newsizey) 880 int oldsizex, int oldsizey, int newsizex, int newsizey)
881 { 881 {
882 // we still need to make sure we see new region 1stNeighbors 882 // we still need to make sure we see new region 1stNeighbors
@@ -1267,7 +1267,7 @@ namespace OpenSim.Framework
1267 1267
1268 /// <summary> 1268 /// <summary>
1269 /// Gets the value of a configuration variable by looking into 1269 /// Gets the value of a configuration variable by looking into
1270 /// multiple sections in order. The latter sections overwrite 1270 /// multiple sections in order. The latter sections overwrite
1271 /// any values previously found. 1271 /// any values previously found.
1272 /// </summary> 1272 /// </summary>
1273 /// <typeparam name="T">Type of the variable</typeparam> 1273 /// <typeparam name="T">Type of the variable</typeparam>
@@ -1282,7 +1282,7 @@ namespace OpenSim.Framework
1282 1282
1283 /// <summary> 1283 /// <summary>
1284 /// Gets the value of a configuration variable by looking into 1284 /// Gets the value of a configuration variable by looking into
1285 /// multiple sections in order. The latter sections overwrite 1285 /// multiple sections in order. The latter sections overwrite
1286 /// any values previously found. 1286 /// any values previously found.
1287 /// </summary> 1287 /// </summary>
1288 /// <remarks> 1288 /// <remarks>
@@ -1338,7 +1338,7 @@ namespace OpenSim.Framework
1338 ConfigSource.ExpandKeyValues(); 1338 ConfigSource.ExpandKeyValues();
1339 } 1339 }
1340 } 1340 }
1341 1341
1342 public static T ReadSettingsFromIniFile<T>(IConfig config, T settingsClass) 1342 public static T ReadSettingsFromIniFile<T>(IConfig config, T settingsClass)
1343 { 1343 {
1344 Type settingsType = settingsClass.GetType(); 1344 Type settingsType = settingsClass.GetType();
@@ -1449,7 +1449,7 @@ namespace OpenSim.Framework
1449 1449
1450 if (File.Exists(configFile)) 1450 if (File.Exists(configFile))
1451 { 1451 {
1452 // Merge 1452 // Merge
1453 config.Merge(new IniConfigSource(configFile)); 1453 config.Merge(new IniConfigSource(configFile));
1454 config.ExpandKeyValues(); 1454 config.ExpandKeyValues();
1455 configFilePath = configFile; 1455 configFilePath = configFile;
@@ -1598,7 +1598,7 @@ namespace OpenSim.Framework
1598 } 1598 }
1599 1599
1600 memory.Position = 0; 1600 memory.Position = 0;
1601 1601
1602 byte[] compressed = new byte[memory.Length]; 1602 byte[] compressed = new byte[memory.Length];
1603 memory.Read(compressed, 0, compressed.Length); 1603 memory.Read(compressed, 0, compressed.Length);
1604 1604
@@ -1645,7 +1645,7 @@ namespace OpenSim.Framework
1645 const int readSize = 256; 1645 const int readSize = 256;
1646 byte[] buffer = new byte[readSize]; 1646 byte[] buffer = new byte[readSize];
1647 MemoryStream ms = new MemoryStream(); 1647 MemoryStream ms = new MemoryStream();
1648 1648
1649 int count = inputStream.Read(buffer, 0, readSize); 1649 int count = inputStream.Read(buffer, 0, readSize);
1650 1650
1651 while (count > 0) 1651 while (count > 0)
@@ -1731,10 +1731,10 @@ namespace OpenSim.Framework
1731 regionHandle = Utils.BytesToUInt64(bytes); 1731 regionHandle = Utils.BytesToUInt64(bytes);
1732 x = Utils.BytesToUInt(bytes, 8) & 0xffff; 1732 x = Utils.BytesToUInt(bytes, 8) & 0xffff;
1733 y = Utils.BytesToUInt(bytes, 12) & 0xffff; 1733 y = Utils.BytesToUInt(bytes, 12) & 0xffff;
1734 // validation may fail, just reducing the odds of using a real UUID as encoded parcel 1734 // validation may fail, just reducing the odds of using a real UUID as encoded parcel
1735 return ( bytes[0] == 0 && bytes[4] == 0 && // handler x,y multiples of 256 1735 return ( bytes[0] == 0 && bytes[4] == 0 && // handler x,y multiples of 256
1736 bytes[9] < 64 && bytes[13] < 64 && // positions < 16km 1736 bytes[9] < 64 && bytes[13] < 64 && // positions < 16km
1737 bytes[14] == 0 && bytes[15] == 0); 1737 bytes[14] == 0 && bytes[15] == 0);
1738 } 1738 }
1739 1739
1740 public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y, out uint z) 1740 public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y, out uint z)
@@ -1757,7 +1757,7 @@ namespace OpenSim.Framework
1757 x += rx; 1757 x += rx;
1758 y += ry; 1758 y += ry;
1759 } 1759 }
1760 1760
1761 /// <summary> 1761 /// <summary>
1762 /// Get operating system information if available. Returns only the first 45 characters of information 1762 /// Get operating system information if available. Returns only the first 45 characters of information
1763 /// </summary> 1763 /// </summary>
@@ -1776,12 +1776,12 @@ namespace OpenSim.Framework
1776// { 1776// {
1777// os = ReadEtcIssue(); 1777// os = ReadEtcIssue();
1778// } 1778// }
1779// 1779//
1780// if (os.Length > 45) 1780// if (os.Length > 45)
1781// { 1781// {
1782// os = os.Substring(0, 45); 1782// os = os.Substring(0, 45);
1783// } 1783// }
1784 1784
1785 return os; 1785 return os;
1786 } 1786 }
1787 1787
@@ -1993,7 +1993,7 @@ namespace OpenSim.Framework
1993 vol = vcomps[0]; 1993 vol = vcomps[0];
1994 } 1994 }
1995 } 1995 }
1996 1996
1997 string[] comps = path.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries); 1997 string[] comps = path.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries);
1998 1998
1999 // Glob 1999 // Glob
@@ -2095,7 +2095,7 @@ namespace OpenSim.Framework
2095 2095
2096 if (!str.EndsWith("\0")) 2096 if (!str.EndsWith("\0"))
2097 str += "\0"; 2097 str += "\0";
2098 2098
2099 // Because this is UTF-8 encoding and not ASCII, it's possible we 2099 // Because this is UTF-8 encoding and not ASCII, it's possible we
2100 // might have gotten an oversized array even after the string trim 2100 // might have gotten an oversized array even after the string trim
2101 byte[] data = UTF8.GetBytes(str); 2101 byte[] data = UTF8.GetBytes(str);
@@ -2354,7 +2354,7 @@ namespace OpenSim.Framework
2354 throw new NotImplementedException(); 2354 throw new NotImplementedException();
2355 } 2355 }
2356 } 2356 }
2357 2357
2358 /// <summary> 2358 /// <summary>
2359 /// Additional information about threads in the main thread pool. Used to time how long the 2359 /// Additional information about threads in the main thread pool. Used to time how long the
2360 /// thread has been running, and abort it if it has timed-out. 2360 /// thread has been running, and abort it if it has timed-out.
@@ -2365,7 +2365,7 @@ namespace OpenSim.Framework
2365 public string StackTrace { get; set; } 2365 public string StackTrace { get; set; }
2366 private string context; 2366 private string context;
2367 public bool LogThread { get; set; } 2367 public bool LogThread { get; set; }
2368 2368
2369 public IWorkItemResult WorkItem { get; set; } 2369 public IWorkItemResult WorkItem { get; set; }
2370 public Thread Thread { get; set; } 2370 public Thread Thread { get; set; }
2371 public bool Running { get; set; } 2371 public bool Running { get; set; }
@@ -2470,7 +2470,7 @@ namespace OpenSim.Framework
2470 public static Dictionary<string, int> GetFireAndForgetCallsMade() 2470 public static Dictionary<string, int> GetFireAndForgetCallsMade()
2471 { 2471 {
2472 return new Dictionary<string, int>(m_fireAndForgetCallsMade); 2472 return new Dictionary<string, int>(m_fireAndForgetCallsMade);
2473 } 2473 }
2474 2474
2475 private static Dictionary<string, int> m_fireAndForgetCallsMade = new Dictionary<string, int>(); 2475 private static Dictionary<string, int> m_fireAndForgetCallsMade = new Dictionary<string, int>();
2476 2476
@@ -2490,7 +2490,7 @@ namespace OpenSim.Framework
2490 { 2490 {
2491 FireAndForget(callback, obj, null); 2491 FireAndForget(callback, obj, null);
2492 } 2492 }
2493 2493
2494 public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context) 2494 public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context)
2495 { 2495 {
2496 Interlocked.Increment(ref numTotalThreadFuncsCalled); 2496 Interlocked.Increment(ref numTotalThreadFuncsCalled);
@@ -2511,19 +2511,19 @@ namespace OpenSim.Framework
2511 WaitCallback realCallback; 2511 WaitCallback realCallback;
2512 2512
2513 bool loggingEnabled = LogThreadPool > 0; 2513 bool loggingEnabled = LogThreadPool > 0;
2514 2514
2515 long threadFuncNum = Interlocked.Increment(ref nextThreadFuncNum); 2515 long threadFuncNum = Interlocked.Increment(ref nextThreadFuncNum);
2516 ThreadInfo threadInfo = new ThreadInfo(threadFuncNum, context); 2516 ThreadInfo threadInfo = new ThreadInfo(threadFuncNum, context);
2517 2517
2518 if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest) 2518 if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
2519 { 2519 {
2520 // If we're running regression tests, then we want any exceptions to rise up to the test code. 2520 // If we're running regression tests, then we want any exceptions to rise up to the test code.
2521 realCallback = 2521 realCallback =
2522 o => 2522 o =>
2523 { 2523 {
2524 Culture.SetCurrentCulture(); 2524 Culture.SetCurrentCulture();
2525 callback(o); 2525 callback(o);
2526 2526
2527 if (context != null) 2527 if (context != null)
2528 m_fireAndForgetCallsInProgress[context]--; 2528 m_fireAndForgetCallsInProgress[context]--;
2529 }; 2529 };
@@ -2666,7 +2666,7 @@ namespace OpenSim.Framework
2666 if (stackTrace.Contains("BeginFireQueueEmpty")) 2666 if (stackTrace.Contains("BeginFireQueueEmpty"))
2667 return false; 2667 return false;
2668 } 2668 }
2669 2669
2670 return true; 2670 return true;
2671 } 2671 }
2672 2672
@@ -2679,7 +2679,7 @@ namespace OpenSim.Framework
2679 { 2679 {
2680 string src = Environment.StackTrace; 2680 string src = Environment.StackTrace;
2681 string[] lines = src.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); 2681 string[] lines = src.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
2682 2682
2683 StringBuilder dest = new StringBuilder(src.Length); 2683 StringBuilder dest = new StringBuilder(src.Length);
2684 2684
2685 bool started = false; 2685 bool started = false;
@@ -2724,11 +2724,11 @@ namespace OpenSim.Framework
2724 /// trace. And pausing another thread can cause a deadlock. This method attempts to 2724 /// trace. And pausing another thread can cause a deadlock. This method attempts to
2725 /// avoid deadlock by using a short timeout (200ms), after which it gives up and 2725 /// avoid deadlock by using a short timeout (200ms), after which it gives up and
2726 /// returns 'null' instead of the stack trace. 2726 /// returns 'null' instead of the stack trace.
2727 /// 2727 ///
2728 /// Take from: http://stackoverflow.com/a/14935378 2728 /// Take from: http://stackoverflow.com/a/14935378
2729 /// 2729 ///
2730 /// WARNING: this doesn't work in Mono. See https://bugzilla.novell.com/show_bug.cgi?id=571691 2730 /// WARNING: this doesn't work in Mono. See https://bugzilla.novell.com/show_bug.cgi?id=571691
2731 /// 2731 ///
2732 /// </remarks> 2732 /// </remarks>
2733 /// <returns>The stack trace, or null if failed to get it</returns> 2733 /// <returns>The stack trace, or null if failed to get it</returns>
2734 private static StackTrace GetStackTrace(Thread targetThread) 2734 private static StackTrace GetStackTrace(Thread targetThread)
@@ -2829,7 +2829,7 @@ namespace OpenSim.Framework
2829 /// <summary> 2829 /// <summary>
2830 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive 2830 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
2831 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap 2831 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap
2832 /// for the callers. 2832 /// for the callers.
2833 /// This trims it to a 12 day interval so don't let your frame time get too long. 2833 /// This trims it to a 12 day interval so don't let your frame time get too long.
2834 /// </summary> 2834 /// </summary>
2835 /// <returns></returns> 2835 /// <returns></returns>
@@ -3186,7 +3186,7 @@ namespace OpenSim.Framework
3186 if (parts.Length == 2) 3186 if (parts.Length == 2)
3187 return CalcUniversalIdentifier(id, agentsURI, parts[0] + " " + parts[1]); 3187 return CalcUniversalIdentifier(id, agentsURI, parts[0] + " " + parts[1]);
3188 } 3188 }
3189 3189
3190 return CalcUniversalIdentifier(id, agentsURI, firstName + " " + lastName); 3190 return CalcUniversalIdentifier(id, agentsURI, firstName + " " + lastName);
3191 } 3191 }
3192 3192
@@ -3286,10 +3286,10 @@ namespace OpenSim.Framework
3286 3286
3287 public virtual int Count 3287 public virtual int Count
3288 { 3288 {
3289 get 3289 get
3290 { 3290 {
3291 lock (m_syncRoot) 3291 lock (m_syncRoot)
3292 return m_highQueue.Count + m_lowQueue.Count; 3292 return m_highQueue.Count + m_lowQueue.Count;
3293 } 3293 }
3294 } 3294 }
3295 3295