save a few lists scaning

httptests
UbitUmarov 2016-12-06 10:26:36 +00:00
parent 1680425f4d
commit ccaa7a4a8a
1 changed files with 80 additions and 58 deletions

View File

@ -113,10 +113,7 @@ namespace OpenSim.Capabilities.Handlers
continue; continue;
} }
// Filter duplicate folder ids that bad viewers may send
if (folders.Find(f => f.folder_id == llsdRequest.folder_id) == null)
folders.Add(llsdRequest); folders.Add(llsdRequest);
} }
if (folders.Count > 0) if (folders.Count > 0)
@ -431,17 +428,10 @@ namespace OpenSim.Capabilities.Handlers
} }
private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> fetchFolders, List<InventoryCollectionWithDescendents> result) private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> libFolders, List<InventoryCollectionWithDescendents> result)
{ {
InventoryFolderImpl fold; InventoryFolderImpl fold;
if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null) foreach (LLSDFetchInventoryDescendents f in libFolders)
{
List<LLSDFetchInventoryDescendents> libfolders = fetchFolders.FindAll(f => f.owner_id == m_LibraryService.LibraryRootFolder.Owner);
fetchFolders.RemoveAll(f => libfolders.Contains(f));
//m_log.DebugFormat("[XXX]: Found {0} library folders in request", libfolders.Count);
foreach (LLSDFetchInventoryDescendents f in libfolders)
{ {
if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null) if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null)
{ {
@ -461,7 +451,6 @@ namespace OpenSim.Capabilities.Handlers
} }
} }
} }
}
private List<InventoryCollectionWithDescendents> Fetch(List<LLSDFetchInventoryDescendents> fetchFolders, List<UUID> bad_folders) private List<InventoryCollectionWithDescendents> Fetch(List<LLSDFetchInventoryDescendents> fetchFolders, List<UUID> bad_folders)
{ {
@ -471,50 +460,77 @@ namespace OpenSim.Capabilities.Handlers
// FIXME MAYBE: We're not handling sortOrder! // FIXME MAYBE: We're not handling sortOrder!
List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>(); List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>();
if(fetchFolders.Count <= 0)
return result;
AddLibraryFolders(fetchFolders, result); List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>();
List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>();
HashSet<UUID> libIDs = new HashSet<UUID>();
HashSet<UUID> otherIDs = new HashSet<UUID>();
bool dolib = (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null);
UUID libOwner = UUID.Zero;
if(dolib)
libOwner = m_LibraryService.LibraryRootFolder.Owner;
// Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense
// and can kill the sim (all root folders have parent_id Zero) // and can kill the sim (all root folders have parent_id Zero)
// send something. // send something.
LLSDFetchInventoryDescendents zero = fetchFolders.Find(f => f.folder_id == UUID.Zero); foreach(LLSDFetchInventoryDescendents f in fetchFolders)
if (zero != null) {
if (f.folder_id == UUID.Zero)
{ {
fetchFolders.Remove(zero);
InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents();
zeroColl.Collection = new InventoryCollection(); zeroColl.Collection = new InventoryCollection();
zeroColl.Collection.OwnerID = zero.owner_id; zeroColl.Collection.OwnerID = f.owner_id;
zeroColl.Collection.Version = 0; zeroColl.Collection.Version = 0;
zeroColl.Collection.FolderID = zero.folder_id; zeroColl.Collection.FolderID = f.folder_id;
zeroColl.Descendents = 0; zeroColl.Descendents = 0;
result.Add(zeroColl); result.Add(zeroColl);
continue;
}
if(dolib && f.owner_id == libOwner)
{
if(libIDs.Contains(f.folder_id))
continue;
libIDs.Add(f.folder_id);
libFolders.Add(f);
continue;
}
if(otherIDs.Contains(f.folder_id))
continue;
otherIDs.Add(f.folder_id);
otherFolders.Add(f);
} }
if (fetchFolders.Count > 0)
if(otherFolders.Count > 0)
{ {
UUID[] fids = new UUID[fetchFolders.Count]; UUID[] fids = new UUID[otherFolders.Count];
int i = 0; int i = 0;
foreach (LLSDFetchInventoryDescendents f in fetchFolders) foreach (LLSDFetchInventoryDescendents f in otherFolders)
fids[i++] = f.folder_id; fids[i++] = f.folder_id;
//m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids)); //m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids));
InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(fetchFolders[0].owner_id, fids); InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, fids);
if (fetchedContents == null || (fetchedContents != null && fetchedContents.Length == 0)) if (fetchedContents == null)
{
m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Could not get contents of multiple folders for user {0}", fetchFolders[0].owner_id);
foreach (LLSDFetchInventoryDescendents freq in fetchFolders)
BadFolder(freq, null, bad_folders);
return null; return null;
}
if (fetchedContents.Length == 0)
{
foreach (LLSDFetchInventoryDescendents freq in otherFolders)
BadFolder(freq, null, bad_folders);
}
else
{
i = 0; i = 0;
// Do some post-processing. May need to fetch more from inv server for links // Do some post-processing. May need to fetch more from inv server for links
foreach (InventoryCollection contents in fetchedContents) foreach (InventoryCollection contents in fetchedContents)
{ {
// Find the original request // Find the original request
LLSDFetchInventoryDescendents freq = fetchFolders[i++]; LLSDFetchInventoryDescendents freq = otherFolders[i++];
InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents(); InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents();
coll.Collection = contents; coll.Collection = contents;
@ -528,6 +544,12 @@ namespace OpenSim.Capabilities.Handlers
result.Add(coll); result.Add(coll);
} }
} }
}
if(dolib && libFolders.Count > 0)
{
AddLibraryFolders(libFolders, result);
}
return result; return result;
} }