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.

This commit is contained in:
Dan Lake
2011-04-21 01:51:08 -07:00
parent b5ab33b5e1
commit 3640d0204f
2 changed files with 38 additions and 2 deletions

View File

@@ -83,6 +83,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <summary>
/// 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.
/// </summary>
/// <param name="sequenceNumber">Sequence number of the packet to
/// acknowledge</param>
@@ -94,6 +97,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_pendingRemoves.Enqueue(new PendingAck(sequenceNumber, currentTime, fromResend));
}
/// <summary>
/// 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.
/// </summary>
/// <param name="sequenceNumber">Sequence number of the packet to
/// acknowledge</param>
/// <remarks>The packet is removed from the collection immediately.
/// This function is not threadsafe. It must be called by the thread calling GetExpiredPackets.</remarks>
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);
}
}
}
/// <summary>
/// Returns a list of all of the packets with a TickCount older than
/// the specified timeout