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,9 +2022,12 @@ 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
{
Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
int count = 0; int count = 0;
bool delay = true; bool newAgent = false;
foreach (GridRegion neighbour in neighbours) foreach (GridRegion neighbour in neighbours)
{ {
//m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName);
@ -2031,22 +2036,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
newAgent = true; newAgent = true;
else else
newAgent = false; newAgent = false;
// continue; // continue;
if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle)
{ {
try try
{ {
// Let's put this back at sync, so that it doesn't clog InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent);
// the network, especially for regions in the same physical server.
// We're really not in a hurry here.
InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, delay);
delay = false; // ugly i know.. but there aren't that many neighbours
//InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
//d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
// InformClientOfNeighbourCompleted,
// d);
} }
catch (ArgumentOutOfRangeException) catch (ArgumentOutOfRangeException)
@ -2073,11 +2069,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
// throw e; // throw e;
} }
} }
count++; count++;
} }
});
} }
Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour) Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour)
@ -2109,13 +2105,8 @@ 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
// after a cross here
if(doinitialdelay)
Thread.Sleep(500);
Scene scene = sp.Scene; Scene scene = sp.Scene;
m_log.DebugFormat( m_log.DebugFormat(