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.
remove-scene-viewer
Justin Clark-Casey (justincc) 2011-09-07 23:16:19 +01:00
parent d7a516d885
commit 7cadb89a0f
3 changed files with 41 additions and 21 deletions

View File

@ -148,8 +148,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
scene.RegisterModuleInterface<IInventoryService>(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;
}
}
}
}

View File

@ -47,9 +47,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private IInventoryService m_InventoryService;
/// <summary>
/// Scene used by this module. This currently needs to be publicly settable for HGInventoryBroker.
/// </summary>
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<IUserManagement>();
m_UserManager = Scene.RequestModuleInterface<IUserManagement>();
}
return m_UserManager;
}
@ -131,8 +134,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
scene.RegisterModuleInterface<IInventoryService>(this);
if (m_Scene == null)
m_Scene = scene;
if (Scene == null)
Scene = scene;
}
public void RemoveRegion(Scene scene)

View File

@ -45,6 +45,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Scene used by this module. This currently needs to be publicly settable for HGInventoryBroker.
/// </summary>
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<IUserManagement>();
m_UserManager = Scene.RequestModuleInterface<IUserManagement>();
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<IInventoryService>(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)