diff --git a/OpenSim/Grid/GridServer/GridMessagingModule.cs b/OpenSim/Grid/GridServer/GridMessagingModule.cs index 16623e7df3..14ce72706f 100644 --- a/OpenSim/Grid/GridServer/GridMessagingModule.cs +++ b/OpenSim/Grid/GridServer/GridMessagingModule.cs @@ -37,7 +37,7 @@ using OpenSim.Framework; namespace OpenSim.Grid.GridServer { - public class GridMessagingModule : IGridMessagingModule + public class GridMessagingModule : IGridMessagingMapper { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -54,12 +54,7 @@ namespace OpenSim.Grid.GridServer protected BaseHttpServer m_httpServer; // This is here so that the grid server can hand out MessageServer settings to regions on registration - private List _MessageServers = new List(); - - public List MessageServers - { - get { return _MessageServers; } - } + private List m_messageServers = new List(); public GridMessagingModule() { @@ -72,7 +67,7 @@ namespace OpenSim.Grid.GridServer m_gridCore = gridCore; m_config = config; - m_gridCore.RegisterInterface(this); + m_gridCore.RegisterInterface(this); RegisterHandlers(); } @@ -92,6 +87,14 @@ namespace OpenSim.Grid.GridServer m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); } + public List GetMessageServersList() + { + lock (m_messageServers) + { + return new List(m_messageServers); + } + } + public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); @@ -107,8 +110,7 @@ namespace OpenSim.Grid.GridServer m.URI = URI; m.sendkey = sendkey; m.recvkey = recvkey; - if (!_MessageServers.Contains(m)) - _MessageServers.Add(m); + RegisterMessageServer(m); responseData["responsestring"] = "TRUE"; response.Value = responseData; } @@ -130,12 +132,29 @@ namespace OpenSim.Grid.GridServer m.URI = URI; m.sendkey = sendkey; m.recvkey = recvkey; - if (_MessageServers.Contains(m)) - _MessageServers.Remove(m); + DeRegisterMessageServer(m); responseData["responsestring"] = "TRUE"; response.Value = responseData; } return response; } + + public void RegisterMessageServer(MessageServerInfo m) + { + lock (m_messageServers) + { + if (!m_messageServers.Contains(m)) + m_messageServers.Add(m); + } + } + + public void DeRegisterMessageServer(MessageServerInfo m) + { + lock (m_messageServers) + { + if (m_messageServers.Contains(m)) + m_messageServers.Remove(m); + } + } } } diff --git a/OpenSim/Grid/GridServer/GridXmlRpcModule.cs b/OpenSim/Grid/GridServer/GridXmlRpcModule.cs index 874b57f72e..e0e16b598c 100644 --- a/OpenSim/Grid/GridServer/GridXmlRpcModule.cs +++ b/OpenSim/Grid/GridServer/GridXmlRpcModule.cs @@ -50,7 +50,7 @@ namespace OpenSim.Grid.GridServer protected GridConfig m_config; - protected IGridMessagingModule m_messagingServerMapper; + protected IGridMessagingMapper m_messagingServerMapper; /// /// Used to notify old regions as to which OpenSim version to upgrade to /// @@ -79,8 +79,8 @@ namespace OpenSim.Grid.GridServer public void PostInitialise() { - IGridMessagingModule messagingModule; - if (m_gridCore.TryGet(out messagingModule)) + IGridMessagingMapper messagingModule; + if (m_gridCore.TryGet(out messagingModule)) { m_messagingServerMapper = messagingModule; } @@ -401,7 +401,7 @@ namespace OpenSim.Grid.GridServer //{ if(m_messagingServerMapper != null) { - List messageServers = m_messagingServerMapper.MessageServers; + List messageServers = m_messagingServerMapper.GetMessageServersList(); responseData["messageserver_count"] = messageServers.Count; for (int i = 0; i < messageServers.Count; i++) diff --git a/OpenSim/Grid/GridServer/IGridMessagingModule.cs b/OpenSim/Grid/GridServer/IGridMessagingMapper.cs similarity index 87% rename from OpenSim/Grid/GridServer/IGridMessagingModule.cs rename to OpenSim/Grid/GridServer/IGridMessagingMapper.cs index 7e37f586aa..0183ad558f 100644 --- a/OpenSim/Grid/GridServer/IGridMessagingModule.cs +++ b/OpenSim/Grid/GridServer/IGridMessagingMapper.cs @@ -1,38 +1,40 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using OpenSim.Framework.Servers; - -namespace OpenSim.Grid.GridServer -{ - public interface IGridMessagingModule - { - List MessageServers { get; } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenSim.Framework.Servers; + +namespace OpenSim.Grid.GridServer +{ + public interface IGridMessagingMapper + { + List GetMessageServersList(); + void RegisterMessageServer(MessageServerInfo m); + void DeRegisterMessageServer(MessageServerInfo m); + } +}