* All CheckRegion within an instance would use the same, global, bool for 'Available', which would lead to intermittent failures on parallell teleport requests.

* Solidified CheckRegion somewhat, adding a second try if the first failed.
0.6.0-stable
lbsa71 2008-08-08 10:59:32 +00:00
parent 97d5b5a1eb
commit 22f09fbd21
4 changed files with 49 additions and 33 deletions

View File

@ -32,8 +32,8 @@ namespace OpenSim.Framework.Communications
public interface IInterRegionCommunications
{
string rdebugRegionName { get; set; }
bool Available { get; }
void CheckRegion(string address, uint port);
bool CheckRegion(string address, uint port);
bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData);
bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData, int XMLMethod);
bool RegionUp(SerializableRegionInfo region, ulong regionhandle);

View File

@ -51,16 +51,9 @@ namespace OpenSim.Region.Communications.Local
public string _gdebugRegionName = String.Empty;
bool m_bAvailable=true;
public void CheckRegion(string address, uint port)
public bool CheckRegion(string address, uint port)
{
m_bAvailable = true;
}
public bool Available
{
get { return m_bAvailable; }
return true;
}
public string gdebugRegionName

View File

@ -1558,36 +1558,60 @@ namespace OpenSim.Region.Communications.OGS1
bool m_bAvailable = false;
int timeOut = 10; //10 seconds
public void CheckRegion(string address, uint port)
public bool CheckRegion(string address, uint port, bool retry)
{
m_bAvailable = false;
IPAddress ia = null;
bool available = false;
bool timed_out = true;
IPAddress ia;
IPAddress.TryParse(address, out ia);
IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port);
AsyncCallback ConnectedMethodCallback = new AsyncCallback(ConnectedMethod);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult ar = socket.BeginConnect(m_EndPoint, ConnectedMethodCallback, socket);
ar.AsyncWaitHandle.WaitOne(timeOut*1000, false);
Thread.Sleep(500);
}
public bool Available
AsyncCallback callback = delegate(IAsyncResult iar)
{
get { return m_bAvailable; }
}
void ConnectedMethod(IAsyncResult ar)
{
Socket socket = (Socket)ar.AsyncState;
Socket s = (Socket)iar.AsyncState;
try
{
socket.EndConnect(ar);
m_bAvailable = true;
s.EndConnect(iar);
available = true;
timed_out = false;
}
catch (Exception)
catch (Exception e)
{
m_log.DebugFormat("Callback EndConnect exception: {0}:{1}", e.Message, e.StackTrace);
}
socket.Close();
s.Close();
};
try
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult ar = socket.BeginConnect(m_EndPoint, callback, socket);
ar.AsyncWaitHandle.WaitOne(timeOut * 1000, false);
}
catch (Exception e)
{
m_log.DebugFormat("CheckRegion Socket Setup exception: {0}:{1}", e.Message, e.StackTrace);
return false;
}
if (timed_out)
{
m_log.DebugFormat("socket [{0}] timed out ({1}) waiting to obtain a connection.", m_EndPoint, timeOut * 1000);
if (retry)
{
return CheckRegion(address, port, false);
}
}
return available;
}
public bool CheckRegion(string address, uint port)
{
return CheckRegion(address, port, true);
}
public void NoteDeadRegion(ulong regionhandle)

View File

@ -580,8 +580,7 @@ namespace OpenSim.Region.Environment.Scenes
if (reg.RemotingAddress != "" && reg.RemotingPort != 0)
{
// region is remote. see if it is up
m_commsProvider.InterRegion.CheckRegion(reg.RemotingAddress, reg.RemotingPort);
destRegionUp = m_commsProvider.InterRegion.Available;
destRegionUp = m_commsProvider.InterRegion.CheckRegion(reg.RemotingAddress, reg.RemotingPort);
}
else
{