diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 74 |
1 files changed, 59 insertions, 15 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index ad3f715..01981dd 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -1764,32 +1764,76 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1764 | endPoint = (IPEndPoint)array[0]; | 1764 | endPoint = (IPEndPoint)array[0]; |
1765 | CompleteAgentMovementPacket packet = (CompleteAgentMovementPacket)array[1]; | 1765 | CompleteAgentMovementPacket packet = (CompleteAgentMovementPacket)array[1]; |
1766 | 1766 | ||
1767 | m_log.DebugFormat( | ||
1768 | "[LLUDPSERVER]: Handling CompleteAgentMovement request from {0} in {1}", endPoint, m_scene.Name); | ||
1769 | |||
1767 | // Determine which agent this packet came from | 1770 | // Determine which agent this packet came from |
1768 | int count = 20; | 1771 | // We need to wait here because in when using the OpenSimulator V2 teleport protocol to travel to a destination |
1769 | bool ready = false; | 1772 | // simulator with no existing child presence, the viewer (at least LL 3.3.4) will send UseCircuitCode |
1770 | while (!ready && count-- > 0) | 1773 | // and then CompleteAgentMovement immediately without waiting for an ack. As we are now handling these |
1774 | // packets asynchronously, we need to account for this thread proceeding more quickly than the | ||
1775 | // UseCircuitCode thread. | ||
1776 | int count = 40; | ||
1777 | while (count-- > 0) | ||
1771 | { | 1778 | { |
1772 | if (m_scene.TryGetClient(endPoint, out client) && client.IsActive && client.SceneAgent != null) | 1779 | if (m_scene.TryGetClient(endPoint, out client)) |
1773 | { | 1780 | { |
1774 | LLClientView llClientView = (LLClientView)client; | 1781 | if (!client.IsActive) |
1775 | LLUDPClient udpClient = llClientView.UDPClient; | 1782 | { |
1776 | if (udpClient != null && udpClient.IsConnected) | 1783 | // This check exists to catch a condition where the client has been closed by another thread |
1777 | ready = true; | 1784 | // but has not yet been removed from the client manager (and possibly a new connection has |
1785 | // not yet been established). | ||
1786 | m_log.DebugFormat( | ||
1787 | "[LLUDPSERVER]: Received a CompleteAgentMovement from {0} for {1} in {2} but client is not active yet. Waiting.", | ||
1788 | endPoint, client.Name, m_scene.Name); | ||
1789 | } | ||
1790 | else if (client.SceneAgent == null) | ||
1791 | { | ||
1792 | // This check exists to catch a condition where the new client has been added to the client | ||
1793 | // manager but the SceneAgent has not yet been set in Scene.AddNewAgent(). If we are too | ||
1794 | // eager, then the new ScenePresence may not have registered a listener for this messsage | ||
1795 | // before we try to process it. | ||
1796 | // XXX: A better long term fix may be to add the SceneAgent before the client is added to | ||
1797 | // the client manager | ||
1798 | m_log.DebugFormat( | ||
1799 | "[LLUDPSERVER]: Received a CompleteAgentMovement from {0} for {1} in {2} but client SceneAgent not set yet. Waiting.", | ||
1800 | endPoint, client.Name, m_scene.Name); | ||
1801 | } | ||
1778 | else | 1802 | else |
1779 | { | 1803 | { |
1780 | m_log.Debug("[LLUDPSERVER]: Received a CompleteMovementIntoRegion in " + m_scene.RegionInfo.RegionName + " (not ready yet)"); | 1804 | break; |
1781 | Thread.Sleep(200); | ||
1782 | } | 1805 | } |
1783 | } | 1806 | } |
1784 | else | 1807 | else |
1785 | { | 1808 | { |
1786 | m_log.Debug("[LLUDPSERVER]: Received a CompleteMovementIntoRegion in " + m_scene.RegionInfo.RegionName + " (not ready yet)"); | 1809 | m_log.DebugFormat( |
1787 | Thread.Sleep(200); | 1810 | "[LLUDPSERVER]: Received a CompleteAgentMovement from {0} in {1} but no client exists yet. Waiting.", |
1811 | endPoint, m_scene.Name); | ||
1788 | } | 1812 | } |
1813 | |||
1814 | Thread.Sleep(200); | ||
1789 | } | 1815 | } |
1790 | 1816 | ||
1791 | if (client == null) | 1817 | if (client == null) |
1818 | { | ||
1819 | m_log.DebugFormat( | ||
1820 | "[LLUDPSERVER]: No client found for CompleteAgentMovement from {0} in {1} after wait. Dropping.", | ||
1821 | endPoint, m_scene.Name); | ||
1822 | |||
1823 | return; | ||
1824 | } | ||
1825 | else if (!client.IsActive || client.SceneAgent == null) | ||
1826 | { | ||
1827 | // This check exists to catch a condition where the client has been closed by another thread | ||
1828 | // but has not yet been removed from the client manager. | ||
1829 | // The packet could be simply ignored but it is useful to know if this condition occurred for other debugging | ||
1830 | // purposes. | ||
1831 | m_log.DebugFormat( | ||
1832 | "[LLUDPSERVER]: Received a CompleteAgentMovement from {0} for {1} in {2} but client is not active after wait. Dropping.", | ||
1833 | endPoint, client.Name, m_scene.Name); | ||
1834 | |||
1792 | return; | 1835 | return; |
1836 | } | ||
1793 | 1837 | ||
1794 | IncomingPacket incomingPacket1; | 1838 | IncomingPacket incomingPacket1; |
1795 | 1839 | ||
@@ -1810,7 +1854,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1810 | catch (Exception e) | 1854 | catch (Exception e) |
1811 | { | 1855 | { |
1812 | m_log.ErrorFormat( | 1856 | m_log.ErrorFormat( |
1813 | "[LLUDPSERVER]: CompleteMovementIntoRegion handling from endpoint {0}, client {1} {2} failed. Exception {3}{4}", | 1857 | "[LLUDPSERVER]: CompleteAgentMovement handling from endpoint {0}, client {1} {2} failed. Exception {3}{4}", |
1814 | endPoint != null ? endPoint.ToString() : "n/a", | 1858 | endPoint != null ? endPoint.ToString() : "n/a", |
1815 | client != null ? client.Name : "unknown", | 1859 | client != null ? client.Name : "unknown", |
1816 | client != null ? client.AgentId.ToString() : "unknown", | 1860 | client != null ? client.AgentId.ToString() : "unknown", |
@@ -1921,7 +1965,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1921 | client.Kick("Simulator logged you out due to connection timeout."); | 1965 | client.Kick("Simulator logged you out due to connection timeout."); |
1922 | } | 1966 | } |
1923 | 1967 | ||
1924 | m_scene.IncomingCloseAgent(client.AgentId, true); | 1968 | m_scene.CloseAgent(client.AgentId, true); |
1925 | } | 1969 | } |
1926 | 1970 | ||
1927 | private void IncomingPacketHandler() | 1971 | private void IncomingPacketHandler() |
@@ -2264,7 +2308,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2264 | if (!client.IsLoggingOut) | 2308 | if (!client.IsLoggingOut) |
2265 | { | 2309 | { |
2266 | client.IsLoggingOut = true; | 2310 | client.IsLoggingOut = true; |
2267 | m_scene.IncomingCloseAgent(client.AgentId, false); | 2311 | m_scene.CloseAgent(client.AgentId, false); |
2268 | } | 2312 | } |
2269 | } | 2313 | } |
2270 | } | 2314 | } |