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 folders.Add(llsdRequest);
if (folders.Find(f => f.folder_id == llsdRequest.folder_id) == null)
folders.Add(llsdRequest);
} }
if (folders.Count > 0) if (folders.Count > 0)
@ -431,34 +428,26 @@ 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); if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null)
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) InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents();
{ ret.Collection = new InventoryCollection();
InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents();
ret.Collection = new InventoryCollection();
// ret.Collection.Folders = new List<InventoryFolderBase>(); // ret.Collection.Folders = new List<InventoryFolderBase>();
ret.Collection.Folders = fold.RequestListOfFolders(); ret.Collection.Folders = fold.RequestListOfFolders();
ret.Collection.Items = fold.RequestListOfItems(); ret.Collection.Items = fold.RequestListOfItems();
ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner; ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner;
ret.Collection.FolderID = f.folder_id; ret.Collection.FolderID = f.folder_id;
ret.Collection.Version = fold.Version; ret.Collection.Version = fold.Version;
ret.Descendents = ret.Collection.Items.Count + ret.Collection.Folders.Count; ret.Descendents = ret.Collection.Items.Count + ret.Collection.Folders.Count;
result.Add(ret); result.Add(ret);
//m_log.DebugFormat("[XXX]: Added libfolder {0} ({1}) {2}", ret.Collection.FolderID, ret.Collection.OwnerID); //m_log.DebugFormat("[XXX]: Added libfolder {0} ({1}) {2}", ret.Collection.FolderID, ret.Collection.OwnerID);
}
} }
} }
} }
@ -471,64 +460,97 @@ 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)
{ {
fetchFolders.Remove(zero); if (f.folder_id == UUID.Zero)
InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); {
zeroColl.Collection = new InventoryCollection(); InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents();
zeroColl.Collection.OwnerID = zero.owner_id; zeroColl.Collection = new InventoryCollection();
zeroColl.Collection.Version = 0; zeroColl.Collection.OwnerID = f.owner_id;
zeroColl.Collection.FolderID = zero.folder_id; zeroColl.Collection.Version = 0;
zeroColl.Descendents = 0; zeroColl.Collection.FolderID = f.folder_id;
result.Add(zeroColl); zeroColl.Descendents = 0;
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)
return null;
if (fetchedContents.Length == 0)
{ {
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 otherFolders)
foreach (LLSDFetchInventoryDescendents freq in fetchFolders)
BadFolder(freq, null, bad_folders); BadFolder(freq, null, bad_folders);
return null;
} }
else
i = 0;
// Do some post-processing. May need to fetch more from inv server for links
foreach (InventoryCollection contents in fetchedContents)
{ {
// Find the original request i = 0;
LLSDFetchInventoryDescendents freq = fetchFolders[i++]; // Do some post-processing. May need to fetch more from inv server for links
foreach (InventoryCollection contents in fetchedContents)
{
// Find the original request
LLSDFetchInventoryDescendents freq = otherFolders[i++];
InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents(); InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents();
coll.Collection = contents; coll.Collection = contents;
if (BadFolder(freq, contents, bad_folders)) if (BadFolder(freq, contents, bad_folders))
continue; continue;
// Next: link management // Next: link management
ProcessLinks(freq, coll); ProcessLinks(freq, coll);
result.Add(coll); result.Add(coll);
}
} }
} }
if(dolib && libFolders.Count > 0)
{
AddLibraryFolders(libFolders, result);
}
return result; return result;
} }