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;
}
Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
IPEndPoint external = region.ExternalEndPoint;
if (external != null)
{
InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
d.BeginInvoke(sp, agent, region, external, true,true,
d.BeginInvoke(sp, agent, region, external, true,
InformClientOfNeighbourCompleted,
d);
}
@ -1906,7 +1908,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
#region Enable Child Agents
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>
/// 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> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
// Dump("Current Neighbors", neighbourHandles);
// Dump("Previous Neighbours", previousRegionNeighbourHandles);
// Dump("New Neighbours", newRegions);
// Dump("Old Neighbours", oldRegions);
// Dump("Current Neighbors", neighbourHandles);
// Dump("Previous Neighbours", previousRegionNeighbourHandles);
// Dump("New Neighbours", newRegions);
// Dump("Old Neighbours", oldRegions);
/// Update the scene presence's known regions here on this region
sp.DropOldNeighbours(oldRegions);
@ -2020,9 +2022,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
//avatar.Scene.DumpChildrenSeeds(avatar.UUID);
//avatar.DumpKnownRegions();
bool newAgent = false;
Util.FireAndForget(delegate
{
Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
int count = 0;
bool delay = true;
bool newAgent = false;
foreach (GridRegion neighbour in neighbours)
{
//m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName);
@ -2031,22 +2036,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
newAgent = true;
else
newAgent = false;
// continue;
// continue;
if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle)
{
try
{
// Let's put this back at sync, so that it doesn't clog
// 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);
InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent);
}
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.
// throw e;
}
}
count++;
}
});
}
Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour)
@ -2109,13 +2105,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// <param name="regionHandle"></param>
/// <param name="endPoint"></param>
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;
m_log.DebugFormat(