make EnableChildAgent async from caller

avinationmerge
UbitUmarov 2014-08-17 03:22:05 +01:00
parent 4a20760929
commit 722b3a6523
1 changed files with 52 additions and 61 deletions

View File

@ -1892,11 +1892,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agent.Id0 = currentAgentCircuit.Id0; agent.Id0 = currentAgentCircuit.Id0;
} }
Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
IPEndPoint external = region.ExternalEndPoint; IPEndPoint external = region.ExternalEndPoint;
if (external != null) if (external != null)
{ {
InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
d.BeginInvoke(sp, agent, region, external, true,true, d.BeginInvoke(sp, agent, region, external, true,
InformClientOfNeighbourCompleted, InformClientOfNeighbourCompleted,
d); d);
} }
@ -1906,7 +1908,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
#region Enable Child Agents #region Enable Child Agents
private delegate void InformClientOfNeighbourDelegate( private delegate void InformClientOfNeighbourDelegate(
ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent, bool doInitialDelay); ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
/// <summary> /// <summary>
/// This informs all neighbouring regions about agent "avatar". /// This informs all neighbouring regions about agent "avatar".
@ -1945,10 +1947,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
// Dump("Current Neighbors", neighbourHandles); // Dump("Current Neighbors", neighbourHandles);
// Dump("Previous Neighbours", previousRegionNeighbourHandles); // Dump("Previous Neighbours", previousRegionNeighbourHandles);
// Dump("New Neighbours", newRegions); // Dump("New Neighbours", newRegions);
// Dump("Old Neighbours", oldRegions); // Dump("Old Neighbours", oldRegions);
/// Update the scene presence's known regions here on this region /// Update the scene presence's known regions here on this region
sp.DropOldNeighbours(oldRegions); sp.DropOldNeighbours(oldRegions);
@ -2020,64 +2022,58 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
//avatar.Scene.DumpChildrenSeeds(avatar.UUID); //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
//avatar.DumpKnownRegions(); //avatar.DumpKnownRegions();
bool newAgent = false; Util.FireAndForget(delegate
int count = 0;
bool delay = true;
foreach (GridRegion neighbour in neighbours)
{ {
//m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
// Don't do it if there's already an agent in that region int count = 0;
if (newRegions.Contains(neighbour.RegionHandle)) bool newAgent = false;
newAgent = true;
else
newAgent = false;
// continue;
if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) foreach (GridRegion neighbour in neighbours)
{ {
try //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName);
{ // Don't do it if there's already an agent in that region
// Let's put this back at sync, so that it doesn't clog if (newRegions.Contains(neighbour.RegionHandle))
// the network, especially for regions in the same physical server. newAgent = true;
// We're really not in a hurry here. else
InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, delay); newAgent = false;
delay = false; // ugly i know.. but there aren't that many neighbours // continue;
//InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle)
//d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, {
// InformClientOfNeighbourCompleted, try
// d); {
} InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent);
}
catch (ArgumentOutOfRangeException) catch (ArgumentOutOfRangeException)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
neighbour.ExternalHostName, neighbour.ExternalHostName,
neighbour.RegionHandle, neighbour.RegionHandle,
neighbour.RegionLocX,
neighbour.RegionLocY);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
neighbour.ExternalHostName,
neighbour.RegionHandle,
neighbour.RegionLocX, neighbour.RegionLocX,
neighbour.RegionLocY, neighbour.RegionLocY);
e); }
catch (Exception e)
{
m_log.ErrorFormat(
"[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
neighbour.ExternalHostName,
neighbour.RegionHandle,
neighbour.RegionLocX,
neighbour.RegionLocY,
e);
// FIXME: Okay, even though we've failed, we're still going to throw the exception on, // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
// since I don't know what will happen if we just let the client continue // since I don't know what will happen if we just let the client continue
// XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
// throw e;
// XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
// throw e;
}
} }
count++;
} }
count++; });
}
} }
Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour) Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour)
@ -2109,14 +2105,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="endPoint"></param> /// <param name="endPoint"></param>
private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg,
IPEndPoint endPoint, bool newAgent,bool doinitialdelay) IPEndPoint endPoint, bool newAgent)
{ {
// Let's wait just a little to give time to originating regions to catch up with closing child agents Scene scene = sp.Scene;
// after a cross here
if(doinitialdelay)
Thread.Sleep(500);
Scene scene = sp.Scene;
m_log.DebugFormat( m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})", "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})",