aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs47
1 files changed, 16 insertions, 31 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
index c19e6a2..e43f7cf 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
@@ -1,4 +1,4 @@
1 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -139,43 +139,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
139 private void ProcessQueues() 139 private void ProcessQueues()
140 { 140 {
141 // Process all the pending adds 141 // Process all the pending adds
142
143 OutgoingPacket pendingAdd; 142 OutgoingPacket pendingAdd;
144 if (m_pendingAdds != null) 143 while (m_pendingAdds.Dequeue(out pendingAdd))
145 { 144 m_packets[pendingAdd.SequenceNumber] = pendingAdd;
146 while (m_pendingAdds.TryDequeue(out pendingAdd)) 145
147 {
148 if (pendingAdd != null && m_packets != null)
149 {
150 m_packets[pendingAdd.SequenceNumber] = pendingAdd;
151 }
152 }
153 }
154
155 // Process all the pending removes, including updating statistics and round-trip times 146 // Process all the pending removes, including updating statistics and round-trip times
156 PendingAck pendingRemove; 147 PendingAck pendingRemove;
157 OutgoingPacket ackedPacket; 148 OutgoingPacket ackedPacket;
158 if (m_pendingRemoves != null) 149 while (m_pendingRemoves.Dequeue(out pendingRemove))
159 { 150 {
160 while (m_pendingRemoves.TryDequeue(out pendingRemove)) 151 if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket))
161 { 152 {
162 if (m_pendingRemoves != null && m_packets != null) 153 m_packets.Remove(pendingRemove.SequenceNumber);
154
155 // Update stats
156 System.Threading.Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength);
157
158 if (!pendingRemove.FromResend)
163 { 159 {
164 if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) 160 // Calculate the round-trip time for this packet and its ACK
165 { 161 int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount;
166 m_packets.Remove(pendingRemove.SequenceNumber); 162 if (rtt > 0)
167 163 ackedPacket.Client.UpdateRoundTrip(rtt);
168 // Update stats
169 System.Threading.Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength);
170
171 if (!pendingRemove.FromResend)
172 {
173 // Calculate the round-trip time for this packet and its ACK
174 int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount;
175 if (rtt > 0)
176 ackedPacket.Client.UpdateRoundTrip(rtt);
177 }
178 }
179 } 164 }
180 } 165 }
181 } 166 }