don't loose inventory items when there are bad folders

httptests
UbitUmarov 2016-07-17 22:52:58 +01:00
parent 79e464f33f
commit eaefae7e20
2 changed files with 49 additions and 61 deletions

View File

@ -30,6 +30,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
@ -93,8 +94,8 @@ namespace OpenSim.Capabilities.Handlers
ArrayList foldersrequested = (ArrayList)hash["folders"]; ArrayList foldersrequested = (ArrayList)hash["folders"];
string response = ""; StringBuilder tmpresponse = new StringBuilder(1024);
string bad_folders_response = ""; StringBuilder tmpbadfolders = new StringBuilder(1024);
List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>(); List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>();
for (int i = 0; i < foldersrequested.Count; i++) for (int i = 0; i < foldersrequested.Count; i++)
@ -142,43 +143,38 @@ namespace OpenSim.Capabilities.Handlers
inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", ""); inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", "");
inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", "");
response += inventoryitemstr; tmpresponse.Append(inventoryitemstr);
} }
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders));
foreach (UUID bad in bad_folders) foreach (UUID bad in bad_folders)
bad_folders_response += "<uuid>" + bad + "</uuid>"; {
tmpbadfolders.Append("<map><key>folder_id</key><uuid>");
tmpbadfolders.Append(bad.ToString());
tmpbadfolders.Append("</uuid><key>error</key><string>Unknown</string></map>");
}
} }
if (response.Length == 0) StringBuilder lastresponse = new StringBuilder(1024);
lastresponse.Append("<llsd>");
if(tmpresponse.Length > 0)
{ {
/* Viewers expect a bad_folders array when not available */ lastresponse.Append("<map><key>folders</key><array>");
if (bad_folders_response.Length != 0) lastresponse.Append(tmpresponse.ToString());
{ lastresponse.Append("</array></map>");
response = "<llsd><map><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>";
}
else
{
response = "<llsd><map><key>folders</key><array /></map></llsd>";
}
} }
else else
lastresponse.Append("<map><key>folders</key><array /></map>");
if(tmpbadfolders.Length > 0)
{ {
if (bad_folders_response.Length != 0) lastresponse.Append("<map><key>bad_folders</key><array>");
{ lastresponse.Append(tmpbadfolders.ToString());
response = "<llsd><map><key>folders</key><array>" + response + "</array><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; lastresponse.Append("</array></map>");
}
else
{
response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>";
}
} }
lastresponse.Append("</llsd>");
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request for {0} folders. Item count {1}", folders.Count, item_count); return lastresponse.ToString();
//m_log.Debug("[WEB FETCH INV DESC HANDLER] " + response);
return response;
} }
/// <summary> /// <summary>
@ -285,8 +281,8 @@ namespace OpenSim.Capabilities.Handlers
{ {
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request for {0} folders", foldersrequested.Count); //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request for {0} folders", foldersrequested.Count);
string response = ""; StringBuilder tmpresponse = new StringBuilder(1024);
string bad_folders_response = ""; StringBuilder tmpbadfolders = new StringBuilder(1024);
for (int i = 0; i < foldersrequested.Count; i++) for (int i = 0; i < foldersrequested.Count; i++)
{ {
@ -308,7 +304,9 @@ namespace OpenSim.Capabilities.Handlers
if (null == reply) if (null == reply)
{ {
bad_folders_response += "<uuid>" + llsdRequest.folder_id.ToString() + "</uuid>"; tmpbadfolders.Append("<map><key>folder_id</key><uuid>");
tmpbadfolders.Append(llsdRequest.folder_id.ToString());
tmpbadfolders.Append("</uuid><key>error</key><string>Unknown</string></map>");
} }
else else
{ {
@ -317,39 +315,29 @@ namespace OpenSim.Capabilities.Handlers
inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", "");
} }
response += inventoryitemstr; tmpresponse.Append(inventoryitemstr);
} }
if (response.Length == 0) StringBuilder lastresponse = new StringBuilder(1024);
lastresponse.Append("<llsd>");
if(tmpresponse.Length > 0)
{ {
/* Viewers expect a bad_folders array when not available */ lastresponse.Append("<map><key>folders</key><array>");
if (bad_folders_response.Length != 0) lastresponse.Append(tmpresponse.ToString());
{ lastresponse.Append("</array></map>");
response = "<llsd><map><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>";
}
else
{
response = "<llsd><map><key>folders</key><array /></map></llsd>";
}
} }
else else
lastresponse.Append("<map><key>folders</key><array /></map>");
if(tmpbadfolders.Length > 0)
{ {
if (bad_folders_response.Length != 0) lastresponse.Append("<map><key>bad_folders</key><array>");
{ lastresponse.Append(tmpbadfolders.ToString());
response = "<llsd><map><key>folders</key><array>" + response + "</array><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; lastresponse.Append("</array></map>");
}
else
{
response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>";
}
} }
lastresponse.Append("</llsd>");
// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request"); return lastresponse.ToString();
//m_log.Debug("[WEB FETCH INV DESC HANDLER] "+response);
return response;
// }
} }
/// <summary> /// <summary>

View File

@ -61,7 +61,6 @@ namespace OpenSim.Region.ClientStack.Linden
public UUID reqID; public UUID reqID;
public Hashtable request; public Hashtable request;
public ScenePresence presence; public ScenePresence presence;
public List<UUID> folders;
} }
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -296,8 +295,10 @@ namespace OpenSim.Region.ClientStack.Linden
reqinfo.reqID = x; reqinfo.reqID = x;
reqinfo.request = y; reqinfo.request = y;
reqinfo.presence = sp; reqinfo.presence = sp;
reqinfo.folders = new List<UUID>();
/* why where we doing this? just to get cof ?
List<UUID> folders = new List<UUID>();
// Decode the request here // Decode the request here
string request = y["body"].ToString(); string request = y["body"].ToString();
@ -333,11 +334,11 @@ namespace OpenSim.Region.ClientStack.Linden
UUID folderID; UUID folderID;
if (UUID.TryParse(folder, out folderID)) if (UUID.TryParse(folder, out folderID))
{ {
if (!reqinfo.folders.Contains(folderID)) if (!folders.Contains(folderID))
{ {
if (sp.COF != UUID.Zero && sp.COF == folderID) if (sp.COF != UUID.Zero && sp.COF == folderID)
highPriority = true; highPriority = true;
reqinfo.folders.Add(folderID); folders.Add(folderID);
} }
} }
} }
@ -345,6 +346,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (highPriority) if (highPriority)
m_queue.PriorityEnqueue(reqinfo); m_queue.PriorityEnqueue(reqinfo);
else else
*/
m_queue.Enqueue(reqinfo); m_queue.Enqueue(reqinfo);
}; };
@ -406,7 +408,6 @@ namespace OpenSim.Region.ClientStack.Linden
if(dropedResponses.Contains(requestID)) if(dropedResponses.Contains(requestID))
{ {
dropedResponses.Remove(requestID); dropedResponses.Remove(requestID);
requestinfo.folders.Clear();
requestinfo.request.Clear(); requestinfo.request.Clear();
WebFetchInvDescModule.ProcessedRequestsCount++; WebFetchInvDescModule.ProcessedRequestsCount++;
return; return;
@ -417,7 +418,6 @@ namespace OpenSim.Region.ClientStack.Linden
m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054");
responses[requestID] = response; responses[requestID] = response;
} }
requestinfo.folders.Clear();
requestinfo.request.Clear(); requestinfo.request.Clear();
WebFetchInvDescModule.ProcessedRequestsCount++; WebFetchInvDescModule.ProcessedRequestsCount++;
} }