From 7cadb89a0f5a298beda619c395c0810ca198a718 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 7 Sep 2011 23:16:19 +0100 Subject: When a region is added to the HG Inventory Broker, also pass this through to the embedded local inventory connector to prevent an NRE when that connector tries to lookup the UserManager through the scene. This is to address http://opensimulator.org/mantis/view.php?id=5669 However, if this failure was happening I'm kind of surprised that local HG inventory was working at all..... We probably weren't seeing these exceptions previously because we weren't logging them when the reached the top of a FireAndForget thread. --- .../Inventory/HGInventoryBroker.cs | 27 +++++++++++++++++++--- .../Inventory/LocalInventoryServiceConnector.cs | 13 +++++++---- .../Inventory/RemoteXInventoryServiceConnector.cs | 22 ++++++++---------- 3 files changed, 41 insertions(+), 21 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index d9d7318..0d121ed 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -148,8 +148,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory scene.RegisterModuleInterface(this); - scene.EventManager.OnClientClosed += OnClientClosed; + if (m_Scenes.Count == 1) + { + // FIXME: The local connector needs the scene to extract the UserManager. However, it's not enabled so + // we can't just add the region. But this approach is super-messy. + if (m_LocalGridInventoryService is RemoteXInventoryServicesConnector) + { + m_log.DebugFormat( + "[HG INVENTORY BROKER]: Manually setting scene in RemoteXInventoryServicesConnector to {0}", + scene.RegionInfo.RegionName); + + ((RemoteXInventoryServicesConnector)m_LocalGridInventoryService).Scene = scene; + } + else if (m_LocalGridInventoryService is LocalInventoryServicesConnector) + { + m_log.DebugFormat( + "[HG INVENTORY BROKER]: Manually setting scene in LocalInventoryServicesConnector to {0}", + scene.RegionInfo.RegionName); + + ((LocalInventoryServicesConnector)m_LocalGridInventoryService).Scene = scene; + } + scene.EventManager.OnClientClosed += OnClientClosed; + } } public void RemoveRegion(Scene scene) @@ -586,7 +607,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory else { RemoteXInventoryServicesConnector rxisc = new RemoteXInventoryServicesConnector(url); - rxisc.UserManager = UserManagementModule; + rxisc.Scene = m_Scenes[0]; connector = rxisc; } @@ -597,4 +618,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return connector; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 65e39c0..d3ef08d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -47,9 +47,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private IInventoryService m_InventoryService; + /// + /// Scene used by this module. This currently needs to be publicly settable for HGInventoryBroker. + /// + public Scene Scene { get; set; } - private Scene m_Scene; + private IInventoryService m_InventoryService; private IUserManagement m_UserManager; private IUserManagement UserManager @@ -58,7 +61,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { if (m_UserManager == null) { - m_UserManager = m_Scene.RequestModuleInterface(); + m_UserManager = Scene.RequestModuleInterface(); } return m_UserManager; } @@ -131,8 +134,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory scene.RegisterModuleInterface(this); - if (m_Scene == null) - m_Scene = scene; + if (Scene == null) + Scene = scene; } public void RemoveRegion(Scene scene) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index 97fdd4e..eb90774 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs @@ -45,6 +45,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Scene used by this module. This currently needs to be publicly settable for HGInventoryBroker. + /// + public Scene Scene { get; set; } + private bool m_Enabled = false; private Scene m_Scene; private XInventoryServicesConnector m_RemoteConnector; @@ -56,24 +61,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { if (m_UserManager == null) { - m_UserManager = m_Scene.RequestModuleInterface(); + m_UserManager = Scene.RequestModuleInterface(); if (m_UserManager == null) m_log.ErrorFormat( "[XINVENTORY CONNECTOR]: Could not retrieve IUserManagement module from {0}", - m_Scene.RegionInfo.RegionName); + Scene.RegionInfo.RegionName); } return m_UserManager; } - - set - { - m_log.WarnFormat( - "[XINVENTORY CONNECTOR]: Manually setting UserManager {0} (scene {1})", value, m_Scene); - - m_UserManager = value; - } } public Type ReplaceableInterface @@ -141,15 +138,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory scene.RegisterModuleInterface(this); - if (m_Scene == null) - m_Scene = scene; + if (Scene == null) + Scene = scene; } public void RemoveRegion(Scene scene) { if (!m_Enabled) return; - } public void RegionLoaded(Scene scene) -- cgit v1.1