remove a lock on hginventorybroker; cosmetics

This commit is contained in:
UbitUmarov
2022-11-10 09:44:36 +00:00
parent 3f0fcbf3c6
commit 4cac42ab98
3 changed files with 82 additions and 113 deletions

View File

@@ -68,8 +68,8 @@ namespace OpenSim.Capabilities.Handlers
{
//m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request);
List<LLSDFetchInventoryDescendents> folders = null;
List<UUID> bad_folders = new List<UUID>();
List<LLSDFetchInventoryDescendents> folders;
List<UUID> bad_folders = new();
try
{
OSDArray foldersrequested = null;
@@ -97,7 +97,7 @@ namespace OpenSim.Capabilities.Handlers
}
else
{
LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();
LLSDFetchInventoryDescendents llsdRequest = new();
try
{
llsdRequest.folder_id = id;
@@ -115,12 +115,11 @@ namespace OpenSim.Capabilities.Handlers
}
}
foldersrequested = null;
map.Clear();
map = null;
}
catch (Exception e)
{
m_log.ErrorFormat("[FETCH INV DESC]: fail parsing request: {0}", e.Message);
m_log.Error("[FETCH INV DESC]: fail parsing request: " + e.Message);
httpResponse.RawBuffer = EmptyResponse;
return;
}
@@ -175,7 +174,7 @@ namespace OpenSim.Capabilities.Handlers
//m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count);
int invcollSetCount = 0;
if (invcollSet != null)
if (invcollSet is not null)
invcollSetCount = invcollSet.Count;
osUTF8 lastresponse = LLSDxmlEncode2.Start();
@@ -197,7 +196,7 @@ namespace OpenSim.Capabilities.Handlers
LLSDxmlEncode2.AddElem("descendents", thiscoll.Descendents, lastresponse);
LLSDxmlEncode2.AddElem_version(thiscoll.Version, lastresponse);
if (thiscoll.Folders == null || thiscoll.Folders.Count == 0)
if (thiscoll.Folders is null || thiscoll.Folders.Count == 0)
LLSDxmlEncode2.AddEmptyArray("categories", lastresponse);
else
{
@@ -217,7 +216,7 @@ namespace OpenSim.Capabilities.Handlers
LLSDxmlEncode2.AddEndArray(lastresponse);
}
if (thiscoll.Items == null || thiscoll.Items.Count == 0)
if (thiscoll.Items is null || thiscoll.Items.Count == 0)
LLSDxmlEncode2.AddEmptyArray("items", lastresponse);
else
{
@@ -283,8 +282,8 @@ namespace OpenSim.Capabilities.Handlers
{
if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) is not null)
{
InventoryCollection Collection = new InventoryCollection();
// ret.Collection.Folders = new List<InventoryFolderBase>();
InventoryCollection Collection = new();
//ret.Collection.Folders = new List<InventoryFolderBase>();
Collection.Folders = fold.RequestListOfFolders();
Collection.Items = fold.RequestListOfItems();
Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner;
@@ -306,11 +305,11 @@ namespace OpenSim.Capabilities.Handlers
// FIXME MAYBE: We're not handling sortOrder!
List<InventoryCollection> result = new List<InventoryCollection>(32);
List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>(32);
List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>(32);
HashSet<UUID> libIDs = new HashSet<UUID>();
HashSet<UUID> otherIDs = new HashSet<UUID>();
List<InventoryCollection> result = new(32);
List<LLSDFetchInventoryDescendents> libFolders = new(32);
List<LLSDFetchInventoryDescendents> otherFolders = new(32);
HashSet<UUID> libIDs = new();
HashSet<UUID> otherIDs = new();
bool dolib = m_LibraryService != null;
@@ -401,7 +400,7 @@ namespace OpenSim.Capabilities.Handlers
private bool BadFolder(LLSDFetchInventoryDescendents freq, InventoryCollection contents, List<UUID> bad_folders)
{
if (contents == null)
if (contents is null)
{
bad_folders.Add(freq.folder_id);
return true;
@@ -433,7 +432,7 @@ namespace OpenSim.Capabilities.Handlers
// viewers are lasy and want a copy of the linked item sent before the link to it
// look for item links
List<UUID> itemIDs = new List<UUID>();
List<UUID> itemIDs = new();
foreach (InventoryItemBase item in contents.Items)
{
//m_log.DebugFormat("[XXX]: {0} {1}", item.Name, item.AssetType);

View File

@@ -101,7 +101,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
IConfig moduleConfig = source.Configs["Modules"];
if (moduleConfig != null)
{
string name = moduleConfig.GetString("InventoryServices", "");
string name = moduleConfig.GetString("InventoryServices", string.Empty);
if (name == Name)
{
IConfig inventoryConfig = source.Configs["InventoryService"];
@@ -111,8 +111,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return;
}
string localDll = inventoryConfig.GetString("LocalGridInventoryService",
String.Empty);
string localDll = inventoryConfig.GetString("LocalGridInventoryService", string.Empty);
if (localDll.Length == 0)
{
@@ -121,10 +120,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
}
Object[] args = new Object[] { source };
m_LocalGridInventoryService =
ServerUtils.LoadPlugin<IInventoryService>(localDll,
args);
ServerUtils.LoadPlugin<IInventoryService>(localDll, new object[] { source });
if (m_LocalGridInventoryService == null)
{
@@ -211,7 +208,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
}
}
m_InventoryURLs.TryRemove(clientID, out string dummy);
m_InventoryURLs.TryRemove(clientID, out string _);
m_Cache.RemoveAll(clientID);
}
@@ -225,45 +222,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID))
{
// The user is not local; let's cache its service URL
string inventoryURL = string.Empty;
string inventoryURL;
ScenePresence sp = null;
foreach (Scene scene in m_Scenes)
{
scene.TryGetScenePresence(userID, out sp);
if (sp != null)
if(scene.TryGetScenePresence(userID, out sp))
{
AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
if (aCircuit == null)
if (aCircuit is null)
return null;
if (aCircuit.ServiceURLs == null)
if (aCircuit.ServiceURLs is null)
return null;
if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI"))
if (aCircuit.ServiceURLs.TryGetValue("InventoryServerURI", out object otmp))
{
inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString();
if (inventoryURL != null && inventoryURL != string.Empty)
inventoryURL = otmp.ToString();
if (!string.IsNullOrEmpty(inventoryURL))
{
inventoryURL = inventoryURL.Trim(new char[] { '/' });
inventoryURL = inventoryURL.Trim('/');
m_InventoryURLs[userID] = inventoryURL;
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
//m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
return inventoryURL;
}
}
// else
// {
// m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID);
// return;
// }
}
}
if (sp == null)
if (sp is null)
{
inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI");
if (!string.IsNullOrEmpty(inventoryURL))
{
inventoryURL = inventoryURL.Trim(new char[] { '/' });
inventoryURL = inventoryURL.Trim('/');
m_InventoryURLs[userID] = inventoryURL;
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
//m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
return inventoryURL;
}
}
@@ -285,15 +276,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
public bool CreateUserInventory(UUID userID)
{
lock (m_Lock)
return m_LocalGridInventoryService.CreateUserInventory(userID);
return m_LocalGridInventoryService.CreateUserInventory(userID);
}
public List<InventoryFolderBase> GetInventorySkeleton(UUID userID)
{
string invURL = GetInventoryServiceURL(userID);
if (invURL == null) // not there, forward to local inventory connector to resolve
if (invURL is null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetInventorySkeleton(userID);
@@ -306,14 +296,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
//m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID);
InventoryFolderBase root = m_Cache.GetRootFolder(userID);
if (root != null)
if (root is not null)
return root;
string invURL = GetInventoryServiceURL(userID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetRootFolder(userID);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.GetRootFolder(userID);
IInventoryService connector = GetConnector(invURL);
@@ -332,10 +320,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return f;
string invURL = GetInventoryServiceURL(userID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetFolderForType(userID, type);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.GetFolderForType(userID, type);
IInventoryService connector = GetConnector(invURL);
@@ -352,9 +338,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(userID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetFolderContent(userID, folderID);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.GetFolderContent(userID, folderID);
InventoryCollection c = m_Cache.GetFolderContent(userID, folderID);
if (c != null)
@@ -372,19 +357,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
string invURL = GetInventoryServiceURL(userID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetMultipleFoldersContent(userID, folderIDs);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.GetMultipleFoldersContent(userID, folderIDs);
else
{
InventoryCollection[] coll = new InventoryCollection[folderIDs.Length];
int i = 0;
foreach (UUID fid in folderIDs)
coll[i++] = GetFolderContent(userID, fid);
InventoryCollection[] coll = new InventoryCollection[folderIDs.Length];
int i = 0;
foreach (UUID fid in folderIDs)
coll[i++] = GetFolderContent(userID, fid);
return coll;
}
return coll;
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
@@ -393,9 +374,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(userID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetFolderItems(userID, folderID);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.GetFolderItems(userID, folderID);
List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID);
if (items != null)
@@ -418,9 +398,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(folder.Owner);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.AddFolder(folder);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.AddFolder(folder);
IInventoryService connector = GetConnector(invURL);
@@ -436,9 +415,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(folder.Owner);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.UpdateFolder(folder);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.UpdateFolder(folder);
IInventoryService connector = GetConnector(invURL);
@@ -456,9 +434,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(ownerID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.DeleteFolders(ownerID, folderIDs);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.DeleteFolders(ownerID, folderIDs);
IInventoryService connector = GetConnector(invURL);
@@ -474,9 +451,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(folder.Owner);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.MoveFolder(folder);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.MoveFolder(folder);
IInventoryService connector = GetConnector(invURL);
@@ -492,9 +468,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(folder.Owner);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.PurgeFolder(folder);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.PurgeFolder(folder);
IInventoryService connector = GetConnector(invURL);
@@ -510,9 +485,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(item.Owner);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.AddItem(item);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.AddItem(item);
IInventoryService connector = GetConnector(invURL);
@@ -528,9 +502,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(item.Owner);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.UpdateItem(item);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.UpdateItem(item);
IInventoryService connector = GetConnector(invURL);
@@ -548,9 +521,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(ownerID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.MoveItems(ownerID, items);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.MoveItems(ownerID, items);
IInventoryService connector = GetConnector(invURL);
@@ -568,9 +540,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(ownerID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.DeleteItems(ownerID, itemIDs);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.DeleteItems(ownerID, itemIDs);
IInventoryService connector = GetConnector(invURL);
@@ -583,9 +554,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(principalID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetItem(principalID, itemID);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.GetItem(principalID, itemID);
IInventoryService connector = GetConnector(invURL);
@@ -594,18 +564,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs)
{
if (itemIDs == null)
return new InventoryItemBase[0];
//m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID);
if (itemIDs is null || itemIDs.Length == 0)
return Array.Empty<InventoryItemBase>();
//m_log.Debug("[HG INVENTORY CONNECTOR]: GetMultipleItems " + item.ID);
string invURL = GetInventoryServiceURL(userID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetMultipleItems(userID, itemIDs);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.GetMultipleItems(userID, itemIDs);
IInventoryService connector = GetConnector(invURL);
if (connector is null)
return Array.Empty<InventoryItemBase>();
return connector.GetMultipleItems(userID, itemIDs);
}
@@ -615,9 +586,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
string invURL = GetInventoryServiceURL(principalID);
if (invURL == null) // not there, forward to local inventory connector to resolve
lock (m_Lock)
return m_LocalGridInventoryService.GetFolder(principalID, folderID);
if (invURL is null) // not there, forward to local inventory connector to resolve
return m_LocalGridInventoryService.GetFolder(principalID, folderID);
IInventoryService connector = GetConnector(invURL);

View File

@@ -507,8 +507,8 @@ namespace OpenSim.Server.Handlers.Inventory
{
List<string> idlist = (List<string>)request["IDLIST"];
List<string> destlist = (List<string>)request["DESTLIST"];
UUID principal = UUID.Zero;
UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
UUID.TryParse(request["PRINCIPAL"].ToString(), out UUID principal);
List<InventoryItemBase> items = new List<InventoryItemBase>();
int n = 0;