diff options
author | Diva Canto | 2011-02-08 12:06:14 -0800 |
---|---|---|
committer | Diva Canto | 2011-02-08 12:06:14 -0800 |
commit | ac7bc78555c1dd51724790032f0711b24bc8c67d (patch) | |
tree | 6e208f4cb470c574d0094db93cb5bc3bdccb9e71 /OpenSim/Region/ClientStack | |
parent | Comment previous debug (diff) | |
download | opensim-SC-ac7bc78555c1dd51724790032f0711b24bc8c67d.zip opensim-SC-ac7bc78555c1dd51724790032f0711b24bc8c67d.tar.gz opensim-SC-ac7bc78555c1dd51724790032f0711b24bc8c67d.tar.bz2 opensim-SC-ac7bc78555c1dd51724790032f0711b24bc8c67d.tar.xz |
Added emergency monitoring of UDP Outgoing packets thread. Just type "emergency-monitoring on/off"
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 5ff9aee..72257d2 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | ||
30 | using System.IO; | 31 | using System.IO; |
31 | using System.Net; | 32 | using System.Net; |
32 | using System.Net.Sockets; | 33 | using System.Net.Sockets; |
@@ -1053,6 +1054,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1053 | 1054 | ||
1054 | #endregion Update Timers | 1055 | #endregion Update Timers |
1055 | 1056 | ||
1057 | if (m_scene.EmergencyMonitoring) | ||
1058 | clientPacketHandler = MonitoredClientOutgoingPacketHandler; | ||
1059 | |||
1056 | // Handle outgoing packets, resends, acknowledgements, and pings for each | 1060 | // Handle outgoing packets, resends, acknowledgements, and pings for each |
1057 | // client. m_packetSent will be set to true if a packet is sent | 1061 | // client. m_packetSent will be set to true if a packet is sent |
1058 | m_scene.ForEachClient(clientPacketHandler); | 1062 | m_scene.ForEachClient(clientPacketHandler); |
@@ -1068,6 +1072,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1068 | { | 1072 | { |
1069 | m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex); | 1073 | m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex); |
1070 | } | 1074 | } |
1075 | |||
1071 | } | 1076 | } |
1072 | 1077 | ||
1073 | Watchdog.RemoveThread(); | 1078 | Watchdog.RemoveThread(); |
@@ -1105,6 +1110,101 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1105 | } | 1110 | } |
1106 | } | 1111 | } |
1107 | 1112 | ||
1113 | #region Emergency Monitoring | ||
1114 | private Stopwatch watch1 = new Stopwatch(); | ||
1115 | private Stopwatch watch2 = new Stopwatch(); | ||
1116 | |||
1117 | private float avgProcessingTicks = 0; | ||
1118 | private float avgResendUnackedTicks = 0; | ||
1119 | private float avgSendAcksTicks = 0; | ||
1120 | private float avgSendPingTicks = 0; | ||
1121 | private float avgDequeueTicks = 0; | ||
1122 | private long nticks = 0; | ||
1123 | private long nticksUnack = 0; | ||
1124 | private long nticksAck = 0; | ||
1125 | private long nticksPing = 0; | ||
1126 | |||
1127 | private void MonitoredClientOutgoingPacketHandler(IClientAPI client) | ||
1128 | { | ||
1129 | nticks++; | ||
1130 | watch1.Start(); | ||
1131 | try | ||
1132 | { | ||
1133 | if (client is LLClientView) | ||
1134 | { | ||
1135 | LLUDPClient udpClient = ((LLClientView)client).UDPClient; | ||
1136 | |||
1137 | if (udpClient.IsConnected) | ||
1138 | { | ||
1139 | if (m_resendUnacked) | ||
1140 | { | ||
1141 | nticksUnack++; | ||
1142 | watch2.Start(); | ||
1143 | |||
1144 | ResendUnacked(udpClient); | ||
1145 | |||
1146 | watch2.Stop(); | ||
1147 | avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack); | ||
1148 | watch2.Reset(); | ||
1149 | } | ||
1150 | |||
1151 | if (m_sendAcks) | ||
1152 | { | ||
1153 | nticksAck++; | ||
1154 | watch2.Start(); | ||
1155 | |||
1156 | SendAcks(udpClient); | ||
1157 | |||
1158 | watch2.Stop(); | ||
1159 | avgSendAcksTicks = (nticksAck - 1) / (float)nticksAck * avgSendAcksTicks + (watch2.ElapsedTicks / (float)nticksAck); | ||
1160 | watch2.Reset(); | ||
1161 | } | ||
1162 | |||
1163 | if (m_sendPing) | ||
1164 | { | ||
1165 | nticksPing++; | ||
1166 | watch2.Start(); | ||
1167 | |||
1168 | SendPing(udpClient); | ||
1169 | |||
1170 | watch2.Stop(); | ||
1171 | avgSendPingTicks = (nticksPing - 1) / (float)nticksPing * avgSendPingTicks + (watch2.ElapsedTicks / (float)nticksPing); | ||
1172 | watch2.Reset(); | ||
1173 | } | ||
1174 | |||
1175 | watch2.Start(); | ||
1176 | // Dequeue any outgoing packets that are within the throttle limits | ||
1177 | if (udpClient.DequeueOutgoing()) | ||
1178 | m_packetSent = true; | ||
1179 | watch2.Stop(); | ||
1180 | avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks); | ||
1181 | watch2.Reset(); | ||
1182 | |||
1183 | } | ||
1184 | else | ||
1185 | m_log.WarnFormat("[LLUDPSERVER]: Client is not connected"); | ||
1186 | } | ||
1187 | } | ||
1188 | catch (Exception ex) | ||
1189 | { | ||
1190 | m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name + | ||
1191 | " threw an exception: " + ex.Message, ex); | ||
1192 | } | ||
1193 | watch1.Stop(); | ||
1194 | avgProcessingTicks = (nticks - 1) / (float)nticks * avgProcessingTicks + (watch1.ElapsedTicks / (float)nticks); | ||
1195 | watch1.Reset(); | ||
1196 | |||
1197 | // reuse this -- it's every 100ms | ||
1198 | if (m_scene.EmergencyMonitoring && nticks % 100 == 0) | ||
1199 | { | ||
1200 | m_log.InfoFormat("[LLUDPSERVER]: avg processing ticks: {0} avg unacked: {1} avg acks: {2} avg ping: {3} avg dequeue: {4} (pack sent? {5})", | ||
1201 | avgProcessingTicks, avgResendUnackedTicks, avgSendAcksTicks, avgSendPingTicks, avgDequeueTicks, m_packetSent); | ||
1202 | } | ||
1203 | |||
1204 | } | ||
1205 | |||
1206 | #endregion | ||
1207 | |||
1108 | private void ProcessInPacket(object state) | 1208 | private void ProcessInPacket(object state) |
1109 | { | 1209 | { |
1110 | IncomingPacket incomingPacket = (IncomingPacket)state; | 1210 | IncomingPacket incomingPacket = (IncomingPacket)state; |