From b9137e2deeb5d207c3f8d39596a666217a642b0e Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 15 Sep 2015 22:30:39 +0100
Subject: avoid a null ref (that should not happen after last commit), also
reduce use of thread jobs, where one is good enought
---
.../Framework/Scenes/SceneCommunicationService.cs | 48 +++++++++++++---------
1 file changed, 28 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs')
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 28df1c1..3eefd3c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes
private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
{
- InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState;
+ InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate)iar.AsyncState;
icon.EndInvoke(iar);
}
@@ -84,11 +84,11 @@ namespace OpenSim.Region.Framework.Scenes
if (neighbourService != null)
neighbour = neighbourService.HelloNeighbour(regionhandle, region);
else
- m_log.DebugFormat( "{0} neighbour service provided for region {0} to inform neigbhours of status", LogHeader, m_scene.Name);
+ m_log.DebugFormat("{0} neighbour service provided for region {0} to inform neigbhours of status", LogHeader, m_scene.Name);
if (neighbour != null)
{
- m_log.DebugFormat( "{0} Region {1} successfully informed neighbour {2} at {3}-{4} that it is up",
+ m_log.DebugFormat("{0} Region {1} successfully informed neighbour {2} at {3}-{4} that it is up",
LogHeader, m_scene.Name, neighbour.RegionName, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
m_scene.EventManager.TriggerOnRegionUp(neighbour);
@@ -114,9 +114,9 @@ namespace OpenSim.Region.Framework.Scenes
{
OpenSim.Framework.RegionFlags? regionFlags = n.RegionFlags;
-// m_log.DebugFormat(
-// "{0}: Region flags for {1} as seen by {2} are {3}",
-// LogHeader, n.RegionName, m_scene.Name, regionFlags != null ? regionFlags.ToString() : "not present");
+ // m_log.DebugFormat(
+ // "{0}: Region flags for {1} as seen by {2} are {3}",
+ // LogHeader, n.RegionName, m_scene.Name, regionFlags != null ? regionFlags.ToString() : "not present");
// Robust services before 2015-01-14 do not return the regionFlags information. In this case, we could
// make a separate RegionFlags call but this would involve a network call for each neighbour.
@@ -132,7 +132,7 @@ namespace OpenSim.Region.Framework.Scenes
}
m_log.DebugFormat(
- "{0} Informing {1} neighbours that region {2} is up",
+ "{0} Informing {1} neighbours that region {2} is up",
LogHeader, onlineNeighbours.Count, m_scene.Name);
foreach (GridRegion n in onlineNeighbours)
@@ -168,15 +168,15 @@ namespace OpenSim.Region.Framework.Scenes
private void SendChildAgentDataUpdateCompleted(IAsyncResult iar)
{
- SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate) iar.AsyncState;
+ SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate)iar.AsyncState;
icon.EndInvoke(iar);
}
public void SendChildAgentDataUpdate(AgentPosition cAgentData, ScenePresence presence)
{
-// m_log.DebugFormat(
-// "[SCENE COMMUNICATION SERVICE]: Sending child agent position updates for {0} in {1}",
-// presence.Name, m_scene.Name);
+ // m_log.DebugFormat(
+ // "[SCENE COMMUNICATION SERVICE]: Sending child agent position updates for {0} in {1}",
+ // presence.Name, m_scene.Name);
// This assumes that we know what our neighbors are.
try
@@ -234,6 +234,13 @@ namespace OpenSim.Region.Framework.Scenes
GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y);
+ if (destination == null)
+ {
+ m_log.DebugFormat(
+ "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} FAIL, region with handle {1} not found", agentID, regionHandle);
+ return;
+ }
+
m_log.DebugFormat(
"[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName);
@@ -248,16 +255,17 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SendCloseChildAgentConnections(UUID agentID, string auth_code, List regionslst)
{
- foreach (ulong handle in regionslst)
+ if (regionslst.Count == 0)
+ return;
+
+ // use a single thread job for all
+ Util.FireAndForget(o =>
{
- // We must take a copy here since handle acts like a reference when used in an iterator.
- // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region.
- ulong handleCopy = handle;
- Util.FireAndForget(
- o => SendCloseChildAgent(agentID, handleCopy, auth_code),
- null,
- "SceneCommunicationService.SendCloseChildAgentConnections");
- }
+ foreach (ulong handle in regionslst)
+ {
+ SendCloseChildAgent(agentID, handle, auth_code);
+ }
+ }, null, "SceneCommunicationService.SendCloseChildAgentConnections");
}
public List RequestNamedRegions(string name, int maxNumber)
--
cgit v1.1