From 3640d0204f77dff3b1c4bd50229b60a49d2745e5 Mon Sep 17 00:00:00 2001
From: Dan Lake
Date: Thu, 21 Apr 2011 01:51:08 -0700
Subject: Added ability to remove unacked packet from UnackedPacketCollection
without an acknowledgement from the network. This prevents RTT and throttles
from being updated as they would when an ACK is actually received. Also fixed
stats logging for unacked bytes and resent packets in this case.
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 12 ++++++++--
.../LindenUDP/UnackedPacketCollection.cs | 28 ++++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 1e8bbb8..6129e10 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -3590,7 +3590,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Remove the update packet from the list of packets waiting for acknowledgement
// because we are requeuing the list of updates. They will be resent in new packets
// with the most recent state and priority.
- m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber, 0, true);
+ m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
+
+ // Count this as a resent packet since we are going to requeue all of the updates contained in it
+ Interlocked.Increment(ref m_udpClient.PacketsResent);
+
foreach (EntityUpdate update in updates)
ResendPrimUpdate(update);
}
@@ -4038,7 +4042,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Remove the update packet from the list of packets waiting for acknowledgement
// because we are requeuing the list of updates. They will be resent in new packets
// with the most recent state.
- m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber, 0, true);
+ m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
+
+ // Count this as a resent packet since we are going to requeue all of the updates contained in it
+ Interlocked.Increment(ref m_udpClient.PacketsResent);
+
foreach (ObjectPropertyUpdate update in updates)
ResendPropertyUpdate(update);
}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
index b170964..90a87fa 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
@@ -83,6 +83,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
///
/// Marks a packet as acknowledged
+ /// This method is used when an acknowledgement is received from the network for a previously
+ /// sent packet. Effects of removal this way are to update unacked byte count, adjust RTT
+ /// and increase throttle to the coresponding client.
///
/// Sequence number of the packet to
/// acknowledge
@@ -95,6 +98,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
///
+ /// Marks a packet as no longer needing acknowledgement without a received acknowledgement.
+ /// This method is called when a packet expires and we no longer need an acknowledgement.
+ /// When some reliable packet types expire, they are handled in a way other than simply
+ /// resending them. The only effect of removal this way is to update unacked byte count.
+ ///
+ /// Sequence number of the packet to
+ /// acknowledge
+ /// The packet is removed from the collection immediately.
+ /// This function is not threadsafe. It must be called by the thread calling GetExpiredPackets.
+ public void Remove(uint sequenceNumber)
+ {
+ OutgoingPacket removedPacket;
+ if (m_packets.TryGetValue(sequenceNumber, out removedPacket))
+ {
+ if (removedPacket != null)
+ {
+ m_packets.Remove(sequenceNumber);
+
+ // Update stats
+ Interlocked.Add(ref removedPacket.Client.UnackedBytes, -removedPacket.Buffer.DataLength);
+ }
+ }
+ }
+
+ ///
/// Returns a list of all of the packets with a TickCount older than
/// the specified timeout
///
--
cgit v1.1