Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

0.8.0.3
Diva Canto 2014-04-24 14:12:04 -07:00
commit cf54df3ecf
10 changed files with 278 additions and 297 deletions

View File

@ -634,8 +634,6 @@ namespace OpenSim.Data.MySQL
{ {
if(reader.HasRows) if(reader.HasRows)
{ {
m_log.DebugFormat("[PROFILES_DATA]" +
": Getting data for {0}.", props.UserId);
reader.Read(); reader.Read();
props.WebUrl = (string)reader["profileURL"]; props.WebUrl = (string)reader["profileURL"];
UUID.TryParse((string)reader["profileImage"], out props.ImageId); UUID.TryParse((string)reader["profileImage"], out props.ImageId);
@ -651,9 +649,6 @@ namespace OpenSim.Data.MySQL
} }
else else
{ {
m_log.DebugFormat("[PROFILES_DATA]" +
": No data for {0}", props.UserId);
props.WebUrl = string.Empty; props.WebUrl = string.Empty;
props.ImageId = UUID.Zero; props.ImageId = UUID.Zero;
props.AboutText = string.Empty; props.AboutText = string.Empty;

View File

@ -584,9 +584,6 @@ namespace OpenSim.Data.SQLite
} }
if(reader != null && reader.Read()) if(reader != null && reader.Read())
{ {
m_log.DebugFormat("[PROFILES_DATA]" +
": Getting data for {0}.", props.UserId);
props.WebUrl = (string)reader["profileURL"]; props.WebUrl = (string)reader["profileURL"];
UUID.TryParse((string)reader["profileImage"], out props.ImageId); UUID.TryParse((string)reader["profileImage"], out props.ImageId);
props.AboutText = (string)reader["profileAboutText"]; props.AboutText = (string)reader["profileAboutText"];
@ -601,9 +598,6 @@ namespace OpenSim.Data.SQLite
} }
else else
{ {
m_log.DebugFormat("[PROFILES_DATA]" +
": No data for {0}", props.UserId);
props.WebUrl = string.Empty; props.WebUrl = string.Empty;
props.ImageId = UUID.Zero; props.ImageId = UUID.Zero;
props.AboutText = string.Empty; props.AboutText = string.Empty;

View File

@ -705,7 +705,7 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
} }
WebUtil.LogResponseDetail(output); WebUtil.LogResponseDetail(null, output);
} }
if (!response.SendChunked && response.ContentLength64 <= 0) if (!response.SendChunked && response.ContentLength64 <= 0)

View File

@ -48,7 +48,6 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
} }
#region Web Util
/// <summary> /// <summary>
/// Sends json-rpc request with a serializable type. /// Sends json-rpc request with a serializable type.
/// </summary> /// </summary>
@ -70,64 +69,62 @@ namespace OpenSim.Framework.Servers.HttpServer
public bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId) public bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId)
{ {
if (jsonId == null) if (jsonId == null)
throw new ArgumentNullException ("jsonId"); throw new ArgumentNullException("jsonId");
if (uri == null) if (uri == null)
throw new ArgumentNullException ("uri"); throw new ArgumentNullException("uri");
if (method == null) if (method == null)
throw new ArgumentNullException ("method"); throw new ArgumentNullException("method");
if (parameters == null) if (parameters == null)
throw new ArgumentNullException ("parameters"); throw new ArgumentNullException("parameters");
// Prep our payload
OSDMap json = new OSDMap();
json.Add("jsonrpc", OSD.FromString("2.0"));
json.Add("id", OSD.FromString(jsonId));
json.Add("method", OSD.FromString(method));
json.Add("params", OSD.SerializeMembers(parameters));
string jsonRequestData = OSDParser.SerializeJsonString(json);
byte[] content = Encoding.UTF8.GetBytes(jsonRequestData);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.ContentType = "application/json-rpc";
webRequest.Method = "POST";
//Stream dataStream = webRequest.GetRequestStream();
//dataStream.Write(content, 0, content.Length);
//dataStream.Close();
using (Stream dataStream = webRequest.GetRequestStream()) OSDMap request = new OSDMap();
dataStream.Write(content, 0, content.Length); request.Add("jsonrpc", OSD.FromString("2.0"));
request.Add("id", OSD.FromString(jsonId));
WebResponse webResponse = null; request.Add("method", OSD.FromString(method));
request.Add("params", OSD.SerializeMembers(parameters));
OSDMap response;
try try
{ {
webResponse = webRequest.GetResponse(); response = WebUtil.PostToService(uri, request, 10000, true);
} }
catch (WebException e) catch (Exception e)
{ {
Console.WriteLine("Web Error" + e.Message); m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e);
Console.WriteLine ("Please check input");
return false; return false;
} }
using (webResponse) if (!response.ContainsKey("_Result"))
using (Stream rstream = webResponse.GetResponseStream())
{ {
OSDMap mret = (OSDMap)OSDParser.DeserializeJson(rstream); m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}",
method, OSDParser.SerializeJsonString(response));
if (mret.ContainsKey("error")) return false;
return false;
// get params...
OSD.DeserializeMembers(ref parameters, (OSDMap)mret["result"]);
return true;
} }
response = (OSDMap)response["_Result"];
OSD data;
if (response.ContainsKey("error"))
{
data = response["error"];
m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}",
method, OSDParser.SerializeJsonString(data));
return false;
}
if (!response.ContainsKey("result"))
{
m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}",
method, OSDParser.SerializeJsonString(response));
return false;
}
data = response["result"];
OSD.DeserializeMembers(ref parameters, (OSDMap)data);
return true;
} }
/// <summary> /// <summary>
/// Sends json-rpc request with OSD parameter. /// Sends json-rpc request with OSD parameter.
/// </summary> /// </summary>
@ -135,7 +132,7 @@ namespace OpenSim.Framework.Servers.HttpServer
/// The rpc request. /// The rpc request.
/// </returns> /// </returns>
/// <param name='data'> /// <param name='data'>
/// data - incoming as parameters, outgong as result/error /// data - incoming as parameters, outgoing as result/error
/// </param> /// </param>
/// <param name='method'> /// <param name='method'>
/// Json-rpc method to call. /// Json-rpc method to call.
@ -148,64 +145,46 @@ namespace OpenSim.Framework.Servers.HttpServer
/// </param> /// </param>
public bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonId) public bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonId)
{ {
OSDMap map = new OSDMap(); if (string.IsNullOrEmpty(jsonId))
jsonId = UUID.Random().ToString();
map["jsonrpc"] = "2.0";
if(string.IsNullOrEmpty(jsonId))
map["id"] = UUID.Random().ToString();
else
map["id"] = jsonId;
map["method"] = method;
map["params"] = data;
string jsonRequestData = OSDParser.SerializeJsonString(map);
byte[] content = Encoding.UTF8.GetBytes(jsonRequestData);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.ContentType = "application/json-rpc";
webRequest.Method = "POST";
using (Stream dataStream = webRequest.GetRequestStream())
dataStream.Write(content, 0, content.Length);
WebResponse webResponse = null; OSDMap request = new OSDMap();
request.Add("jsonrpc", OSD.FromString("2.0"));
request.Add("id", OSD.FromString(jsonId));
request.Add("method", OSD.FromString(method));
request.Add("params", data);
OSDMap response;
try try
{ {
webResponse = webRequest.GetResponse(); response = WebUtil.PostToService(uri, request, 10000, true);
} }
catch (WebException e) catch (Exception e)
{ {
Console.WriteLine("Web Error" + e.Message); m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e);
Console.WriteLine ("Please check input");
return false; return false;
} }
using (webResponse) if (!response.ContainsKey("_Result"))
using (Stream rstream = webResponse.GetResponseStream())
{ {
OSDMap response = new OSDMap(); m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}",
try method, OSDParser.SerializeJsonString(response));
{ return false;
response = (OSDMap)OSDParser.DeserializeJson(rstream);
}
catch (Exception e)
{
m_log.DebugFormat("[JSONRPC]: JsonRpcRequest Error {0}", e.Message);
return false;
}
if (response.ContainsKey("error"))
{
data = response["error"];
return false;
}
data = response;
return true;
} }
response = (OSDMap)response["_Result"];
if (response.ContainsKey("error"))
{
data = response["error"];
m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}",
method, OSDParser.SerializeJsonString(data));
return false;
}
data = response;
return true;
} }
#endregion Web Util
} }
} }

View File

@ -39,7 +39,9 @@ using System.Text;
using System.Web; using System.Web;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Xml.Linq;
using log4net; using log4net;
using Nwc.XmlRpc;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper; using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper;
@ -127,41 +129,41 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
public static OSDMap PutToServiceCompressed(string url, OSDMap data, int timeout) public static OSDMap PutToServiceCompressed(string url, OSDMap data, int timeout)
{ {
return ServiceOSDRequest(url,data, "PUT", timeout, true); return ServiceOSDRequest(url,data, "PUT", timeout, true, false);
} }
public static OSDMap PutToService(string url, OSDMap data, int timeout) public static OSDMap PutToService(string url, OSDMap data, int timeout)
{ {
return ServiceOSDRequest(url,data, "PUT", timeout, false); return ServiceOSDRequest(url,data, "PUT", timeout, false, false);
} }
public static OSDMap PostToService(string url, OSDMap data, int timeout) public static OSDMap PostToService(string url, OSDMap data, int timeout, bool rpc)
{ {
return ServiceOSDRequest(url, data, "POST", timeout, false); return ServiceOSDRequest(url, data, "POST", timeout, false, rpc);
} }
public static OSDMap PostToServiceCompressed(string url, OSDMap data, int timeout) public static OSDMap PostToServiceCompressed(string url, OSDMap data, int timeout)
{ {
return ServiceOSDRequest(url, data, "POST", timeout, true); return ServiceOSDRequest(url, data, "POST", timeout, true, false);
} }
public static OSDMap GetFromService(string url, int timeout) public static OSDMap GetFromService(string url, int timeout)
{ {
return ServiceOSDRequest(url, null, "GET", timeout, false); return ServiceOSDRequest(url, null, "GET", timeout, false, false);
} }
public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed) public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc)
{ {
if (SerializeOSDRequestsPerEndpoint) if (SerializeOSDRequestsPerEndpoint)
{ {
lock (EndPointLock(url)) lock (EndPointLock(url))
{ {
return ServiceOSDRequestWorker(url, data, method, timeout, compressed); return ServiceOSDRequestWorker(url, data, method, timeout, compressed, rpc);
} }
} }
else else
{ {
return ServiceOSDRequestWorker(url, data, method, timeout, compressed); return ServiceOSDRequestWorker(url, data, method, timeout, compressed, rpc);
} }
} }
@ -191,9 +193,9 @@ namespace OpenSim.Framework
} }
} }
public static void LogOutgoingDetail(string output) public static void LogOutgoingDetail(string type, int reqnum, string output)
{ {
LogOutgoingDetail("", output); LogOutgoingDetail(string.Format("{0} {1}: ", type, reqnum), output);
} }
public static void LogOutgoingDetail(string context, string output) public static void LogOutgoingDetail(string context, string output)
@ -207,24 +209,24 @@ namespace OpenSim.Framework
m_log.DebugFormat("[LOGHTTP]: {0}{1}", context, Util.BinaryToASCII(output)); m_log.DebugFormat("[LOGHTTP]: {0}{1}", context, Util.BinaryToASCII(output));
} }
public static void LogResponseDetail(Stream inputStream) public static void LogResponseDetail(int reqnum, Stream inputStream)
{ {
LogOutgoingDetail("RESPONSE: ", inputStream); LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), inputStream);
} }
public static void LogResponseDetail(string input) public static void LogResponseDetail(int? reqnum, string input)
{ {
LogOutgoingDetail("RESPONSE: ", input); string context = (reqnum == null) ? "" : string.Format("RESPONSE {0}: ", reqnum.Value);
LogOutgoingDetail(context, input);
} }
private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc)
{ {
int reqnum = RequestNumber++; int reqnum = RequestNumber++;
if (DebugLevel >= 3) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} JSON-RPC {1} to {2}",
"[LOGHTTP]: HTTP OUT {0} ServiceOSD {1} {2} (timeout {3}, compressed {4})", reqnum, method, url);
reqnum, method, url, timeout, compressed);
string errorMessage = "unknown error"; string errorMessage = "unknown error";
int tickstart = Util.EnvironmentTickCount(); int tickstart = Util.EnvironmentTickCount();
@ -247,11 +249,11 @@ namespace OpenSim.Framework
strBuffer = OSDParser.SerializeJsonString(data); strBuffer = OSDParser.SerializeJsonString(data);
if (DebugLevel >= 5) if (DebugLevel >= 5)
LogOutgoingDetail(strBuffer); LogOutgoingDetail("SEND", reqnum, strBuffer);
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer);
request.ContentType = "application/json"; request.ContentType = rpc ? "application/json-rpc" : "application/json";
if (compressed) if (compressed)
{ {
@ -291,9 +293,8 @@ namespace OpenSim.Framework
using (StreamReader reader = new StreamReader(responseStream)) using (StreamReader reader = new StreamReader(responseStream))
{ {
string responseStr = reader.ReadToEnd(); string responseStr = reader.ReadToEnd();
// m_log.DebugFormat("[LOGHTTP]: <{0}> response is <{1}>",reqnum,responseStr);
if (WebUtil.DebugLevel >= 5) if (WebUtil.DebugLevel >= 5)
WebUtil.LogResponseDetail(responseStr); WebUtil.LogResponseDetail(reqnum, responseStr);
return CanonicalizeResults(responseStr); return CanonicalizeResults(responseStr);
} }
} }
@ -316,24 +317,23 @@ namespace OpenSim.Framework
{ {
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
if (tickdiff > LongCallTime) if (tickdiff > LongCallTime)
{
m_log.InfoFormat( m_log.InfoFormat(
"[LOGHTTP]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing, {5}", "[LOGHTTP]: Slow JSON-RPC request {0} {1} to {2} took {3}ms, {4}ms writing, {5}",
reqnum, reqnum, method, url, tickdiff, tickdata,
method,
url,
tickdiff,
tickdata,
strBuffer != null strBuffer != null
? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer)
: ""); : "");
}
else if (DebugLevel >= 4) else if (DebugLevel >= 4)
m_log.DebugFormat( {
"[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
reqnum, tickdiff, tickdata); reqnum, tickdiff, tickdata);
}
} }
m_log.DebugFormat( m_log.DebugFormat(
"[LOGHTTP]: ServiceOSD request {0} {1} {2} FAILED: {3}", reqnum, url, method, errorMessage); "[LOGHTTP]: JSON-RPC request {0} {1} to {2} FAILED: {3}", reqnum, method, url, errorMessage);
return ErrorResponseMap(errorMessage); return ErrorResponseMap(errorMessage);
} }
@ -411,9 +411,8 @@ namespace OpenSim.Framework
string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown";
if (DebugLevel >= 3) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} ServiceForm '{1}' to {2}",
"[LOGHTTP]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})", reqnum, method, url);
reqnum, method, url, timeout);
string errorMessage = "unknown error"; string errorMessage = "unknown error";
int tickstart = Util.EnvironmentTickCount(); int tickstart = Util.EnvironmentTickCount();
@ -435,7 +434,7 @@ namespace OpenSim.Framework
queryString = BuildQueryString(data); queryString = BuildQueryString(data);
if (DebugLevel >= 5) if (DebugLevel >= 5)
LogOutgoingDetail(queryString); LogOutgoingDetail("SEND", reqnum, queryString);
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString);
@ -457,7 +456,7 @@ namespace OpenSim.Framework
{ {
string responseStr = reader.ReadToEnd(); string responseStr = reader.ReadToEnd();
if (WebUtil.DebugLevel >= 5) if (WebUtil.DebugLevel >= 5)
WebUtil.LogResponseDetail(responseStr); WebUtil.LogResponseDetail(reqnum, responseStr);
OSD responseOSD = OSDParser.Deserialize(responseStr); OSD responseOSD = OSDParser.Deserialize(responseStr);
if (responseOSD.Type == OSDType.Map) if (responseOSD.Type == OSDType.Map)
@ -483,23 +482,22 @@ namespace OpenSim.Framework
{ {
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
if (tickdiff > LongCallTime) if (tickdiff > LongCallTime)
{
m_log.InfoFormat( m_log.InfoFormat(
"[LOGHTTP]: Slow ServiceForm request {0} {1} {2} took {3}ms, {4}ms writing, {5}", "[LOGHTTP]: Slow ServiceForm request {0} '{1}' to {2} took {3}ms, {4}ms writing, {5}",
reqnum, reqnum, method, url, tickdiff, tickdata,
method,
url,
tickdiff,
tickdata,
queryString != null queryString != null
? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString
: ""); : "");
}
else if (DebugLevel >= 4) else if (DebugLevel >= 4)
m_log.DebugFormat( {
"[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
reqnum, tickdiff, tickdata); reqnum, tickdiff, tickdata);
}
} }
m_log.WarnFormat("[LOGHTTP]: ServiceForm request {0} {1} {2} failed: {2}", reqnum, method, url, errorMessage); m_log.WarnFormat("[LOGHTTP]: ServiceForm request {0} '{1}' to {2} failed: {3}", reqnum, method, url, errorMessage);
return ErrorResponseMap(errorMessage); return ErrorResponseMap(errorMessage);
} }
@ -779,8 +777,7 @@ namespace OpenSim.Framework
int reqnum = WebUtil.RequestNumber++; int reqnum = WebUtil.RequestNumber++;
if (WebUtil.DebugLevel >= 3) if (WebUtil.DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} AsynchronousRequestObject {1} to {2}",
"[LOGHTTP]: HTTP OUT {0} AsynchronousRequestObject {1} {2}",
reqnum, verb, requestUrl); reqnum, verb, requestUrl);
int tickstart = Util.EnvironmentTickCount(); int tickstart = Util.EnvironmentTickCount();
@ -822,7 +819,7 @@ namespace OpenSim.Framework
byte[] data = buffer.ToArray(); byte[] data = buffer.ToArray();
if (WebUtil.DebugLevel >= 5) if (WebUtil.DebugLevel >= 5)
WebUtil.LogOutgoingDetail(System.Text.Encoding.UTF8.GetString(data)); WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data));
request.BeginGetRequestStream(delegate(IAsyncResult res) request.BeginGetRequestStream(delegate(IAsyncResult res)
{ {
@ -840,7 +837,8 @@ namespace OpenSim.Framework
{ {
using (Stream respStream = response.GetResponseStream()) using (Stream respStream = response.GetResponseStream())
{ {
deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, response.ContentLength); deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(
reqnum, respStream, response.ContentLength);
} }
} }
catch (System.InvalidOperationException) catch (System.InvalidOperationException)
@ -867,7 +865,8 @@ namespace OpenSim.Framework
{ {
using (Stream respStream = response.GetResponseStream()) using (Stream respStream = response.GetResponseStream())
{ {
deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, response.ContentLength); deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(
reqnum, respStream, response.ContentLength);
} }
} }
catch (System.InvalidOperationException) catch (System.InvalidOperationException)
@ -938,18 +937,13 @@ namespace OpenSim.Framework
} }
m_log.InfoFormat( m_log.InfoFormat(
"[LOGHTTP]: [ASYNC REQUEST]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", "[LOGHTTP]: Slow AsynchronousRequestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}",
reqnum, reqnum, verb, requestUrl, tickdiff, tickdata,
verb,
requestUrl,
tickdiff,
tickdata,
originalRequest); originalRequest);
} }
else if (WebUtil.DebugLevel >= 4) else if (WebUtil.DebugLevel >= 4)
{ {
m_log.DebugFormat( m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
"[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
reqnum, tickdiff, tickdata); reqnum, tickdiff, tickdata);
} }
} }
@ -981,8 +975,7 @@ namespace OpenSim.Framework
int reqnum = WebUtil.RequestNumber++; int reqnum = WebUtil.RequestNumber++;
if (WebUtil.DebugLevel >= 3) if (WebUtil.DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} SynchronousRestForms {1} to {2}",
"[LOGHTTP]: HTTP OUT {0} SynchronousRestForms {1} {2}",
reqnum, verb, requestUrl); reqnum, verb, requestUrl);
int tickstart = Util.EnvironmentTickCount(); int tickstart = Util.EnvironmentTickCount();
@ -1012,7 +1005,7 @@ namespace OpenSim.Framework
byte[] data = buffer.ToArray(); byte[] data = buffer.ToArray();
if (WebUtil.DebugLevel >= 5) if (WebUtil.DebugLevel >= 5)
WebUtil.LogOutgoingDetail(System.Text.Encoding.UTF8.GetString(data)); WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data));
Stream requestStream = null; Stream requestStream = null;
try try
@ -1058,21 +1051,20 @@ namespace OpenSim.Framework
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
if (tickdiff > WebUtil.LongCallTime) if (tickdiff > WebUtil.LongCallTime)
{
m_log.InfoFormat( m_log.InfoFormat(
"[LOGHTTP]: [FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", "[LOGHTTP]: Slow SynchronousRestForms request {0} {1} to {2} took {3}ms, {4}ms writing, {5}",
reqnum, reqnum, verb, requestUrl, tickdiff, tickdata,
verb,
requestUrl,
tickdiff,
tickdata,
obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj);
}
else if (WebUtil.DebugLevel >= 4) else if (WebUtil.DebugLevel >= 4)
m_log.DebugFormat( {
"[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
reqnum, tickdiff, tickdata); reqnum, tickdiff, tickdata);
}
if (WebUtil.DebugLevel >= 5) if (WebUtil.DebugLevel >= 5)
WebUtil.LogResponseDetail(respstring); WebUtil.LogResponseDetail(reqnum, respstring);
return respstring; return respstring;
} }
@ -1114,8 +1106,7 @@ namespace OpenSim.Framework
int reqnum = WebUtil.RequestNumber++; int reqnum = WebUtil.RequestNumber++;
if (WebUtil.DebugLevel >= 3) if (WebUtil.DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} SynchronousRestObject {1} to {2}",
"[LOGHTTP]: HTTP OUT {0} SynchronousRestObject {1} {2}",
reqnum, verb, requestUrl); reqnum, verb, requestUrl);
int tickstart = Util.EnvironmentTickCount(); int tickstart = Util.EnvironmentTickCount();
@ -1155,7 +1146,7 @@ namespace OpenSim.Framework
byte[] data = buffer.ToArray(); byte[] data = buffer.ToArray();
if (WebUtil.DebugLevel >= 5) if (WebUtil.DebugLevel >= 5)
WebUtil.LogOutgoingDetail(System.Text.Encoding.UTF8.GetString(data)); WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data));
try try
{ {
@ -1185,7 +1176,8 @@ namespace OpenSim.Framework
{ {
using (Stream respStream = resp.GetResponseStream()) using (Stream respStream = resp.GetResponseStream())
{ {
deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, resp.ContentLength); deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(
reqnum, respStream, resp.ContentLength);
} }
} }
else else
@ -1236,18 +1228,13 @@ namespace OpenSim.Framework
} }
m_log.InfoFormat( m_log.InfoFormat(
"[LOGHTTP]: [SynchronousRestObjectRequester]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", "[LOGHTTP]: Slow SynchronousRestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}",
reqnum, reqnum, verb, requestUrl, tickdiff, tickdata,
verb,
requestUrl,
tickdiff,
tickdata,
originalRequest); originalRequest);
} }
else if (WebUtil.DebugLevel >= 4) else if (WebUtil.DebugLevel >= 4)
{ {
m_log.DebugFormat( m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
"[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
reqnum, tickdiff, tickdata); reqnum, tickdiff, tickdata);
} }
} }
@ -1263,7 +1250,7 @@ namespace OpenSim.Framework
public static class XMLResponseHelper public static class XMLResponseHelper
{ {
public static TResponse LogAndDeserialize<TRequest, TResponse>(Stream respStream, long contentLength) public static TResponse LogAndDeserialize<TRequest, TResponse>(int reqnum, Stream respStream, long contentLength)
{ {
XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
@ -1272,7 +1259,7 @@ namespace OpenSim.Framework
byte[] data = new byte[contentLength]; byte[] data = new byte[contentLength];
Util.ReadStream(respStream, data); Util.ReadStream(respStream, data);
WebUtil.LogResponseDetail(System.Text.Encoding.UTF8.GetString(data)); WebUtil.LogResponseDetail(reqnum, System.Text.Encoding.UTF8.GetString(data));
using (MemoryStream temp = new MemoryStream(data)) using (MemoryStream temp = new MemoryStream(data))
return (TResponse)deserializer.Deserialize(temp); return (TResponse)deserializer.Deserialize(temp);
@ -1284,4 +1271,81 @@ namespace OpenSim.Framework
} }
} }
} }
public static class XMLRPCRequester
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static Hashtable SendRequest(Hashtable ReqParams, string method, string url)
{
int reqnum = WebUtil.RequestNumber++;
if (WebUtil.DebugLevel >= 3)
m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} XML-RPC '{1}' to {2}",
reqnum, method, url);
int tickstart = Util.EnvironmentTickCount();
string responseStr = null;
try
{
ArrayList SendParams = new ArrayList();
SendParams.Add(ReqParams);
XmlRpcRequest Req = new XmlRpcRequest(method, SendParams);
if (WebUtil.DebugLevel >= 5)
{
string str = Req.ToString();
str = XElement.Parse(str).ToString(SaveOptions.DisableFormatting);
WebUtil.LogOutgoingDetail("SEND", reqnum, str);
}
XmlRpcResponse Resp = Req.Send(url, 30000);
try
{
responseStr = Resp.ToString();
responseStr = XElement.Parse(responseStr).ToString(SaveOptions.DisableFormatting);
if (WebUtil.DebugLevel >= 5)
WebUtil.LogResponseDetail(reqnum, responseStr);
}
catch (Exception e)
{
m_log.Error("Error parsing XML-RPC response", e);
}
if (Resp.IsFault)
{
m_log.DebugFormat(
"[LOGHTTP]: XML-RPC request {0} '{1}' to {2} FAILED: FaultCode={3}, FaultMessage={4}",
reqnum, method, url, Resp.FaultCode, Resp.FaultString);
return null;
}
Hashtable RespData = (Hashtable)Resp.Value;
return RespData;
}
finally
{
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
if (tickdiff > WebUtil.LongCallTime)
{
m_log.InfoFormat(
"[LOGHTTP]: Slow XML-RPC request {0} '{1}' to {2} took {3}ms, {4}",
reqnum, method, url, tickdiff,
responseStr != null
? (responseStr.Length > WebUtil.MaxRequestDiagLength ? responseStr.Remove(WebUtil.MaxRequestDiagLength) : responseStr)
: "");
}
else if (WebUtil.DebugLevel >= 4)
{
m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", reqnum, tickdiff);
}
}
}
}
} }

View File

@ -47,6 +47,7 @@ using OpenSim.Services.Interfaces;
using Mono.Addins; using Mono.Addins;
using OpenSim.Services.Connectors.Hypergrid; using OpenSim.Services.Connectors.Hypergrid;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.UserProfilesService;
namespace OpenSim.Region.CoreModules.Avatar.UserProfiles namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
{ {
@ -64,6 +65,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
Dictionary<UUID, UUID> m_classifiedCache = new Dictionary<UUID, UUID>(); Dictionary<UUID, UUID> m_classifiedCache = new Dictionary<UUID, UUID>();
Dictionary<UUID, int> m_classifiedInterest = new Dictionary<UUID, int>(); Dictionary<UUID, int> m_classifiedInterest = new Dictionary<UUID, int>();
private JsonRpcRequestManager rpc = new JsonRpcRequestManager();
public Scene Scene public Scene Scene
{ {
get; private set; get; private set;
@ -113,7 +116,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
set; set;
} }
JsonRpcRequestManager rpc = new JsonRpcRequestManager();
#region IRegionModuleBase implementation #region IRegionModuleBase implementation
/// <summary> /// <summary>
@ -919,7 +921,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
{ {
if ( String.IsNullOrEmpty(avatarID.ToString()) || String.IsNullOrEmpty(remoteClient.AgentId.ToString())) if (String.IsNullOrEmpty(avatarID.ToString()) || String.IsNullOrEmpty(remoteClient.AgentId.ToString()))
{ {
// Looking for a reason that some viewers are sending null Id's // Looking for a reason that some viewers are sending null Id's
m_log.DebugFormat("[PROFILES]: This should not happen remoteClient.AgentId {0} - avatarID {1}", remoteClient.AgentId, avatarID); m_log.DebugFormat("[PROFILES]: This should not happen remoteClient.AgentId {0} - avatarID {1}", remoteClient.AgentId, avatarID);
@ -997,29 +999,10 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
props.UserId = avatarID; props.UserId = avatarID;
try if (!GetProfileData(ref props, foreign, out result))
{ {
GetProfileData(ref props, out result); m_log.DebugFormat("Error getting profile for {0}: {1}", avatarID, result);
} return;
catch (Exception e)
{
if (foreign)
{
// Check if the foreign grid is using OpenProfile.
// If any error occurs then discard it, and report the original error.
try
{
OpenProfileClient client = new OpenProfileClient(serverURI);
if (!client.RequestAvatarPropertiesUsingOpenProfile(ref props))
throw e;
}
catch (Exception)
{
throw e;
}
}
else
throw;
} }
remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, charterMember , props.FirstLifeText, flags, remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, charterMember , props.FirstLifeText, flags,
@ -1073,10 +1056,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
/// <returns> /// <returns>
/// The profile data. /// The profile data.
/// </returns> /// </returns>
/// <param name='userID'> bool GetProfileData(ref UserProfileProperties properties, bool foreign, out string message)
/// User I.
/// </param>
bool GetProfileData(ref UserProfileProperties properties, out string message)
{ {
// Can't handle NPC yet... // Can't handle NPC yet...
ScenePresence p = FindPresence(properties.UserId); ScenePresence p = FindPresence(properties.UserId);
@ -1095,14 +1075,42 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
// This is checking a friend on the home grid // This is checking a friend on the home grid
// Not HG friend // Not HG friend
if ( String.IsNullOrEmpty(serverURI)) if (String.IsNullOrEmpty(serverURI))
{ {
message = "No Presence - foreign friend"; message = "No Presence - foreign friend";
return false; return false;
} }
object Prop = (object)properties; object Prop = (object)properties;
rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString()); if (!rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString()))
{
// If it's a foreign user then try again using OpenProfile, in case that's what the grid is using
bool secondChanceSuccess = false;
if (foreign)
{
try
{
OpenProfileClient client = new OpenProfileClient(serverURI);
if (client.RequestAvatarPropertiesUsingOpenProfile(ref properties))
secondChanceSuccess = true;
}
catch (Exception e)
{
m_log.Debug(string.Format("Request using the OpenProfile API to {0} failed", serverURI), e);
// Allow the return 'message' to say "JsonRpcRequest" and not "OpenProfile", because
// the most likely reason that OpenProfile failed is that the remote server
// doesn't support OpenProfile, and that's not very interesting.
}
}
if (!secondChanceSuccess)
{
message = string.Format("JsonRpcRequest to {0} failed", serverURI);
return false;
}
// else, continue below
}
properties = (UserProfileProperties)Prop; properties = (UserProfileProperties)Prop;
message = "Success"; message = "Success";

View File

@ -136,7 +136,7 @@ namespace OpenSim.Services.Connectors.Simulation
} }
// Try the old version, uncompressed // Try the old version, uncompressed
result = WebUtil.PostToService(uri, args, 30000); result = WebUtil.PostToService(uri, args, 30000, false);
if (result["Success"].AsBoolean()) if (result["Success"].AsBoolean())
{ {
@ -302,7 +302,7 @@ namespace OpenSim.Services.Connectors.Simulation
try try
{ {
OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false); OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false);
bool success = result["success"].AsBoolean(); bool success = result["success"].AsBoolean();
if (result.ContainsKey("_Result")) if (result.ContainsKey("_Result"))
{ {
@ -365,7 +365,7 @@ namespace OpenSim.Services.Connectors.Simulation
try try
{ {
WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false);
} }
catch (Exception e) catch (Exception e)
{ {
@ -384,7 +384,7 @@ namespace OpenSim.Services.Connectors.Simulation
try try
{ {
WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false);
} }
catch (Exception e) catch (Exception e)
{ {
@ -431,7 +431,7 @@ namespace OpenSim.Services.Connectors.Simulation
args["destination_name"] = OSD.FromString(destination.RegionName); args["destination_name"] = OSD.FromString(destination.RegionName);
args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
OSDMap result = WebUtil.PostToService(uri, args, 40000); OSDMap result = WebUtil.PostToService(uri, args, 40000, false);
if (result == null) if (result == null)
return false; return false;

View File

@ -68,10 +68,6 @@ namespace OpenSim.Services.GridService
protected string m_ThisGatekeeper = string.Empty; protected string m_ThisGatekeeper = string.Empty;
protected Uri m_ThisGatekeeperURI = null; protected Uri m_ThisGatekeeperURI = null;
// Hyperlink regions are hyperlinks on the map
public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
protected GridRegion m_DefaultRegion; protected GridRegion m_DefaultRegion;
protected GridRegion DefaultRegion protected GridRegion DefaultRegion
{ {

View File

@ -35,11 +35,10 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
using log4net; using log4net;
using Nwc.XmlRpc;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
namespace OpenSim.Region.CoreModules.Avatar.UserProfiles namespace OpenSim.Services.UserProfilesService
{ {
/// <summary> /// <summary>
/// A client for accessing a profile server using the OpenProfile protocol. /// A client for accessing a profile server using the OpenProfile protocol.
@ -79,7 +78,12 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
Hashtable ReqHash = new Hashtable(); Hashtable ReqHash = new Hashtable();
ReqHash["avatar_id"] = props.UserId.ToString(); ReqHash["avatar_id"] = props.UserId.ToString();
Hashtable profileData = GenericXMLRPCRequest(ReqHash, "avatar_properties_request", m_serverURI); Hashtable profileData = XMLRPCRequester.SendRequest(ReqHash, "avatar_properties_request", m_serverURI);
if (profileData == null)
return false;
if (!profileData.ContainsKey("data"))
return false;
ArrayList dataArray = (ArrayList)profileData["data"]; ArrayList dataArray = (ArrayList)profileData["data"];
@ -128,66 +132,5 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
return true; return true;
} }
private Hashtable GenericXMLRPCRequest(Hashtable ReqParams, string method, string server)
{
ArrayList SendParams = new ArrayList();
SendParams.Add(ReqParams);
XmlRpcResponse Resp;
try
{
XmlRpcRequest Req = new XmlRpcRequest(method, SendParams);
Resp = Req.Send(server, 30000);
}
catch (WebException ex)
{
m_log.ErrorFormat("[PROFILE]: Unable to connect to Profile " +
"Server {0}. Exception {1}", server, ex);
Hashtable ErrorHash = new Hashtable();
ErrorHash["success"] = false;
ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
ErrorHash["errorURI"] = "";
return ErrorHash;
}
catch (SocketException ex)
{
m_log.ErrorFormat(
"[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. " +
"Exception {3}", server, method, ReqParams, ex);
Hashtable ErrorHash = new Hashtable();
ErrorHash["success"] = false;
ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
ErrorHash["errorURI"] = "";
return ErrorHash;
}
catch (XmlException ex)
{
m_log.ErrorFormat(
"[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. " +
"Exception {3}", server, method, ReqParams.ToString(), ex);
Hashtable ErrorHash = new Hashtable();
ErrorHash["success"] = false;
ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
ErrorHash["errorURI"] = "";
return ErrorHash;
}
if (Resp.IsFault)
{
Hashtable ErrorHash = new Hashtable();
ErrorHash["success"] = false;
ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
ErrorHash["errorURI"] = "";
return ErrorHash;
}
Hashtable RespData = (Hashtable)Resp.Value;
return RespData;
}
} }
} }

View File

@ -93,6 +93,7 @@
<Reference name="System"/> <Reference name="System"/>
<Reference name="System.Core"/> <Reference name="System.Core"/>
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="System.Xml.Linq"/>
<Reference name="System.Data"/> <Reference name="System.Data"/>
<Reference name="System.Drawing"/> <Reference name="System.Drawing"/>
<Reference name="System.Web"/> <Reference name="System.Web"/>
@ -133,6 +134,7 @@
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="System.Xml"/>
<Reference name="Nini" path="../../../bin/"/> <Reference name="Nini" path="../../../bin/"/>
<Reference name="log4net" path="../../../bin/"/> <Reference name="log4net" path="../../../bin/"/>