Add additional instrumentation so that when there is an xmlrpc call failure, the actual xml that was returned from the groups service can be logged.

remotes/origin/0.6.7-post-fixes
Michael Cortez 2009-08-20 09:41:14 -07:00 committed by Justin Clark-Casey (justincc)
parent 841cd69af7
commit 247fdd1a4d
1 changed files with 27 additions and 15 deletions

View File

@ -855,16 +855,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
IList parameters = new ArrayList();
parameters.Add(param);
XmlRpcRequest req;
if (!m_disableKeepAlive)
{
req = new XmlRpcRequest(function, parameters);
}
else
{
// This seems to solve a major problem on some windows servers
req = new NoKeepAliveXmlRpcRequest(function, parameters);
}
ConfigurableKeepAliveXmlRpcRequest req;
req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
XmlRpcResponse resp = null;
@ -874,10 +866,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
}
catch (Exception e)
{
m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
foreach( string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None))
{
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine);
}
foreach (string key in param.Keys)
{
m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString());
@ -961,20 +959,24 @@ namespace Nwc.XmlRpc
using System.Reflection;
/// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
public class NoKeepAliveXmlRpcRequest : XmlRpcRequest
public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest
{
private Encoding _encoding = new ASCIIEncoding();
private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
private bool _disableKeepAlive = true;
public string RequestResponse = String.Empty;
/// <summary>Instantiate an <c>XmlRpcRequest</c> for a specified method and parameters.</summary>
/// <param name="methodName"><c>String</c> designating the <i>object.method</i> on the server the request
/// should be directed to.</param>
/// <param name="parameters"><c>ArrayList</c> of XML-RPC type parameters to invoke the request with.</param>
public NoKeepAliveXmlRpcRequest(String methodName, IList parameters)
public ConfigurableKeepAliveXmlRpcRequest(String methodName, IList parameters, bool disableKeepAlive)
{
MethodName = methodName;
_params = parameters;
_disableKeepAlive = disableKeepAlive;
}
/// <summary>Send the request to the server.</summary>
@ -989,7 +991,7 @@ namespace Nwc.XmlRpc
request.Method = "POST";
request.ContentType = "text/xml";
request.AllowWriteStreamBuffering = true;
request.KeepAlive = false;
request.KeepAlive = !_disableKeepAlive;
Stream stream = request.GetRequestStream();
XmlTextWriter xml = new XmlTextWriter(stream, _encoding);
@ -1000,7 +1002,17 @@ namespace Nwc.XmlRpc
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader input = new StreamReader(response.GetResponseStream());
XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input);
string inputXml = input.ReadToEnd();
XmlRpcResponse resp;
try
{
resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
}
catch (Exception e)
{
RequestResponse = inputXml;
throw e;
}
input.Close();
response.Close();
return resp;