From d1fcd2217327579d21d4c5a33341d4e51c91a089 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 30 Apr 2010 19:28:44 +0100 Subject: Fix a null ref from trying to access a dictionary that was never initialized. --- .../CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 9c6e1cd..c97ab9e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -52,7 +52,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory protected Dictionary> m_InventoryCache; // A cache of userIDs --> ServiceURLs, for HGBroker only - protected Dictionary m_InventoryURLs; + protected Dictionary m_InventoryURLs = + new Dictionary(); public virtual void Init(IConfigSource source, BaseInventoryConnector connector) { -- cgit v1.1 From 5fda81e6bbb80cbe904e69638f5f405aca78f111 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 30 Apr 2010 11:39:02 -0700 Subject: * XInventory fairly tested, including for HG. Almost ready to switch. * Removed a few buglets and added better exception handling. --- .../Inventory/HGInventoryBroker2.cs | 212 ++++++++------------- .../Inventory/RemoteXInventoryServiceConnector.cs | 8 +- .../Presence/RemotePresenceServiceConnector.cs | 2 +- 3 files changed, 79 insertions(+), 143 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker2.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker2.cs index 3509161..fc3393f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker2.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker2.cs @@ -41,27 +41,22 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { - public class HGInventoryBroker2 : INonSharedRegionModule, IInventoryService + public class HGInventoryBroker2 : ISharedRegionModule, IInventoryService { private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private static bool m_Initialized = false; private static bool m_Enabled = false; private static IInventoryService m_LocalGridInventoryService; - private static ISessionAuthInventoryService m_HGService; // obsolete private Dictionary m_connectors = new Dictionary(); // A cache of userIDs --> ServiceURLs, for HGBroker only - protected Dictionary m_InventoryURLs; + protected Dictionary m_InventoryURLs = new Dictionary(); - private Scene m_Scene; private List m_Scenes = new List(); - private IUserAccountService m_UserAccountService; - public Type ReplaceableInterface { get { return null; } @@ -74,65 +69,45 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public void Initialise(IConfigSource source) { - if (!m_Initialized) + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) + string name = moduleConfig.GetString("InventoryServices", ""); + if (name == Name) { - string name = moduleConfig.GetString("InventoryServices", ""); - if (name == Name) + IConfig inventoryConfig = source.Configs["InventoryService"]; + if (inventoryConfig == null) { - IConfig inventoryConfig = source.Configs["InventoryService"]; - if (inventoryConfig == null) - { - m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); - return; - } - - string localDll = inventoryConfig.GetString("LocalGridInventoryService", - String.Empty); - string HGDll = inventoryConfig.GetString("HypergridInventoryService", - String.Empty); - - if (localDll == String.Empty) - { - m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService"); - //return; - throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); - } - - if (HGDll == String.Empty) - { - m_log.Error("[HG INVENTORY CONNECTOR]: No HypergridInventoryService named in section InventoryService"); - //return; - throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); - } + m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); + return; + } - Object[] args = new Object[] { source }; - m_LocalGridInventoryService = - ServerUtils.LoadPlugin(localDll, - args); + string localDll = inventoryConfig.GetString("LocalGridInventoryService", + String.Empty); + //string HGDll = inventoryConfig.GetString("HypergridInventoryService", + // String.Empty); - m_HGService = - ServerUtils.LoadPlugin(HGDll, - args); + if (localDll == String.Empty) + { + m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } - if (m_LocalGridInventoryService == null) - { - m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service"); - return; - } - if (m_HGService == null) - { - m_log.Error("[HG INVENTORY CONNECTOR]: Can't load hypergrid inventory service"); - return; - } + Object[] args = new Object[] { source }; + m_LocalGridInventoryService = + ServerUtils.LoadPlugin(localDll, + args); - m_Enabled = true; - m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled"); + if (m_LocalGridInventoryService == null) + { + m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service"); + return; } + + m_Enabled = true; + m_log.InfoFormat("[HG INVENTORY CONNECTOR]: HG inventory broker enabled with inner connector of type {0}", m_LocalGridInventoryService.GetType()); } - m_Initialized = true; } } @@ -149,13 +124,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (!m_Enabled) return; - m_Scene = scene; m_Scenes.Add(scene); - m_UserAccountService = m_Scene.UserAccountService; scene.RegisterModuleInterface(this); - scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; scene.EventManager.OnClientClosed += OnClientClosed; } @@ -177,13 +149,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } - #region Cache - - void OnMakeRootAgent(ScenePresence presence) - { - if (!m_InventoryURLs.ContainsKey(presence.UUID)) - CacheInventoryServiceURL(presence.Scene, presence.UUID); - } + #region URL Cache void OnClientClosed(UUID clientID, Scene scene) { @@ -200,10 +166,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return; } } - - m_log.DebugFormat( - "[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping inventory URL", - scene.RegionInfo.RegionName, clientID); DropInventoryServiceURL(clientID); } } @@ -213,35 +175,47 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// and sticks it in the cache /// /// - private void CacheInventoryServiceURL(Scene scene, UUID userID) + private void CacheInventoryServiceURL(UUID userID) { - if (scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID) == null) + if (m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, userID) == null) { // The user does not have a local account; let's cache its service URL string inventoryURL = string.Empty; ScenePresence sp = null; - scene.TryGetScenePresence(userID, out sp); - if (sp != null) + foreach (Scene scene in m_Scenes) { - AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); - if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) + scene.TryGetScenePresence(userID, out sp); + if (sp != null) { - inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); - if (inventoryURL != null && inventoryURL != string.Empty) + AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); + if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) { - inventoryURL = inventoryURL.Trim(new char[] { '/' }); - m_InventoryURLs.Add(userID, inventoryURL); + inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); + if (inventoryURL != null && inventoryURL != string.Empty) + { + inventoryURL = inventoryURL.Trim(new char[] { '/' }); + m_InventoryURLs.Add(userID, inventoryURL); + m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); + return; + } } } } } + + // else put a null; it means that the methods should forward to local grid's inventory + m_InventoryURLs.Add(userID, null); } private void DropInventoryServiceURL(UUID userID) { lock (m_InventoryURLs) if (m_InventoryURLs.ContainsKey(userID)) + { + string url = m_InventoryURLs[userID]; m_InventoryURLs.Remove(userID); + m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Removed {0} from the cache of inventory URLs", url); + } } public string GetInventoryServiceURL(UUID userID) @@ -249,7 +223,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (m_InventoryURLs.ContainsKey(userID)) return m_InventoryURLs[userID]; - return null; + else + CacheInventoryServiceURL(userID); + + return m_InventoryURLs[userID]; } #endregion @@ -276,7 +253,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public InventoryFolderBase GetRootFolder(UUID userID) { - m_log.DebugFormat("[HGInventory]: GetRootFolder for {0}", userID); + m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID); string invURL = GetInventoryServiceURL(userID); @@ -290,7 +267,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) { - m_log.DebugFormat("[HGInventory]: GetFolderForType {0} type {1}", userID, type); + m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type); string invURL = GetInventoryServiceURL(userID); @@ -304,7 +281,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public InventoryCollection GetFolderContent(UUID userID, UUID folderID) { - m_log.Debug("[HGInventory]: GetFolderContent " + folderID); + m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent " + folderID); string invURL = GetInventoryServiceURL(userID); @@ -319,7 +296,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public List GetFolderItems(UUID userID, UUID folderID) { - m_log.Debug("[HGInventory]: GetFolderItems " + folderID); + m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems " + folderID); string invURL = GetInventoryServiceURL(userID); @@ -337,7 +314,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return false; - m_log.Debug("[HGInventory]: AddFolder " + folder.ID); + m_log.Debug("[HG INVENTORY CONNECTOR]: AddFolder " + folder.ID); string invURL = GetInventoryServiceURL(folder.Owner); @@ -354,7 +331,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return false; - m_log.Debug("[HGInventory]: UpdateFolder " + folder.ID); + m_log.Debug("[HG INVENTORY CONNECTOR]: UpdateFolder " + folder.ID); string invURL = GetInventoryServiceURL(folder.Owner); @@ -373,7 +350,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folderIDs.Count == 0) return false; - m_log.Debug("[HGInventory]: DeleteFolders for " + ownerID); + m_log.Debug("[HG INVENTORY CONNECTOR]: DeleteFolders for " + ownerID); string invURL = GetInventoryServiceURL(ownerID); @@ -390,7 +367,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return false; - m_log.Debug("[HGInventory]: MoveFolder for " + folder.Owner); + m_log.Debug("[HG INVENTORY CONNECTOR]: MoveFolder for " + folder.Owner); string invURL = GetInventoryServiceURL(folder.Owner); @@ -407,7 +384,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return false; - m_log.Debug("[HGInventory]: PurgeFolder for " + folder.Owner); + m_log.Debug("[HG INVENTORY CONNECTOR]: PurgeFolder for " + folder.Owner); string invURL = GetInventoryServiceURL(folder.Owner); @@ -424,7 +401,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (item == null) return false; - m_log.Debug("[HGInventory]: AddItem " + item.ID); + m_log.Debug("[HG INVENTORY CONNECTOR]: AddItem " + item.ID); string invURL = GetInventoryServiceURL(item.Owner); @@ -441,7 +418,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (item == null) return false; - m_log.Debug("[HGInventory]: UpdateItem " + item.ID); + m_log.Debug("[HG INVENTORY CONNECTOR]: UpdateItem " + item.ID); string invURL = GetInventoryServiceURL(item.Owner); @@ -460,7 +437,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (items.Count == 0) return true; - m_log.Debug("[HGInventory]: MoveItems for " + ownerID); + m_log.Debug("[HG INVENTORY CONNECTOR]: MoveItems for " + ownerID); string invURL = GetInventoryServiceURL(ownerID); @@ -481,7 +458,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (itemIDs.Count == 0) return true; - m_log.Debug("[HGInventory]: DeleteItems for " + ownerID); + m_log.Debug("[HG INVENTORY CONNECTOR]: DeleteItems for " + ownerID); string invURL = GetInventoryServiceURL(ownerID); @@ -497,7 +474,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { if (item == null) return null; - m_log.Debug("[HGInventory]: GetItem " + item.ID); + m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID); string invURL = GetInventoryServiceURL(item.Owner); @@ -514,7 +491,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return null; - m_log.Debug("[HGInventory]: GetFolder " + folder.ID); + m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolder " + folder.ID); string invURL = GetInventoryServiceURL(folder.Owner); @@ -538,7 +515,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public int GetAssetPermissions(UUID userID, UUID assetID) { - m_log.Debug("[HGInventory]: GetAssetPermissions " + assetID); + m_log.Debug("[HG INVENTORY CONNECTOR]: GetAssetPermissions " + assetID); string invURL = GetInventoryServiceURL(userID); @@ -575,44 +552,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return connector; } - - private UUID GetSessionID(UUID userID) - { - ScenePresence sp = null; - if (m_Scene.TryGetScenePresence(userID, out sp)) - { - return sp.ControllingClient.SessionId; - } - - m_log.DebugFormat("[HG INVENTORY CONNECTOR]: scene presence for {0} not found", userID); - return UUID.Zero; - } - - private bool IsForeignUser(UUID userID, out string inventoryURL) - { - inventoryURL = string.Empty; - UserAccount account = null; - if (m_Scene.UserAccountService != null) - account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); - - if (account == null) // foreign user - { - ScenePresence sp = null; - m_Scene.TryGetScenePresence(userID, out sp); - if (sp != null) - { - AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); - if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) - { - inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); - inventoryURL = inventoryURL.Trim(new char[] { '/' }); - return true; - } - } - } - return false; - } - - } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index ac9e792..277060d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs @@ -172,11 +172,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.GetFolderForType(userID, type); } - public Dictionary GetSystemFolders(UUID userID) - { - return m_RemoteConnector.GetSystemFolders(userID); - } - public InventoryCollection GetFolderContent(UUID userID, UUID folderID) { return m_RemoteConnector.GetFolderContent(userID, folderID); @@ -267,9 +262,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public InventoryItemBase GetItem(InventoryItemBase item) { + m_log.DebugFormat("[XINVENTORY CONNECTOR]: GetItem {0}", item.ID); if (item == null) return null; + if (m_RemoteConnector == null) + m_log.DebugFormat("[XINVENTORY CONNECTOR]: connector stub is null!!!"); return m_RemoteConnector.GetItem(item); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index 865f99e..5f3666e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence m_PresenceDetector = new PresenceDetector(this); - m_log.Info("[INVENTORY CONNECTOR]: Remote presence enabled"); + m_log.Info("[REMOTE PRESENCE CONNECTOR]: Remote presence enabled"); } } -- cgit v1.1