aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs47
1 files changed, 46 insertions, 1 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 13a4b3f..c39fb6f 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Data; 31using System.Data;
32using System.Diagnostics;
32using System.Globalization; 33using System.Globalization;
33using System.IO; 34using System.IO;
34using System.IO.Compression; 35using System.IO.Compression;
@@ -553,7 +554,7 @@ namespace OpenSim.Framework
553 } 554 }
554 catch (Exception e) 555 catch (Exception e)
555 { 556 {
556 m_log.ErrorFormat("[UTIL]: An error occurred while resolving {0}, {1}", dnsAddress, e); 557 m_log.WarnFormat("[UTIL]: An error occurred while resolving host name {0}, {1}", dnsAddress, e);
557 558
558 // Still going to throw the exception on for now, since this was what was happening in the first place 559 // Still going to throw the exception on for now, since this was what was happening in the first place
559 throw e; 560 throw e;
@@ -1192,6 +1193,33 @@ namespace OpenSim.Framework
1192 return null; 1193 return null;
1193 } 1194 }
1194 1195
1196 public static OSDMap GetOSDMap(string data)
1197 {
1198 OSDMap args = null;
1199 try
1200 {
1201 OSD buffer;
1202 // We should pay attention to the content-type, but let's assume we know it's Json
1203 buffer = OSDParser.DeserializeJson(data);
1204 if (buffer.Type == OSDType.Map)
1205 {
1206 args = (OSDMap)buffer;
1207 return args;
1208 }
1209 else
1210 {
1211 // uh?
1212 m_log.Debug(("[UTILS]: Got OSD of unexpected type " + buffer.Type.ToString()));
1213 return null;
1214 }
1215 }
1216 catch (Exception ex)
1217 {
1218 m_log.Debug("[UTILS]: exception on GetOSDMap " + ex.Message);
1219 return null;
1220 }
1221 }
1222
1195 public static string[] Glob(string path) 1223 public static string[] Glob(string path)
1196 { 1224 {
1197 string vol=String.Empty; 1225 string vol=String.Empty;
@@ -1416,6 +1444,7 @@ namespace OpenSim.Framework
1416 } 1444 }
1417 1445
1418 #endregion FireAndForget Threading Pattern 1446 #endregion FireAndForget Threading Pattern
1447
1419 /// <summary> 1448 /// <summary>
1420 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive 1449 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
1421 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap 1450 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap
@@ -1440,5 +1469,21 @@ namespace OpenSim.Framework
1440 Int32 diff = EnvironmentTickCount() - prevValue; 1469 Int32 diff = EnvironmentTickCount() - prevValue;
1441 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1); 1470 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1);
1442 } 1471 }
1472
1473 /// <summary>
1474 /// Prints the call stack at any given point. Useful for debugging.
1475 /// </summary>
1476 public static void PrintCallStack()
1477 {
1478 StackTrace stackTrace = new StackTrace(); // get call stack
1479 StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)
1480
1481 // write call stack method names
1482 foreach (StackFrame stackFrame in stackFrames)
1483 {
1484 m_log.Debug(stackFrame.GetMethod().DeclaringType + "." + stackFrame.GetMethod().Name); // write method name
1485 }
1486 }
1487
1443 } 1488 }
1444} \ No newline at end of file 1489} \ No newline at end of file