Add a bit more error-checking to GetFriendRegionInfos.

0.6.0-stable
Homer Horwitz 2008-11-03 19:13:42 +00:00
parent 8dbd0118a8
commit a64d6eccd0
1 changed files with 24 additions and 13 deletions

View File

@ -739,25 +739,31 @@ namespace OpenSim.Region.Communications.OGS1
map["uuids"] = list; map["uuids"] = list;
map["recv_key"] = m_parent.NetworkServersInfo.UserRecvKey; map["recv_key"] = m_parent.NetworkServersInfo.UserRecvKey;
map["send_key"] = m_parent.NetworkServersInfo.UserRecvKey; map["send_key"] = m_parent.NetworkServersInfo.UserSendKey;
parameters.Add(map); parameters.Add(map);
try { try {
XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters); XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters);
XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.MessagingURL, 8000); XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.MessagingURL, 8000);
Hashtable respData = (Hashtable) resp.Value; Hashtable respData = resp != null ? (Hashtable) resp.Value : null;
if (respData.ContainsKey("faultMessage")) if (respData == null || respData.ContainsKey("faultMessage"))
{ {
m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessageServer about user-regions resulted in error: {0}", m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessagingServer about user-regions resulted in error: {0}",
respData["faultMessage"]); respData == null ? "<unknown error>" : respData["faultMessage"]);
}
else if(!respData.ContainsKey("count"))
{
m_log.WarnFormat("[OGS1 USER SERVICES]: Wrong format in response for MessagingServer request get_presence_info_bulk: missing 'count' field");
} }
else else
{ {
int count = (int)respData["count"]; int count = (int)respData["count"];
m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count); m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count);
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{
if(respData.ContainsKey("uuid_" + i) && respData.ContainsKey("isOnline_" + i) && respData.ContainsKey("regionHandle_" + i))
{ {
UUID uuid; UUID uuid;
if (UUID.TryParse((string)respData["uuid_" + i], out uuid)) if (UUID.TryParse((string)respData["uuid_" + i], out uuid))
@ -769,6 +775,11 @@ namespace OpenSim.Region.Communications.OGS1
result.Add(uuid, info); result.Add(uuid, info);
} }
} }
else
{
m_log.WarnFormat("[OGS1 USER SERVICES]: Response to get_presence_info_bulk contained an error in entry {0}", i);
}
}
} }
} }
catch (WebException e) catch (WebException e)