More improvements on agent position updates: if the target sims fail, blacklist them for 2 min, so that we don't keep doing remote calls that fail.

0.7.3-post-fixes
Diva Canto 2012-02-20 10:58:07 -08:00
parent fdda57cf10
commit 512910a51f
2 changed files with 16 additions and 11 deletions

View File

@ -140,7 +140,6 @@ namespace OpenSim.Region.Framework.Scenes
icon.EndInvoke(iar);
}
ExpiringCache<string, bool> _failedSims = new ExpiringCache<string, bool>();
public void SendChildAgentDataUpdate(AgentPosition cAgentData, ScenePresence presence)
{
// This assumes that we know what our neighbors are.
@ -158,15 +157,13 @@ namespace OpenSim.Region.Framework.Scenes
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
bool v = true;
if (! simulatorList.Contains(dest.ServerURI) && !_failedSims.TryGetValue(dest.ServerURI, out v))
if (! simulatorList.Contains(dest.ServerURI))
{
// we havent seen this simulator before, add it to the list
// and send it an update
simulatorList.Add(dest.ServerURI);
// Let move this to sync. Mono definitely does not like async networking.
if (!m_scene.SimulationService.UpdateAgent(dest, cAgentData))
// Also if it fails, get it out of the loop for a bit
_failedSims.Add(dest.ServerURI, true, 120);
m_scene.SimulationService.UpdateAgent(dest, cAgentData);
// Leaving this here as a reminder that we tried, and it sucks.
//SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync;

View File

@ -153,6 +153,7 @@ namespace OpenSim.Services.Connectors.Simulation
return UpdateAgent(destination, (IAgentData)data, 200000); // yes, 200 seconds
}
private ExpiringCache<string, bool> _failedSims = new ExpiringCache<string, bool>();
/// <summary>
/// Send updated position information about an agent in this region to a neighbor
/// This operation may be called very frequently if an avatar is moving about in
@ -160,6 +161,10 @@ namespace OpenSim.Services.Connectors.Simulation
/// </summary>
public bool UpdateAgent(GridRegion destination, AgentPosition data)
{
bool v = true;
if (_failedSims.TryGetValue(destination.ServerURI, out v))
return false;
// The basic idea of this code is that the first thread that needs to
// send an update for a specific avatar becomes the worker for any subsequent
// requests until there are no more outstanding requests. Further, only send the most
@ -183,9 +188,10 @@ namespace OpenSim.Services.Connectors.Simulation
// Otherwise update the reference and start processing
m_updateAgentQueue[uri] = data;
}
AgentPosition pos = null;
while (true)
bool success = true;
while (success)
{
lock (m_updateAgentQueue)
{
@ -205,11 +211,13 @@ namespace OpenSim.Services.Connectors.Simulation
}
}
UpdateAgent(destination, (IAgentData)pos, 10000);
success = UpdateAgent(destination, (IAgentData)pos, 10000);
}
// unreachable
// return true;
// we get here iff success == false
// blacklist sim for 2 minutes
_failedSims.AddOrUpdate(destination.ServerURI, true, 120);
m_updateAgentQueue.Clear();
return false;
}
/// <summary>