aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs64
1 files changed, 47 insertions, 17 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 305f8a4..b9526da 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -35,7 +35,6 @@ using OpenMetaverse.StructuredData;
35using log4net; 35using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Client; 37using OpenSim.Framework.Client;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Capabilities; 38using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
@@ -52,6 +51,7 @@ namespace OpenSim.Region.Framework.Scenes
52 public class SceneCommunicationService //one instance per region 51 public class SceneCommunicationService //one instance per region
53 { 52 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 private static string LogHeader = "[SCENE COMMUNICATION SERVICE]";
55 55
56 protected RegionInfo m_regionInfo; 56 protected RegionInfo m_regionInfo;
57 protected Scene m_scene; 57 protected Scene m_scene;
@@ -84,15 +84,12 @@ namespace OpenSim.Region.Framework.Scenes
84 if (neighbourService != null) 84 if (neighbourService != null)
85 neighbour = neighbourService.HelloNeighbour(regionhandle, region); 85 neighbour = neighbourService.HelloNeighbour(regionhandle, region);
86 else 86 else
87 m_log.DebugFormat( 87 m_log.DebugFormat( "{0} neighbour service provided for region {0} to inform neigbhours of status", LogHeader, m_scene.Name);
88 "[SCENE COMMUNICATION SERVICE]: No neighbour service provided for region {0} to inform neigbhours of status",
89 m_scene.Name);
90 88
91 if (neighbour != null) 89 if (neighbour != null)
92 { 90 {
93 m_log.DebugFormat( 91 m_log.DebugFormat( "{0} Region {1} successfully informed neighbour {2} at {3}-{4} that it is up",
94 "[SCENE COMMUNICATION SERVICE]: Region {0} successfully informed neighbour {1} at {2}-{3} that it is up", 92 LogHeader, m_scene.Name, neighbour.RegionName, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
95 m_scene.Name, neighbour.RegionName, x / Constants.RegionSize, y / Constants.RegionSize);
96 93
97 m_scene.EventManager.TriggerOnRegionUp(neighbour); 94 m_scene.EventManager.TriggerOnRegionUp(neighbour);
98 } 95 }
@@ -100,7 +97,7 @@ namespace OpenSim.Region.Framework.Scenes
100 { 97 {
101 m_log.WarnFormat( 98 m_log.WarnFormat(
102 "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.", 99 "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.",
103 m_scene.Name, x / Constants.RegionSize, y / Constants.RegionSize); 100 m_scene.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
104 } 101 }
105 } 102 }
106 103
@@ -111,12 +108,35 @@ namespace OpenSim.Region.Framework.Scenes
111 List<GridRegion> neighbours 108 List<GridRegion> neighbours
112 = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); 109 = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);
113 110
114 m_log.DebugFormat( 111 List<GridRegion> onlineNeighbours = new List<GridRegion>();
115 "[SCENE COMMUNICATION SERVICE]: Informing {0} neighbours that region {1} is up",
116 neighbours.Count, m_scene.Name);
117 112
118 foreach (GridRegion n in neighbours) 113 foreach (GridRegion n in neighbours)
119 { 114 {
115 OpenSim.Framework.RegionFlags? regionFlags = n.RegionFlags;
116
117// m_log.DebugFormat(
118// "{0}: Region flags for {1} as seen by {2} are {3}",
119// LogHeader, n.RegionName, m_scene.Name, regionFlags != null ? regionFlags.ToString() : "not present");
120
121 // Robust services before 2015-01-14 do not return the regionFlags information. In this case, we could
122 // make a separate RegionFlags call but this would involve a network call for each neighbour.
123 if (regionFlags != null)
124 {
125 if ((regionFlags & OpenSim.Framework.RegionFlags.RegionOnline) != 0)
126 onlineNeighbours.Add(n);
127 }
128 else
129 {
130 onlineNeighbours.Add(n);
131 }
132 }
133
134 m_log.DebugFormat(
135 "{0} Informing {1} neighbours that region {2} is up",
136 LogHeader, onlineNeighbours.Count, m_scene.Name);
137
138 foreach (GridRegion n in onlineNeighbours)
139 {
120 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; 140 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
121 d.BeginInvoke(neighbourService, region, n.RegionHandle, 141 d.BeginInvoke(neighbourService, region, n.RegionHandle,
122 InformNeighborsThatRegionisUpCompleted, 142 InformNeighborsThatRegionisUpCompleted,
@@ -154,6 +174,10 @@ namespace OpenSim.Region.Framework.Scenes
154 174
155 public void SendChildAgentDataUpdate(AgentPosition cAgentData, ScenePresence presence) 175 public void SendChildAgentDataUpdate(AgentPosition cAgentData, ScenePresence presence)
156 { 176 {
177// m_log.DebugFormat(
178// "[SCENE COMMUNICATION SERVICE]: Sending child agent position updates for {0} in {1}",
179// presence.Name, m_scene.Name);
180
157 // This assumes that we know what our neighbors are. 181 // This assumes that we know what our neighbors are.
158 try 182 try
159 { 183 {
@@ -166,7 +190,7 @@ namespace OpenSim.Region.Framework.Scenes
166 // we only want to send one update to each simulator; the simulator will 190 // we only want to send one update to each simulator; the simulator will
167 // hand it off to the regions where a child agent exists, this does assume 191 // hand it off to the regions where a child agent exists, this does assume
168 // that the region position is cached or performance will degrade 192 // that the region position is cached or performance will degrade
169 Utils.LongToUInts(regionHandle, out x, out y); 193 Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
170 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); 194 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
171 if (dest == null) 195 if (dest == null)
172 continue; 196 continue;
@@ -197,20 +221,20 @@ namespace OpenSim.Region.Framework.Scenes
197 /// <summary> 221 /// <summary>
198 /// Closes a child agent on a given region 222 /// Closes a child agent on a given region
199 /// </summary> 223 /// </summary>
200 protected void SendCloseChildAgent(UUID agentID, ulong regionHandle) 224 protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token)
201 { 225 {
202 // let's do our best, but there's not much we can do if the neighbour doesn't accept. 226 // let's do our best, but there's not much we can do if the neighbour doesn't accept.
203 227
204 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 228 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
205 uint x = 0, y = 0; 229 uint x = 0, y = 0;
206 Utils.LongToUInts(regionHandle, out x, out y); 230 Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
207 231
208 GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); 232 GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y);
209 233
210 m_log.DebugFormat( 234 m_log.DebugFormat(
211 "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName); 235 "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName);
212 236
213 m_scene.SimulationService.CloseAgent(destination, agentID); 237 m_scene.SimulationService.CloseAgent(destination, agentID, auth_token);
214 } 238 }
215 239
216 /// <summary> 240 /// <summary>
@@ -219,11 +243,17 @@ namespace OpenSim.Region.Framework.Scenes
219 /// </summary> 243 /// </summary>
220 /// <param name="agentID"></param> 244 /// <param name="agentID"></param>
221 /// <param name="regionslst"></param> 245 /// <param name="regionslst"></param>
222 public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) 246 public void SendCloseChildAgentConnections(UUID agentID, string auth_code, List<ulong> regionslst)
223 { 247 {
224 foreach (ulong handle in regionslst) 248 foreach (ulong handle in regionslst)
225 { 249 {
226 SendCloseChildAgent(agentID, handle); 250 // We must take a copy here since handle is acts like a reference when used in an iterator.
251 // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region.
252 ulong handleCopy = handle;
253 Util.FireAndForget(
254 o => SendCloseChildAgent(agentID, handleCopy, auth_code),
255 null,
256 "SceneCommunicationService.SendCloseChildAgentConnections");
227 } 257 }
228 } 258 }
229 259