From d05c443b71603a22f5b5d767fb3026617d04e9f5 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Tue, 29 Apr 2008 18:46:15 +0000
Subject: * Made a change to InterGrid module to prevent duplicate
 registrations.

---
 .../Interregion/IInterregionModule.cs               |  1 +
 .../Communications/Interregion/InterregionModule.cs | 21 +++++++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/OpenSim/Region/Environment/Modules/Communications/Interregion/IInterregionModule.cs b/OpenSim/Region/Environment/Modules/Communications/Interregion/IInterregionModule.cs
index c15738c..713b46a 100644
--- a/OpenSim/Region/Environment/Modules/Communications/Interregion/IInterregionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/Interregion/IInterregionModule.cs
@@ -10,5 +10,6 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
         T RequestInterface<T>(Location loc);
         T[] RequestInterface<T>();
         Location GetLocationByDirection(Scene scene, InterregionModule.Direction dir);
+        void internal_CreateRemotingObjects();
     }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Communications/Interregion/InterregionModule.cs b/OpenSim/Region/Environment/Modules/Communications/Interregion/InterregionModule.cs
index 858f099..685aed9 100644
--- a/OpenSim/Region/Environment/Modules/Communications/Interregion/InterregionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/Interregion/InterregionModule.cs
@@ -41,6 +41,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
 
         #region IRegionModule Members
 
+        //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
         public void Initialise(Scene scene, IConfigSource source)
         {
             m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX,
@@ -61,7 +62,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
             {
             }
 
-            CreateRemotingObjects();
+            internal_CreateRemotingObjects();
         }
 
         public void Close()
@@ -81,13 +82,19 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
 
         #endregion
 
-        private void CreateRemotingObjects()
+        public void internal_CreateRemotingObjects()
         {
-            m_myRemote = new RemotingObject(m_interfaces, m_myLocations.ToArray());
-            m_tcpChannel = new TcpChannel(m_tcpPort);
+            lock (m_tcpChannel)
+            {
+                if (m_tcpChannel == null)
+                {
+                    m_myRemote = new RemotingObject(m_interfaces, m_myLocations.ToArray());
+                    m_tcpChannel = new TcpChannel(m_tcpPort);
 
-            ChannelServices.RegisterChannel(m_tcpChannel, false);
-            RemotingServices.Marshal(m_myRemote, "OpenSimRemote2", typeof (RemotingObject));
+                    ChannelServices.RegisterChannel(m_tcpChannel, false);
+                    RemotingServices.Marshal(m_myRemote, "OpenSimRemote2", typeof (RemotingObject));
+                }
+            }
         }
 
         public void RegisterRemoteRegion(string uri)
@@ -155,7 +162,5 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
         {
             return new Location(0, 0);
         }
-
-        //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
     }
 }
\ No newline at end of file
-- 
cgit v1.1