diff options
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 75 |
1 files changed, 70 insertions, 5 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index d310d65..3bdde3b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -163,6 +163,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
163 | 163 | ||
164 | private int m_malformedCount = 0; // Guard against a spamming attack | 164 | private int m_malformedCount = 0; // Guard against a spamming attack |
165 | 165 | ||
166 | /// <summary> | ||
167 | /// Record current outgoing client for monitoring purposes. | ||
168 | /// </summary> | ||
169 | private IClientAPI m_currentOutgoingClient; | ||
170 | |||
171 | /// <summary> | ||
172 | /// Recording current incoming client for monitoring purposes. | ||
173 | /// </summary> | ||
174 | private IClientAPI m_currentIncomingClient; | ||
175 | |||
166 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) | 176 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) |
167 | : base(listenIP, (int)port) | 177 | : base(listenIP, (int)port) |
168 | { | 178 | { |
@@ -244,19 +254,56 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
244 | if (m_scene == null) | 254 | if (m_scene == null) |
245 | throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference"); | 255 | throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference"); |
246 | 256 | ||
247 | m_log.Info("[LLUDPSERVER]: Starting the LLUDP server in " + (m_asyncPacketHandling ? "asynchronous" : "synchronous") + " mode"); | 257 | m_log.InfoFormat( |
258 | "[LLUDPSERVER]: Starting the LLUDP server in {0} mode", | ||
259 | m_asyncPacketHandling ? "asynchronous" : "synchronous"); | ||
248 | 260 | ||
249 | base.Start(m_recvBufferSize, m_asyncPacketHandling); | 261 | base.Start(m_recvBufferSize, m_asyncPacketHandling); |
250 | 262 | ||
251 | // Start the packet processing threads | 263 | // Start the packet processing threads |
252 | Watchdog.StartThread( | 264 | Watchdog.StartThread( |
253 | IncomingPacketHandler, "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false, true); | 265 | IncomingPacketHandler, |
266 | string.Format("Incoming Packets ({0})", m_scene.RegionInfo.RegionName), | ||
267 | ThreadPriority.Normal, | ||
268 | false, | ||
269 | true, | ||
270 | GetWatchdogIncomingAlarmData, | ||
271 | Watchdog.WATCHDOG_TIMEOUT_MS); | ||
272 | |||
254 | Watchdog.StartThread( | 273 | Watchdog.StartThread( |
255 | OutgoingPacketHandler, "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false, true); | 274 | OutgoingPacketHandler, |
275 | string.Format("Outgoing Packets ({0})", m_scene.RegionInfo.RegionName), | ||
276 | ThreadPriority.Normal, | ||
277 | false, | ||
278 | true, | ||
279 | GetWatchdogOutgoingAlarmData, | ||
280 | Watchdog.WATCHDOG_TIMEOUT_MS); | ||
256 | 281 | ||
257 | m_elapsedMSSinceLastStatReport = Environment.TickCount; | 282 | m_elapsedMSSinceLastStatReport = Environment.TickCount; |
258 | } | 283 | } |
259 | 284 | ||
285 | /// <summary> | ||
286 | /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. | ||
287 | /// </summary> | ||
288 | /// <returns></returns> | ||
289 | private string GetWatchdogIncomingAlarmData() | ||
290 | { | ||
291 | return string.Format( | ||
292 | "Client is {0}", | ||
293 | m_currentIncomingClient != null ? m_currentIncomingClient.Name : "none"); | ||
294 | } | ||
295 | |||
296 | /// <summary> | ||
297 | /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. | ||
298 | /// </summary> | ||
299 | /// <returns></returns> | ||
300 | private string GetWatchdogOutgoingAlarmData() | ||
301 | { | ||
302 | return string.Format( | ||
303 | "Client is {0}", | ||
304 | m_currentOutgoingClient != null ? m_currentOutgoingClient.Name : "none"); | ||
305 | } | ||
306 | |||
260 | public new void Stop() | 307 | public new void Stop() |
261 | { | 308 | { |
262 | m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName); | 309 | m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName); |
@@ -1067,6 +1114,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1067 | client.IsLoggingOut = true; | 1114 | client.IsLoggingOut = true; |
1068 | client.Close(false); | 1115 | client.Close(false); |
1069 | } | 1116 | } |
1117 | else | ||
1118 | { | ||
1119 | m_log.WarnFormat( | ||
1120 | "[LLUDPSERVER]: Tried to remove client with id {0} but not such client in {1}", | ||
1121 | udpClient.AgentID, m_scene.RegionInfo.RegionName); | ||
1122 | } | ||
1070 | } | 1123 | } |
1071 | 1124 | ||
1072 | private void IncomingPacketHandler() | 1125 | private void IncomingPacketHandler() |
@@ -1175,6 +1228,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1175 | // client. m_packetSent will be set to true if a packet is sent | 1228 | // client. m_packetSent will be set to true if a packet is sent |
1176 | m_scene.ForEachClient(clientPacketHandler); | 1229 | m_scene.ForEachClient(clientPacketHandler); |
1177 | 1230 | ||
1231 | m_currentOutgoingClient = null; | ||
1232 | |||
1178 | // If nothing was sent, sleep for the minimum amount of time before a | 1233 | // If nothing was sent, sleep for the minimum amount of time before a |
1179 | // token bucket could get more tokens | 1234 | // token bucket could get more tokens |
1180 | if (!m_packetSent) | 1235 | if (!m_packetSent) |
@@ -1193,6 +1248,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1193 | 1248 | ||
1194 | private void ClientOutgoingPacketHandler(IClientAPI client) | 1249 | private void ClientOutgoingPacketHandler(IClientAPI client) |
1195 | { | 1250 | { |
1251 | m_currentOutgoingClient = client; | ||
1252 | |||
1196 | try | 1253 | try |
1197 | { | 1254 | { |
1198 | if (client is LLClientView) | 1255 | if (client is LLClientView) |
@@ -1218,8 +1275,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1218 | } | 1275 | } |
1219 | catch (Exception ex) | 1276 | catch (Exception ex) |
1220 | { | 1277 | { |
1221 | m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name + | 1278 | m_log.Error( |
1222 | " threw an exception: " + ex.Message, ex); | 1279 | string.Format("[LLUDPSERVER]: OutgoingPacketHandler iteration for {0} threw ", client.Name), ex); |
1223 | } | 1280 | } |
1224 | } | 1281 | } |
1225 | 1282 | ||
@@ -1245,6 +1302,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1245 | { | 1302 | { |
1246 | nticks++; | 1303 | nticks++; |
1247 | watch1.Start(); | 1304 | watch1.Start(); |
1305 | m_currentOutgoingClient = client; | ||
1306 | |||
1248 | try | 1307 | try |
1249 | { | 1308 | { |
1250 | if (client is LLClientView) | 1309 | if (client is LLClientView) |
@@ -1346,6 +1405,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1346 | // Make sure this client is still alive | 1405 | // Make sure this client is still alive |
1347 | if (m_scene.TryGetClient(udpClient.AgentID, out client)) | 1406 | if (m_scene.TryGetClient(udpClient.AgentID, out client)) |
1348 | { | 1407 | { |
1408 | m_currentIncomingClient = client; | ||
1409 | |||
1349 | try | 1410 | try |
1350 | { | 1411 | { |
1351 | // Process this packet | 1412 | // Process this packet |
@@ -1363,6 +1424,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1363 | m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", udpClient.AgentID, packet.Type); | 1424 | m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", udpClient.AgentID, packet.Type); |
1364 | m_log.Error(e.Message, e); | 1425 | m_log.Error(e.Message, e); |
1365 | } | 1426 | } |
1427 | finally | ||
1428 | { | ||
1429 | m_currentIncomingClient = null; | ||
1430 | } | ||
1366 | } | 1431 | } |
1367 | else | 1432 | else |
1368 | { | 1433 | { |