aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs40
-rw-r--r--OpenSim/Framework/Util.cs10
2 files changed, 42 insertions, 8 deletions
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
index 1254086..55640ac 100644
--- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
+++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics;
30using System.IO; 31using System.IO;
31using System.Reflection; 32using System.Reflection;
32using System.Xml; 33using System.Xml;
@@ -47,7 +48,7 @@ namespace OpenSim.Framework.Serialization.External
47 /// Populate a node with data read from xml using a dictinoary of processors 48 /// Populate a node with data read from xml using a dictinoary of processors
48 /// </summary> 49 /// </summary>
49 /// <param name="nodeToFill"></param> 50 /// <param name="nodeToFill"></param>
50 /// <param name="processors">/param> 51 /// <param name="processors"></param>
51 /// <param name="xtr"></param> 52 /// <param name="xtr"></param>
52 /// <returns>true on successful, false if there were any processing failures</returns> 53 /// <returns>true on successful, false if there were any processing failures</returns>
53 public static bool ExecuteReadProcessors<NodeType>( 54 public static bool ExecuteReadProcessors<NodeType>(
@@ -57,10 +58,10 @@ namespace OpenSim.Framework.Serialization.External
57 nodeToFill, 58 nodeToFill,
58 processors, 59 processors,
59 xtr, 60 xtr,
60 (o, name, e) 61 (o, nodeName, e) => {
61 => m_log.DebugFormat( 62 m_log.Debug(string.Format("[ExternalRepresentationUtils]: Error while parsing element {0} ",
62 "[ExternalRepresentationUtils]: Exception while parsing element {0}, continuing. Exception {1}{2}", 63 nodeName), e);
63 name, e.Message, e.StackTrace)); 64 });
64 } 65 }
65 66
66 /// <summary> 67 /// <summary>
@@ -80,18 +81,22 @@ namespace OpenSim.Framework.Serialization.External
80 Action<NodeType, string, Exception> parseExceptionAction) 81 Action<NodeType, string, Exception> parseExceptionAction)
81 { 82 {
82 bool errors = false; 83 bool errors = false;
84 int numErrors = 0;
85
86 Stopwatch timer = new Stopwatch();
87 timer.Start();
83 88
84 string nodeName = string.Empty; 89 string nodeName = string.Empty;
85 while (xtr.NodeType != XmlNodeType.EndElement) 90 while (xtr.NodeType != XmlNodeType.EndElement)
86 { 91 {
87 nodeName = xtr.Name; 92 nodeName = xtr.Name;
88 93
89// m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); 94 // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing node: {0}", nodeName);
90 95
91 Action<NodeType, XmlReader> p = null; 96 Action<NodeType, XmlReader> p = null;
92 if (processors.TryGetValue(xtr.Name, out p)) 97 if (processors.TryGetValue(xtr.Name, out p))
93 { 98 {
94// m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); 99 // m_log.DebugFormat("[ExternalRepresentationUtils]: Found processor for {0}", nodeName);
95 100
96 try 101 try
97 { 102 {
@@ -101,6 +106,18 @@ namespace OpenSim.Framework.Serialization.External
101 { 106 {
102 errors = true; 107 errors = true;
103 parseExceptionAction(nodeToFill, nodeName, e); 108 parseExceptionAction(nodeToFill, nodeName, e);
109
110 if (xtr.EOF)
111 {
112 m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to unexpected end of XML");
113 break;
114 }
115
116 if (++numErrors == 10)
117 {
118 m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to too many parsing errors");
119 break;
120 }
104 121
105 if (xtr.NodeType == XmlNodeType.EndElement) 122 if (xtr.NodeType == XmlNodeType.EndElement)
106 xtr.Read(); 123 xtr.Read();
@@ -108,9 +125,16 @@ namespace OpenSim.Framework.Serialization.External
108 } 125 }
109 else 126 else
110 { 127 {
111 // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); 128 // m_log.DebugFormat("[ExternalRepresentationUtils]: found unknown element \"{0}\"", nodeName);
112 xtr.ReadOuterXml(); // ignore 129 xtr.ReadOuterXml(); // ignore
113 } 130 }
131
132 if (timer.Elapsed.TotalSeconds >= 60)
133 {
134 m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to timeout");
135 errors = true;
136 break;
137 }
114 } 138 }
115 139
116 return errors; 140 return errors;
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 875f4ad..a5f798d 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -2910,6 +2910,16 @@ namespace OpenSim.Framework
2910 2910
2911 return name; 2911 return name;
2912 } 2912 }
2913
2914 public static void LogFailedXML(string message, string xml)
2915 {
2916 int length = xml.Length;
2917 if (length > 2000)
2918 xml = xml.Substring(0, 2000) + "...";
2919
2920 m_log.ErrorFormat("{0} Failed XML ({1} bytes) = {2}", message, length, xml);
2921 }
2922
2913 } 2923 }
2914 2924
2915 public class DoubleQueue<T> where T:class 2925 public class DoubleQueue<T> where T:class