aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications
diff options
context:
space:
mode:
authorlbsa712008-08-08 10:59:32 +0000
committerlbsa712008-08-08 10:59:32 +0000
commit22f09fbd213ffd414514756b4a7ee0e86325d733 (patch)
tree812fd206280d2f527063a902e0a041612338947f /OpenSim/Region/Communications
parentDe-coupling the IClientAPI interface and ClientManager class from the (diff)
downloadopensim-SC-22f09fbd213ffd414514756b4a7ee0e86325d733.zip
opensim-SC-22f09fbd213ffd414514756b4a7ee0e86325d733.tar.gz
opensim-SC-22f09fbd213ffd414514756b4a7ee0e86325d733.tar.bz2
opensim-SC-22f09fbd213ffd414514756b4a7ee0e86325d733.tar.xz
* 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.
Diffstat (limited to 'OpenSim/Region/Communications')
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs11
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs64
2 files changed, 46 insertions, 29 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
index f967cf7..8d6bbcc 100644
--- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
+++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
@@ -51,16 +51,9 @@ namespace OpenSim.Region.Communications.Local
51 51
52 public string _gdebugRegionName = String.Empty; 52 public string _gdebugRegionName = String.Empty;
53 53
54 bool m_bAvailable=true; 54 public bool CheckRegion(string address, uint port)
55
56 public void CheckRegion(string address, uint port)
57 {
58 m_bAvailable = true;
59 }
60
61 public bool Available
62 { 55 {
63 get { return m_bAvailable; } 56 return true;
64 } 57 }
65 58
66 public string gdebugRegionName 59 public string gdebugRegionName
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index a2cddec..af3b666 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -1558,36 +1558,60 @@ namespace OpenSim.Region.Communications.OGS1
1558 bool m_bAvailable = false; 1558 bool m_bAvailable = false;
1559 int timeOut = 10; //10 seconds 1559 int timeOut = 10; //10 seconds
1560 1560
1561 public void CheckRegion(string address, uint port) 1561 public bool CheckRegion(string address, uint port, bool retry)
1562 { 1562 {
1563 m_bAvailable = false; 1563 bool available = false;
1564 IPAddress ia = null; 1564 bool timed_out = true;
1565
1566 IPAddress ia;
1565 IPAddress.TryParse(address, out ia); 1567 IPAddress.TryParse(address, out ia);
1566 IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port); 1568 IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port);
1567 AsyncCallback ConnectedMethodCallback = new AsyncCallback(ConnectedMethod);
1568 Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
1569 IAsyncResult ar = socket.BeginConnect(m_EndPoint, ConnectedMethodCallback, socket);
1570 ar.AsyncWaitHandle.WaitOne(timeOut*1000, false);
1571 Thread.Sleep(500);
1572 }
1573 1569
1574 public bool Available 1570 AsyncCallback callback = delegate(IAsyncResult iar)
1575 { 1571 {
1576 get { return m_bAvailable; } 1572 Socket s = (Socket)iar.AsyncState;
1577 } 1573 try
1574 {
1575 s.EndConnect(iar);
1576 available = true;
1577 timed_out = false;
1578 }
1579 catch (Exception e)
1580 {
1581 m_log.DebugFormat("Callback EndConnect exception: {0}:{1}", e.Message, e.StackTrace);
1582 }
1583
1584 s.Close();
1585 };
1578 1586
1579 void ConnectedMethod(IAsyncResult ar)
1580 {
1581 Socket socket = (Socket)ar.AsyncState;
1582 try 1587 try
1583 { 1588 {
1584 socket.EndConnect(ar); 1589 Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
1585 m_bAvailable = true; 1590 IAsyncResult ar = socket.BeginConnect(m_EndPoint, callback, socket);
1591 ar.AsyncWaitHandle.WaitOne(timeOut * 1000, false);
1586 } 1592 }
1587 catch (Exception) 1593 catch (Exception e)
1594 {
1595 m_log.DebugFormat("CheckRegion Socket Setup exception: {0}:{1}", e.Message, e.StackTrace);
1596 return false;
1597 }
1598
1599 if (timed_out)
1588 { 1600 {
1601 m_log.DebugFormat("socket [{0}] timed out ({1}) waiting to obtain a connection.", m_EndPoint, timeOut * 1000);
1602
1603 if (retry)
1604 {
1605 return CheckRegion(address, port, false);
1606 }
1589 } 1607 }
1590 socket.Close(); 1608
1609 return available;
1610 }
1611
1612 public bool CheckRegion(string address, uint port)
1613 {
1614 return CheckRegion(address, port, true);
1591 } 1615 }
1592 1616
1593 public void NoteDeadRegion(ulong regionhandle) 1617 public void NoteDeadRegion(ulong regionhandle)