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.

bulletsim
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

@ -3590,7 +3590,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Remove the update packet from the list of packets waiting for acknowledgement // 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 // because we are requeuing the list of updates. They will be resent in new packets
// with the most recent state and priority. // 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) foreach (EntityUpdate update in updates)
ResendPrimUpdate(update); ResendPrimUpdate(update);
} }
@ -4038,7 +4042,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Remove the update packet from the list of packets waiting for acknowledgement // 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 // because we are requeuing the list of updates. They will be resent in new packets
// with the most recent state. // 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) foreach (ObjectPropertyUpdate update in updates)
ResendPropertyUpdate(update); ResendPropertyUpdate(update);
} }

View File

@ -83,6 +83,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <summary> /// <summary>
/// Marks a packet as acknowledged /// 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> /// </summary>
/// <param name="sequenceNumber">Sequence number of the packet to /// <param name="sequenceNumber">Sequence number of the packet to
/// acknowledge</param> /// acknowledge</param>
@ -94,6 +97,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_pendingRemoves.Enqueue(new PendingAck(sequenceNumber, currentTime, fromResend)); 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> /// <summary>
/// Returns a list of all of the packets with a TickCount older than /// Returns a list of all of the packets with a TickCount older than
/// the specified timeout /// the specified timeout