From fb19d1ca0a7c6e82c540c4e8d22c82c09b7bec98 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Tue, 6 Oct 2009 10:12:59 -0700
Subject: * Try/catch around EndInvoke() when Util.FireAndForget() returns to
catch exceptions thrown in the async method * Added packet stats handling to
the new LLUDP implementation * Attempting to avoid a race condition when
creating a new LLUDPClient
---
.../Region/ClientStack/LindenUDP/LLUDPClient.cs | 40 ++++++++++++++++------
1 file changed, 30 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index ad01135..f2e76d3 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -33,6 +33,7 @@ using OpenMetaverse;
namespace OpenSim.Region.ClientStack.LindenUDP
{
+ public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes);
public delegate void QueueEmpty(ThrottleOutPacketType category);
public class LLUDPClient
@@ -41,6 +42,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// or removed, this number must also change
const int THROTTLE_CATEGORY_COUNT = 7;
+ public event PacketStats OnPacketStats;
public event QueueEmpty OnQueueEmpty;
/// AgentID for this client
@@ -84,6 +86,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// Number of bytes received since the last acknowledgement was sent out. This is used
/// to loosely follow the TCP delayed ACK algorithm in RFC 1122 (4.2.3.2)
public int BytesSinceLastACK;
+ /// Number of packets received from this client
+ public int PacketsReceived;
+ /// Number of packets sent to this client
+ public int PacketsSent;
+ /// Total byte count of unacked packets sent to this client
+ public int UnackedBytes;
+
+ /// Total number of received packets that we have reported to the OnPacketStats event(s)
+ private int m_packetsReceivedReported;
+ /// Total number of sent packets that we have reported to the OnPacketStats event(s)
+ private int m_packetsSentReported;
/// Throttle bucket for this agent's connection
private readonly TokenBucket throttle;
@@ -162,17 +175,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public string GetStats()
{
+ // TODO: ???
return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0);
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ }
+
+ public void SendPacketStats()
+ {
+ PacketStats callback = OnPacketStats;
+ if (callback != null)
+ {
+ int newPacketsReceived = PacketsReceived - m_packetsReceivedReported;
+ int newPacketsSent = PacketsSent - m_packetsSentReported;
+
+ callback(newPacketsReceived, newPacketsSent, UnackedBytes);
+
+ m_packetsReceivedReported += newPacketsReceived;
+ m_packetsSentReported += newPacketsSent;
+ }
}
public void SetThrottles(byte[] throttleData)
--
cgit v1.1