diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 80 |
1 files changed, 70 insertions, 10 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 746eb90..86d8f62 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -155,6 +155,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
155 | /// <summary>Flag to signal when clients should send pings</summary> | 155 | /// <summary>Flag to signal when clients should send pings</summary> |
156 | protected bool m_sendPing; | 156 | protected bool m_sendPing; |
157 | 157 | ||
158 | private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); | ||
159 | |||
158 | private int m_defaultRTO = 0; | 160 | private int m_defaultRTO = 0; |
159 | private int m_maxRTO = 0; | 161 | private int m_maxRTO = 0; |
160 | private int m_ackTimeout = 0; | 162 | private int m_ackTimeout = 0; |
@@ -765,19 +767,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
765 | 767 | ||
766 | #region Packet to Client Mapping | 768 | #region Packet to Client Mapping |
767 | 769 | ||
768 | // UseCircuitCode handling | 770 | // If there is already a client for this endpoint, don't process UseCircuitCode |
769 | if (packet.Type == PacketType.UseCircuitCode) | 771 | IClientAPI client = null; |
772 | if (!m_scene.TryGetClient(address, out client)) | ||
770 | { | 773 | { |
771 | object[] array = new object[] { buffer, packet }; | 774 | // UseCircuitCode handling |
775 | if (packet.Type == PacketType.UseCircuitCode) | ||
776 | { | ||
777 | // And if there is a UseCircuitCode pending, also drop it | ||
778 | lock (m_pendingCache) | ||
779 | { | ||
780 | if (m_pendingCache.Contains(address)) | ||
781 | return; | ||
772 | 782 | ||
773 | Util.FireAndForget(HandleUseCircuitCode, array); | 783 | m_pendingCache.AddOrUpdate(address, new Queue<UDPPacketBuffer>(), 60); |
784 | } | ||
774 | 785 | ||
775 | return; | 786 | object[] array = new object[] { buffer, packet }; |
787 | |||
788 | Util.FireAndForget(HandleUseCircuitCode, array); | ||
789 | |||
790 | return; | ||
791 | } | ||
792 | } | ||
793 | |||
794 | // If this is a pending connection, enqueue, don't process yet | ||
795 | lock (m_pendingCache) | ||
796 | { | ||
797 | Queue<UDPPacketBuffer> queue; | ||
798 | if (m_pendingCache.TryGetValue(address, out queue)) | ||
799 | { | ||
800 | //m_log.DebugFormat("[LLUDPSERVER]: Enqueued a {0} packet into the pending queue", packet.Type); | ||
801 | queue.Enqueue(buffer); | ||
802 | return; | ||
803 | } | ||
776 | } | 804 | } |
777 | 805 | ||
778 | // Determine which agent this packet came from | 806 | // Determine which agent this packet came from |
779 | IClientAPI client; | 807 | if (client == null || !(client is LLClientView)) |
780 | if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) | ||
781 | { | 808 | { |
782 | //m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); | 809 | //m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); |
783 | return; | 810 | return; |
@@ -786,7 +813,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
786 | udpClient = ((LLClientView)client).UDPClient; | 813 | udpClient = ((LLClientView)client).UDPClient; |
787 | 814 | ||
788 | if (!udpClient.IsConnected) | 815 | if (!udpClient.IsConnected) |
816 | { | ||
817 | // m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet for a unConnected client in " + m_scene.RegionInfo.RegionName); | ||
789 | return; | 818 | return; |
819 | } | ||
790 | 820 | ||
791 | #endregion Packet to Client Mapping | 821 | #endregion Packet to Client Mapping |
792 | 822 | ||
@@ -1011,6 +1041,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1011 | // We only want to send initial data to new clients, not ones which are being converted from child to root. | 1041 | // We only want to send initial data to new clients, not ones which are being converted from child to root. |
1012 | if (client != null) | 1042 | if (client != null) |
1013 | client.SceneAgent.SendInitialDataToMe(); | 1043 | client.SceneAgent.SendInitialDataToMe(); |
1044 | |||
1045 | // Now we know we can handle more data | ||
1046 | Thread.Sleep(200); | ||
1047 | |||
1048 | // Obtain the queue and remove it from the cache | ||
1049 | Queue<UDPPacketBuffer> queue = null; | ||
1050 | |||
1051 | lock (m_pendingCache) | ||
1052 | { | ||
1053 | if (!m_pendingCache.TryGetValue(remoteEndPoint, out queue)) | ||
1054 | { | ||
1055 | m_log.DebugFormat("[LLUDPSERVER]: Client created but no pending queue present"); | ||
1056 | return; | ||
1057 | } | ||
1058 | m_pendingCache.Remove(remoteEndPoint); | ||
1059 | } | ||
1060 | |||
1061 | m_log.DebugFormat("[LLUDPSERVER]: Client created, processing pending queue, {0} entries", queue.Count); | ||
1062 | |||
1063 | // Reinject queued packets | ||
1064 | while(queue.Count > 0) | ||
1065 | { | ||
1066 | UDPPacketBuffer buf = queue.Dequeue(); | ||
1067 | PacketReceived(buf); | ||
1068 | } | ||
1069 | queue = null; | ||
1014 | } | 1070 | } |
1015 | else | 1071 | else |
1016 | { | 1072 | { |
@@ -1018,6 +1074,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1018 | m_log.WarnFormat( | 1074 | m_log.WarnFormat( |
1019 | "[LLUDPSERVER]: Ignoring connection request for {0} to {1} with unknown circuit code {2} from IP {3}", | 1075 | "[LLUDPSERVER]: Ignoring connection request for {0} to {1} with unknown circuit code {2} from IP {3}", |
1020 | uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, remoteEndPoint); | 1076 | uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, remoteEndPoint); |
1077 | lock (m_pendingCache) | ||
1078 | m_pendingCache.Remove(remoteEndPoint); | ||
1021 | } | 1079 | } |
1022 | 1080 | ||
1023 | // m_log.DebugFormat( | 1081 | // m_log.DebugFormat( |
@@ -1136,7 +1194,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1136 | if (!client.SceneAgent.IsChildAgent) | 1194 | if (!client.SceneAgent.IsChildAgent) |
1137 | client.Kick("Simulator logged you out due to connection timeout"); | 1195 | client.Kick("Simulator logged you out due to connection timeout"); |
1138 | 1196 | ||
1139 | client.CloseWithoutChecks(); | 1197 | client.CloseWithoutChecks(true); |
1140 | } | 1198 | } |
1141 | } | 1199 | } |
1142 | 1200 | ||
@@ -1148,6 +1206,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1148 | 1206 | ||
1149 | while (base.IsRunning) | 1207 | while (base.IsRunning) |
1150 | { | 1208 | { |
1209 | m_scene.ThreadAlive(1); | ||
1151 | try | 1210 | try |
1152 | { | 1211 | { |
1153 | IncomingPacket incomingPacket = null; | 1212 | IncomingPacket incomingPacket = null; |
@@ -1190,6 +1249,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1190 | 1249 | ||
1191 | while (base.IsRunning) | 1250 | while (base.IsRunning) |
1192 | { | 1251 | { |
1252 | m_scene.ThreadAlive(2); | ||
1193 | try | 1253 | try |
1194 | { | 1254 | { |
1195 | m_packetSent = false; | 1255 | m_packetSent = false; |
@@ -1455,8 +1515,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1455 | if (!client.IsLoggingOut) | 1515 | if (!client.IsLoggingOut) |
1456 | { | 1516 | { |
1457 | client.IsLoggingOut = true; | 1517 | client.IsLoggingOut = true; |
1458 | client.Close(); | 1518 | client.Close(false); |
1459 | } | 1519 | } |
1460 | } | 1520 | } |
1461 | } | 1521 | } |
1462 | } \ No newline at end of file | 1522 | } |