diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 127 |
1 files changed, 85 insertions, 42 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 01981dd..4854893 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -147,6 +147,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
147 | 147 | ||
148 | StatsManager.RegisterStat( | 148 | StatsManager.RegisterStat( |
149 | new Stat( | 149 | new Stat( |
150 | "OutgoingPacketsResentCount", | ||
151 | "Number of packets resent because a client did not acknowledge receipt", | ||
152 | "", | ||
153 | "", | ||
154 | "clientstack", | ||
155 | scene.Name, | ||
156 | StatType.Pull, | ||
157 | MeasuresOfInterest.AverageChangeOverTime, | ||
158 | stat => stat.Value = m_udpServer.PacketsResentCount, | ||
159 | StatVerbosity.Debug)); | ||
160 | |||
161 | StatsManager.RegisterStat( | ||
162 | new Stat( | ||
150 | "AverageUDPProcessTime", | 163 | "AverageUDPProcessTime", |
151 | "Average number of milliseconds taken to process each incoming UDP packet in a sample.", | 164 | "Average number of milliseconds taken to process each incoming UDP packet in a sample.", |
152 | "This is for initial receive processing which is separate from the later client LL packet processing stage.", | 165 | "This is for initial receive processing which is separate from the later client LL packet processing stage.", |
@@ -299,6 +312,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
299 | public Socket Server { get { return null; } } | 312 | public Socket Server { get { return null; } } |
300 | 313 | ||
301 | /// <summary> | 314 | /// <summary> |
315 | /// Record how many packets have been resent | ||
316 | /// </summary> | ||
317 | internal int PacketsResentCount { get; set; } | ||
318 | |||
319 | /// <summary> | ||
320 | /// Record how many packets have been sent | ||
321 | /// </summary> | ||
322 | internal int PacketsSentCount { get; set; } | ||
323 | |||
324 | /// <summary> | ||
302 | /// Record how many inbound packets could not be recognized as LLUDP packets. | 325 | /// Record how many inbound packets could not be recognized as LLUDP packets. |
303 | /// </summary> | 326 | /// </summary> |
304 | public int IncomingMalformedPacketCount { get; private set; } | 327 | public int IncomingMalformedPacketCount { get; private set; } |
@@ -866,44 +889,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
866 | return x == m_location; | 889 | return x == m_location; |
867 | } | 890 | } |
868 | 891 | ||
869 | public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) | 892 | // public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) |
870 | { | 893 | // { |
871 | // CoarseLocationUpdate and AvatarGroupsReply packets cannot be split in an automated way | 894 | // // CoarseLocationUpdate and AvatarGroupsReply packets cannot be split in an automated way |
872 | if ((packet.Type == PacketType.CoarseLocationUpdate || packet.Type == PacketType.AvatarGroupsReply) && allowSplitting) | 895 | // if ((packet.Type == PacketType.CoarseLocationUpdate || packet.Type == PacketType.AvatarGroupsReply) && allowSplitting) |
873 | allowSplitting = false; | 896 | // allowSplitting = false; |
874 | 897 | // | |
875 | if (allowSplitting && packet.HasVariableBlocks) | 898 | // if (allowSplitting && packet.HasVariableBlocks) |
876 | { | 899 | // { |
877 | byte[][] datas = packet.ToBytesMultiple(); | 900 | // byte[][] datas = packet.ToBytesMultiple(); |
878 | int packetCount = datas.Length; | 901 | // int packetCount = datas.Length; |
879 | 902 | // | |
880 | if (packetCount < 1) | 903 | // if (packetCount < 1) |
881 | m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length); | 904 | // m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length); |
882 | 905 | // | |
883 | for (int i = 0; i < packetCount; i++) | 906 | // for (int i = 0; i < packetCount; i++) |
884 | { | 907 | // { |
885 | byte[] data = datas[i]; | 908 | // byte[] data = datas[i]; |
886 | m_scene.ForEachClient( | 909 | // m_scene.ForEachClient( |
887 | delegate(IClientAPI client) | 910 | // delegate(IClientAPI client) |
888 | { | 911 | // { |
889 | if (client is LLClientView) | 912 | // if (client is LLClientView) |
890 | SendPacketData(((LLClientView)client).UDPClient, data, packet.Type, category, null); | 913 | // SendPacketData(((LLClientView)client).UDPClient, data, packet.Type, category, null); |
891 | } | 914 | // } |
892 | ); | 915 | // ); |
893 | } | 916 | // } |
894 | } | 917 | // } |
895 | else | 918 | // else |
896 | { | 919 | // { |
897 | byte[] data = packet.ToBytes(); | 920 | // byte[] data = packet.ToBytes(); |
898 | m_scene.ForEachClient( | 921 | // m_scene.ForEachClient( |
899 | delegate(IClientAPI client) | 922 | // delegate(IClientAPI client) |
900 | { | 923 | // { |
901 | if (client is LLClientView) | 924 | // if (client is LLClientView) |
902 | SendPacketData(((LLClientView)client).UDPClient, data, packet.Type, category, null); | 925 | // SendPacketData(((LLClientView)client).UDPClient, data, packet.Type, category, null); |
903 | } | 926 | // } |
904 | ); | 927 | // ); |
905 | } | 928 | // } |
906 | } | 929 | // } |
907 | 930 | ||
908 | /// <summary> | 931 | /// <summary> |
909 | /// Start the process of sending a packet to the client. | 932 | /// Start the process of sending a packet to the client. |
@@ -923,6 +946,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
923 | if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting) | 946 | if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting) |
924 | allowSplitting = false; | 947 | allowSplitting = false; |
925 | 948 | ||
949 | bool packetQueued = false; | ||
950 | |||
926 | if (allowSplitting && packet.HasVariableBlocks) | 951 | if (allowSplitting && packet.HasVariableBlocks) |
927 | { | 952 | { |
928 | byte[][] datas = packet.ToBytesMultiple(); | 953 | byte[][] datas = packet.ToBytesMultiple(); |
@@ -934,18 +959,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
934 | for (int i = 0; i < packetCount; i++) | 959 | for (int i = 0; i < packetCount; i++) |
935 | { | 960 | { |
936 | byte[] data = datas[i]; | 961 | byte[] data = datas[i]; |
937 | SendPacketData(udpClient, data, packet.Type, category, method); | 962 | |
963 | if (!SendPacketData(udpClient, data, packet.Type, category, method)) | ||
964 | packetQueued = true; | ||
938 | } | 965 | } |
939 | } | 966 | } |
940 | else | 967 | else |
941 | { | 968 | { |
942 | byte[] data = packet.ToBytes(); | 969 | byte[] data = packet.ToBytes(); |
943 | SendPacketData(udpClient, data, packet.Type, category, method); | 970 | packetQueued = SendPacketData(udpClient, data, packet.Type, category, method); |
944 | } | 971 | } |
945 | 972 | ||
946 | PacketPool.Instance.ReturnPacket(packet); | 973 | PacketPool.Instance.ReturnPacket(packet); |
947 | 974 | ||
948 | m_dataPresentEvent.Set(); | 975 | if (packetQueued) |
976 | m_dataPresentEvent.Set(); | ||
949 | } | 977 | } |
950 | 978 | ||
951 | /// <summary> | 979 | /// <summary> |
@@ -959,7 +987,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
959 | /// The method to call if the packet is not acked by the client. If null, then a standard | 987 | /// The method to call if the packet is not acked by the client. If null, then a standard |
960 | /// resend of the packet is done. | 988 | /// resend of the packet is done. |
961 | /// </param> | 989 | /// </param> |
962 | public void SendPacketData( | 990 | /// <returns>true if the data was sent immediately, false if it was queued for sending</returns> |
991 | public bool SendPacketData( | ||
963 | LLUDPClient udpClient, byte[] data, PacketType type, ThrottleOutPacketType category, UnackedPacketMethod method) | 992 | LLUDPClient udpClient, byte[] data, PacketType type, ThrottleOutPacketType category, UnackedPacketMethod method) |
964 | { | 993 | { |
965 | int dataLength = data.Length; | 994 | int dataLength = data.Length; |
@@ -1032,7 +1061,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1032 | // packet so that it isn't sent before a queued update packet. | 1061 | // packet so that it isn't sent before a queued update packet. |
1033 | bool requestQueue = type == PacketType.KillObject; | 1062 | bool requestQueue = type == PacketType.KillObject; |
1034 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, requestQueue, highPriority)) | 1063 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, requestQueue, highPriority)) |
1064 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, requestQueue)) | ||
1065 | { | ||
1035 | SendPacketFinal(outgoingPacket); | 1066 | SendPacketFinal(outgoingPacket); |
1067 | return true; | ||
1068 | } | ||
1069 | |||
1070 | return false; | ||
1036 | 1071 | ||
1037 | #endregion Queue or Send | 1072 | #endregion Queue or Send |
1038 | } | 1073 | } |
@@ -1213,6 +1248,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1213 | else | 1248 | else |
1214 | { | 1249 | { |
1215 | Interlocked.Increment(ref udpClient.PacketsResent); | 1250 | Interlocked.Increment(ref udpClient.PacketsResent); |
1251 | |||
1252 | // We're not going to worry about interlock yet since its not currently critical that this total count | ||
1253 | // is 100% correct | ||
1254 | PacketsResentCount++; | ||
1216 | } | 1255 | } |
1217 | 1256 | ||
1218 | #endregion Sequence Number Assignment | 1257 | #endregion Sequence Number Assignment |
@@ -1220,6 +1259,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1220 | // Stats tracking | 1259 | // Stats tracking |
1221 | Interlocked.Increment(ref udpClient.PacketsSent); | 1260 | Interlocked.Increment(ref udpClient.PacketsSent); |
1222 | 1261 | ||
1262 | // We're not going to worry about interlock yet since its not currently critical that this total count | ||
1263 | // is 100% correct | ||
1264 | PacketsSentCount++; | ||
1265 | |||
1223 | // Put the UDP payload on the wire | 1266 | // Put the UDP payload on the wire |
1224 | AsyncBeginSend(buffer); | 1267 | AsyncBeginSend(buffer); |
1225 | 1268 | ||