From b0cbf16c19495814920e138deba4d1bb47615582 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 26 Apr 2012 16:04:49 +0100
Subject: minor: Add region name to dropped inbound packet message
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index fb6b11e..d05f72f 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1350,7 +1350,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
else
{
- m_log.DebugFormat("[LLUDPSERVER]: Dropping incoming {0} packet for dead client {1}", packet.Type, udpClient.AgentID);
+ m_log.DebugFormat(
+ "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}",
+ packet.Type, udpClient.AgentID, m_scene.RegionInfo.RegionName);
}
}
--
cgit v1.1
From cb6791fb30ce0fbe416f42d95b9737f9f30e02a7 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 26 Apr 2012 22:35:25 +0100
Subject: Tweak log messages on local region to region teleport path to help
with problem resolution.
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index d05f72f..edf91cb 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -916,7 +916,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UDPPacketBuffer buffer = (UDPPacketBuffer)array[0];
UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1];
- m_log.DebugFormat("[LLUDPSERVER]: Handling UseCircuitCode request from {0}", buffer.RemoteEndPoint);
+ m_log.DebugFormat(
+ "[LLUDPSERVER]: Handling UseCircuitCode request for circuit {0} from {1}",
+ uccp.CircuitCode.Code, buffer.RemoteEndPoint);
remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
--
cgit v1.1
From 008c6a4610fa7b710a9e2546cc09d9fee57e5795 Mon Sep 17 00:00:00 2001
From: Talun
Date: Fri, 1 Jun 2012 00:39:26 +0100
Subject: Mantis 4597 AgentPaused packet is ignored.
The packet was actually being handled but not acted on.
This change extends the default timeout for paused clients to 5 minutes
and makes both the paused and non-paused timeout periods configurable.
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index edf91cb..32ba590 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -155,7 +155,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private int m_defaultRTO = 0;
private int m_maxRTO = 0;
-
+ private int m_ackTimeout = 0;
+ private int m_pausedAckTimeout = 0;
private bool m_disableFacelights = false;
public Socket Server { get { return null; } }
@@ -198,11 +199,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_defaultRTO = config.GetInt("DefaultRTO", 0);
m_maxRTO = config.GetInt("MaxRTO", 0);
m_disableFacelights = config.GetBoolean("DisableFacelights", false);
+ m_ackTimeout = 1000 * config.GetInt("AckTimeout", 60);
+ m_pausedAckTimeout = 1000 * config.GetInt("PausedAckTimeout", 300);
}
else
{
PrimUpdatesPerCallback = 100;
TextureSendLimit = 20;
+ m_ackTimeout = 1000 * 60; // 1 minute
+ m_pausedAckTimeout = 1000 * 300; // 5 minutes
}
#region BinaryStats
@@ -491,8 +496,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return;
// Disconnect an agent if no packets are received for some time
- //FIXME: Make 60 an .ini setting
- if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60)
+ int timeoutTicks = m_ackTimeout;
+
+ // Allow more slack if the client is "paused" eg file upload dialogue is open
+ // Some sort of limit is needed in case the client crashes, loses its network connection
+ // or some other disaster prevents it from sendung the AgentResume
+ if (udpClient.IsPaused)
+ timeoutTicks = m_pausedAckTimeout;
+
+ if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > timeoutTicks)
{
m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
--
cgit v1.1
From 98b46d48fefc7801b7c9e496000e9329f4266e5e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 7 Jun 2012 02:44:13 +0100
Subject: Allow the thread watchdog to accept an alarm method that is invoked
if the timeout is breached.
This alarm can then invoke this to log extra information.
This is used in LLUDPServer to show which client was being processed when incoming and outgoing udp watchdog alarms are triggered.
---
.../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 69 ++++++++++++++++++++--
1 file changed, 64 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 32ba590..e37adb8 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
private int m_malformedCount = 0; // Guard against a spamming attack
+ ///
+ /// Record current outgoing client for monitoring purposes.
+ ///
+ private IClientAPI m_currentOutgoingClient;
+
+ ///
+ /// Recording current incoming client for monitoring purposes.
+ ///
+ private IClientAPI m_currentIncomingClient;
+
public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
: base(listenIP, (int)port)
{
@@ -244,19 +254,56 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (m_scene == null)
throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference");
- m_log.Info("[LLUDPSERVER]: Starting the LLUDP server in " + (m_asyncPacketHandling ? "asynchronous" : "synchronous") + " mode");
+ m_log.InfoFormat(
+ "[LLUDPSERVER]: Starting the LLUDP server in {0} mode",
+ m_asyncPacketHandling ? "asynchronous" : "synchronous");
base.Start(m_recvBufferSize, m_asyncPacketHandling);
// Start the packet processing threads
Watchdog.StartThread(
- IncomingPacketHandler, "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false, true);
+ IncomingPacketHandler,
+ string.Format("Incoming Packets ({0})", m_scene.RegionInfo.RegionName),
+ ThreadPriority.Normal,
+ false,
+ true,
+ GetWatchdogIncomingAlarmData,
+ Watchdog.WATCHDOG_TIMEOUT_MS);
+
Watchdog.StartThread(
- OutgoingPacketHandler, "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false, true);
+ OutgoingPacketHandler,
+ string.Format("Outgoing Packets ({0})", m_scene.RegionInfo.RegionName),
+ ThreadPriority.Normal,
+ false,
+ true,
+ GetWatchdogOutgoingAlarmData,
+ Watchdog.WATCHDOG_TIMEOUT_MS);
m_elapsedMSSinceLastStatReport = Environment.TickCount;
}
+ ///
+ /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
+ ///
+ ///
+ private string GetWatchdogIncomingAlarmData()
+ {
+ return string.Format(
+ "Client is {0}",
+ m_currentIncomingClient != null ? m_currentIncomingClient.Name : "none");
+ }
+
+ ///
+ /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
+ ///
+ ///
+ private string GetWatchdogOutgoingAlarmData()
+ {
+ return string.Format(
+ "Client is {0}",
+ m_currentOutgoingClient != null ? m_currentOutgoingClient.Name : "none");
+ }
+
public new void Stop()
{
m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName);
@@ -1173,6 +1220,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// client. m_packetSent will be set to true if a packet is sent
m_scene.ForEachClient(clientPacketHandler);
+ m_currentOutgoingClient = null;
+
// If nothing was sent, sleep for the minimum amount of time before a
// token bucket could get more tokens
if (!m_packetSent)
@@ -1191,6 +1240,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void ClientOutgoingPacketHandler(IClientAPI client)
{
+ m_currentOutgoingClient = client;
+
try
{
if (client is LLClientView)
@@ -1216,8 +1267,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
catch (Exception ex)
{
- m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name +
- " threw an exception: " + ex.Message, ex);
+ m_log.Error(
+ string.Format("[LLUDPSERVER]: OutgoingPacketHandler iteration for {0} threw ", client.Name), ex);
}
}
@@ -1243,6 +1294,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
nticks++;
watch1.Start();
+ m_currentOutgoingClient = client;
+
try
{
if (client is LLClientView)
@@ -1344,6 +1397,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Make sure this client is still alive
if (m_scene.TryGetClient(udpClient.AgentID, out client))
{
+ m_currentIncomingClient = client;
+
try
{
// Process this packet
@@ -1361,6 +1416,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", udpClient.AgentID, packet.Type);
m_log.Error(e.Message, e);
}
+ finally
+ {
+ m_currentIncomingClient = null;
+ }
}
else
{
--
cgit v1.1
From 7550b97e65fa873b42624648747cec3e12a8e689 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 7 Jun 2012 04:00:29 +0100
Subject: Log warning if we try to remove a UDP client that has already been
removed.
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index e37adb8..09bb52c 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1114,6 +1114,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
client.IsLoggingOut = true;
client.Close();
}
+ else
+ {
+ m_log.WarnFormat(
+ "[LLUDPSERVER]: Tried to remove client with id {0} but not such client in {1}",
+ udpClient.AgentID, m_scene.RegionInfo.RegionName);
+ }
}
private void IncomingPacketHandler()
--
cgit v1.1
From d71c6dea7e5bfe827a9d723d972a9eec4cb77826 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 8 Jun 2012 01:43:58 +0100
Subject: Store already retrieve IClientAPI in IncomingPacket structure for
later use rather than doing another retrieve on dequeue.
Instead of checking whether the client still exists by trying to retrieve again from the client manager, this patch gets it back from IncomingPacket and checks the IClientAPI.IsActive state.
---
.../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 26 +++++++++++-----------
1 file changed, 13 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 09bb52c..55bda63 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -879,7 +879,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion Ping Check Handling
// Inbox insertion
- packetInbox.Enqueue(new IncomingPacket(udpClient, packet));
+ packetInbox.Enqueue(new IncomingPacket((LLClientView)client, packet));
}
#region BinaryStats
@@ -1386,22 +1386,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion
- private void ProcessInPacket(object state)
+ private void ProcessInPacket(IncomingPacket incomingPacket)
{
- IncomingPacket incomingPacket = (IncomingPacket)state;
Packet packet = incomingPacket.Packet;
- LLUDPClient udpClient = incomingPacket.Client;
- IClientAPI client;
+ LLClientView client = incomingPacket.Client;
// Sanity check
- if (packet == null || udpClient == null)
+ if (packet == null || client == null)
{
- m_log.WarnFormat("[LLUDPSERVER]: Processing a packet with incomplete state. Packet=\"{0}\", UDPClient=\"{1}\"",
- packet, udpClient);
+ m_log.WarnFormat("[LLUDPSERVER]: Processing a packet with incomplete state. Packet=\"{0}\", Client=\"{1}\"",
+ packet, client);
}
- // Make sure this client is still alive
- if (m_scene.TryGetClient(udpClient.AgentID, out client))
+ if (client.IsActive)
{
m_currentIncomingClient = client;
@@ -1419,8 +1416,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
catch (Exception e)
{
// Don't let a failure in an individual client thread crash the whole sim.
- m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", udpClient.AgentID, packet.Type);
- m_log.Error(e.Message, e);
+ m_log.Error(
+ string.Format(
+ "[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw ",
+ client.Name, packet.Type),
+ e);
}
finally
{
@@ -1431,7 +1431,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
m_log.DebugFormat(
"[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}",
- packet.Type, udpClient.AgentID, m_scene.RegionInfo.RegionName);
+ packet.Type, client.Name, m_scene.RegionInfo.RegionName);
}
}
--
cgit v1.1
From d73805d7f488e45a00a2d25c08876d400083d27f Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 8 Jun 2012 01:51:28 +0100
Subject: Remove null checks at top of LLUDPServer.ProcessInPacket(). Neither
packet nor client are ever null.
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 55bda63..a292a6c 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1391,13 +1391,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Packet packet = incomingPacket.Packet;
LLClientView client = incomingPacket.Client;
- // Sanity check
- if (packet == null || client == null)
- {
- m_log.WarnFormat("[LLUDPSERVER]: Processing a packet with incomplete state. Packet=\"{0}\", Client=\"{1}\"",
- packet, client);
- }
-
if (client.IsActive)
{
m_currentIncomingClient = client;
@@ -1442,4 +1435,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP
RemoveClient(((LLClientView)client).UDPClient);
}
}
-}
+}
\ No newline at end of file
--
cgit v1.1
From 5f4f9f02309b7df4d1bdcc560cee96d266c48a07 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 8 Jun 2012 03:12:23 +0100
Subject: Add regression test for client logout due to ack timeout.
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index a292a6c..58a3b1c 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -147,11 +147,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private int m_elapsed500MSOutgoingPacketHandler;
/// Flag to signal when clients should check for resends
- private bool m_resendUnacked;
+ protected bool m_resendUnacked;
+
/// Flag to signal when clients should send ACKs
- private bool m_sendAcks;
+ protected bool m_sendAcks;
+
/// Flag to signal when clients should send pings
- private bool m_sendPing;
+ protected bool m_sendPing;
private int m_defaultRTO = 0;
private int m_maxRTO = 0;
@@ -1244,7 +1246,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Watchdog.RemoveThread();
}
- private void ClientOutgoingPacketHandler(IClientAPI client)
+ protected void ClientOutgoingPacketHandler(IClientAPI client)
{
m_currentOutgoingClient = client;
--
cgit v1.1
From c215b1ad169cb8c3add70622f610e980ee9cfa31 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 8 Jun 2012 03:53:03 +0100
Subject: If logging a client out due to ack timeout, do this asynchronously
rather than synchronously on the outgoing packet loop.
This is the same async behaviour as normal logouts.
This is necessary because the event queue will sleep the thread for 5 seconds on an ack timeout logout as the client isn't around to pick up the final event queue messages.
---
.../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 26 +++++++++++++++-------
1 file changed, 18 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 58a3b1c..e1fccb5 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -539,8 +539,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false, null);
}
- public void HandleUnacked(LLUDPClient udpClient)
+ public void HandleUnacked(LLClientView client)
{
+ LLUDPClient udpClient = client.UDPClient;
+
if (!udpClient.IsConnected)
return;
@@ -553,12 +555,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (udpClient.IsPaused)
timeoutTicks = m_pausedAckTimeout;
- if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > timeoutTicks)
+ if (!client.IsLoggingOut &&
+ (Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > timeoutTicks)
{
m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
-
RemoveClient(udpClient);
+
return;
}
@@ -1113,8 +1116,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
IClientAPI client;
if (m_scene.TryGetClient(udpClient.AgentID, out client))
{
+ // We must set IsLoggingOut synchronously so that we can stop the packet loop reinvoking this method.
client.IsLoggingOut = true;
- client.Close();
+
+ // Fire this out on a different thread so that we don't hold up outgoing packet processing for
+ // everybody else if this is being called due to an ack timeout.
+ // This is the same as processing as the async process of a logout request.
+ Util.FireAndForget(o => client.Close());
}
else
{
@@ -1254,12 +1262,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
if (client is LLClientView)
{
- LLUDPClient udpClient = ((LLClientView)client).UDPClient;
+ LLClientView llClient = (LLClientView)client;
+ LLUDPClient udpClient = llClient.UDPClient;
if (udpClient.IsConnected)
{
if (m_resendUnacked)
- HandleUnacked(udpClient);
+ HandleUnacked(llClient);
if (m_sendAcks)
SendAcks(udpClient);
@@ -1308,7 +1317,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
if (client is LLClientView)
{
- LLUDPClient udpClient = ((LLClientView)client).UDPClient;
+ LLClientView llClient = (LLClientView)client;
+ LLUDPClient udpClient = llClient.UDPClient;
if (udpClient.IsConnected)
{
@@ -1317,7 +1327,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
nticksUnack++;
watch2.Start();
- HandleUnacked(udpClient);
+ HandleUnacked(llClient);
watch2.Stop();
avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack);
--
cgit v1.1
From f94b92df4646162c0a8f37dd3373c6c2a20c66e3 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 8 Jun 2012 04:12:22 +0100
Subject: Instead of retrieving the known client again in
LLUDPServer.RemoveClient(), check the IsLoggingOut flag instead.
This is slightly better thread-race wise
---
.../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 31 +++++++---------------
1 file changed, 10 insertions(+), 21 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index e1fccb5..7f86491 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -560,7 +560,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
- RemoveClient(udpClient);
+ RemoveClient(client);
return;
}
@@ -1110,26 +1110,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return client;
}
- private void RemoveClient(LLUDPClient udpClient)
+ private void RemoveClient(IClientAPI client)
{
- // Remove this client from the scene
- IClientAPI client;
- if (m_scene.TryGetClient(udpClient.AgentID, out client))
- {
- // We must set IsLoggingOut synchronously so that we can stop the packet loop reinvoking this method.
- client.IsLoggingOut = true;
+ // We must set IsLoggingOut synchronously so that we can stop the packet loop reinvoking this method.
+ client.IsLoggingOut = true;
- // Fire this out on a different thread so that we don't hold up outgoing packet processing for
- // everybody else if this is being called due to an ack timeout.
- // This is the same as processing as the async process of a logout request.
- Util.FireAndForget(o => client.Close());
- }
- else
- {
- m_log.WarnFormat(
- "[LLUDPSERVER]: Tried to remove client with id {0} but not such client in {1}",
- udpClient.AgentID, m_scene.RegionInfo.RegionName);
- }
+ // Fire this out on a different thread so that we don't hold up outgoing packet processing for
+ // everybody else if this is being called due to an ack timeout.
+ // This is the same as processing as the async process of a logout request.
+ Util.FireAndForget(o => client.Close());
}
private void IncomingPacketHandler()
@@ -1443,8 +1432,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected void LogoutHandler(IClientAPI client)
{
client.SendLogoutPacket();
- if (client.IsActive)
- RemoveClient(((LLClientView)client).UDPClient);
+ if (!client.IsLoggingOut)
+ RemoveClient(client);
}
}
}
\ No newline at end of file
--
cgit v1.1
From c89db34fc4372be7ff94d92472131b2c33de8605 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 12 Jun 2012 02:03:31 +0100
Subject: If the simulator closes a root agent due to ack timeout, then send
the client a kick message with that reason, in case it is somehow still
listening.
---
.../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 7f86491..2036f61 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -558,9 +558,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!client.IsLoggingOut &&
(Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > timeoutTicks)
{
- m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
+ m_log.WarnFormat(
+ "[LLUDPSERVER]: Ack timeout for {0} {1}, disconnecting",
+ client.Name, client.AgentId);
+
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
- RemoveClient(client);
+ LogoutClientDueToTimeout(client);
return;
}
@@ -1121,6 +1124,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Util.FireAndForget(o => client.Close());
}
+ private void LogoutClientDueToTimeout(IClientAPI client)
+ {
+ // We must set IsLoggingOut synchronously so that we can stop the packet loop reinvoking this method.
+ client.IsLoggingOut = true;
+
+ // Fire this out on a different thread so that we don't hold up outgoing packet processing for
+ // everybody else if this is being called due to an ack timeout.
+ // This is the same as processing as the async process of a logout request.
+ Util.FireAndForget(
+ o =>
+ { if (!client.SceneAgent.IsChildAgent)
+ client.Kick("Simulator logged you out due to connection timeout");
+ client.Close(); });
+ }
+
private void IncomingPacketHandler()
{
// Set this culture for the thread that incoming packets are received
--
cgit v1.1
From b099f26376a7d671eeb9113dd7611cfcb0e57de0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 12 Jun 2012 02:16:36 +0100
Subject: Set IClientAPI.IsActive = false early on client removal due to ack
timeout rather than using IsLoggingOut flag.
IsActive is more appropriate since unack timeout is not due to voluntary logout.
This is in line with operations such as manual kick that do not set the IsLoggingOut flag.
It's also slightly better race-wise since it reduces the chance of this operation clashing with another reason for client deactivation (e.g. manual kick).
---
.../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 64 ++++++++++++----------
1 file changed, 35 insertions(+), 29 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 2036f61..37d2943 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -555,15 +555,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (udpClient.IsPaused)
timeoutTicks = m_pausedAckTimeout;
- if (!client.IsLoggingOut &&
+ if (client.IsActive &&
(Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > timeoutTicks)
{
- m_log.WarnFormat(
- "[LLUDPSERVER]: Ack timeout for {0} {1}, disconnecting",
- client.Name, client.AgentId);
+ // We must set IsActive synchronously so that we can stop the packet loop reinvoking this method, even
+ // though it's set later on by LLClientView.Close()
+ client.IsActive = false;
- StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
- LogoutClientDueToTimeout(client);
+ // Fire this out on a different thread so that we don't hold up outgoing packet processing for
+ // everybody else if this is being called due to an ack timeout.
+ // This is the same as processing as the async process of a logout request.
+ Util.FireAndForget(o => DeactivateClientDueToTimeout(client));
return;
}
@@ -792,7 +794,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Interlocked.Increment(ref udpClient.PacketsReceived);
int now = Environment.TickCount & Int32.MaxValue;
- udpClient.TickLastPacketReceived = now;
+// udpClient.TickLastPacketReceived = now;
#region ACK Receiving
@@ -1113,30 +1115,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return client;
}
- private void RemoveClient(IClientAPI client)
+ ///
+ /// Deactivates the client if we don't receive any packets within a certain amount of time (default 60 seconds).
+ ///
+ ///
+ /// If a connection is active then we will always receive packets even if nothing else is happening, due to
+ /// regular client pings.
+ ///
+ ///
+ private void DeactivateClientDueToTimeout(IClientAPI client)
{
- // We must set IsLoggingOut synchronously so that we can stop the packet loop reinvoking this method.
- client.IsLoggingOut = true;
+ // We must set IsActive synchronously so that we can stop the packet loop reinvoking this method, even
+ // though it's set later on by LLClientView.Close()
+ client.IsActive = false;
- // Fire this out on a different thread so that we don't hold up outgoing packet processing for
- // everybody else if this is being called due to an ack timeout.
- // This is the same as processing as the async process of a logout request.
- Util.FireAndForget(o => client.Close());
- }
+ m_log.WarnFormat(
+ "[LLUDPSERVER]: Ack timeout, disconnecting {0} agent for {1} in {2}",
+ client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, m_scene.RegionInfo.RegionName);
- private void LogoutClientDueToTimeout(IClientAPI client)
- {
- // We must set IsLoggingOut synchronously so that we can stop the packet loop reinvoking this method.
- client.IsLoggingOut = true;
-
- // Fire this out on a different thread so that we don't hold up outgoing packet processing for
- // everybody else if this is being called due to an ack timeout.
- // This is the same as processing as the async process of a logout request.
- Util.FireAndForget(
- o =>
- { if (!client.SceneAgent.IsChildAgent)
- client.Kick("Simulator logged you out due to connection timeout");
- client.Close(); });
+ StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
+
+ if (!client.SceneAgent.IsChildAgent)
+ client.Kick("Simulator logged you out due to connection timeout");
+
+ client.Close();
}
private void IncomingPacketHandler()
@@ -1450,8 +1452,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected void LogoutHandler(IClientAPI client)
{
client.SendLogoutPacket();
+
if (!client.IsLoggingOut)
- RemoveClient(client);
+ {
+ client.IsLoggingOut = true;
+ client.Close();
+ }
}
}
}
\ No newline at end of file
--
cgit v1.1
From 2ca31a9841991f748e972c96a3eba96e611f1dea Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 12 Jun 2012 02:46:14 +0100
Subject: Remove accidental timeout left in during earlier debugging. Has been
in since two commits ago (b099f26)
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 37d2943..5126d84 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -794,7 +794,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Interlocked.Increment(ref udpClient.PacketsReceived);
int now = Environment.TickCount & Int32.MaxValue;
-// udpClient.TickLastPacketReceived = now;
+ udpClient.TickLastPacketReceived = now;
#region ACK Receiving
--
cgit v1.1
From aaa30dcebc223d74d59ecb5d9f8e1e69532efb7c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 15 Jun 2012 05:01:36 +0100
Subject: Add region name to UseCircuitCode log messages
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 5126d84..44c65e0 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -986,8 +986,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1];
m_log.DebugFormat(
- "[LLUDPSERVER]: Handling UseCircuitCode request for circuit {0} from {1}",
- uccp.CircuitCode.Code, buffer.RemoteEndPoint);
+ "[LLUDPSERVER]: Handling UseCircuitCode request for circuit {0} to {1} from IP {2}",
+ uccp.CircuitCode.Code, m_scene.RegionInfo.RegionName, buffer.RemoteEndPoint);
remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
@@ -1016,8 +1016,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
// Don't create clients for unauthorized requesters.
m_log.WarnFormat(
- "[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
- uccp.CircuitCode.ID, uccp.CircuitCode.Code, remoteEndPoint);
+ "[LLUDPSERVER]: Ignoring connection request for {0} to {1} with unknown circuit code {2} from IP {3}",
+ uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, remoteEndPoint);
}
// m_log.DebugFormat(
--
cgit v1.1
From 5691a8b860b22939e2b608d6d8400b5260b25cf3 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 4 Jul 2012 00:15:03 +0100
Subject: refactor: rename Watchdog.WATCHDOG_TIMEOUT_MS to
DEFAULT_WATCHDOG_TIMEOUT_MS to reflect what it actually is
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 44c65e0..468d524 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -270,7 +270,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
false,
true,
GetWatchdogIncomingAlarmData,
- Watchdog.WATCHDOG_TIMEOUT_MS);
+ Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
Watchdog.StartThread(
OutgoingPacketHandler,
@@ -279,7 +279,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
false,
true,
GetWatchdogOutgoingAlarmData,
- Watchdog.WATCHDOG_TIMEOUT_MS);
+ Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
m_elapsedMSSinceLastStatReport = Environment.TickCount;
}
--
cgit v1.1
From d6f54b25cd8e3d7a465e9875d2e00dd414a1b019 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 12 Jul 2012 23:48:42 +0100
Subject: Stop redundantly passing in the endpoint to the LLClientView
constructor.
This can always be retrieved via the LLUDPClient and is so done in various places already.
---
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 468d524..097f109 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1103,7 +1103,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
- client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
+ client = new LLClientView(m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
client.OnLogout += LogoutHandler;
((LLClientView)client).DisableFacelights = m_disableFacelights;
--
cgit v1.1