aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs45
1 files changed, 30 insertions, 15 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
index 9d40688..d762bef 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
@@ -141,31 +141,46 @@ namespace OpenSim.Region.ClientStack.LindenUDP
141 private void ProcessQueues() 141 private void ProcessQueues()
142 { 142 {
143 // Process all the pending adds 143 // Process all the pending adds
144
144 OutgoingPacket pendingAdd; 145 OutgoingPacket pendingAdd;
145 while (m_pendingAdds.TryDequeue(out pendingAdd)) 146 if (m_pendingAdds != null)
146 m_packets[pendingAdd.SequenceNumber] = pendingAdd; 147 {
148 while (m_pendingAdds.TryDequeue(out pendingAdd))
149 {
150 if (pendingAdd != null && m_packets != null)
151 {
152 m_packets[pendingAdd.SequenceNumber] = pendingAdd;
153 }
154 }
155 }
147 156
148 // Process all the pending removes, including updating statistics and round-trip times 157 // Process all the pending removes, including updating statistics and round-trip times
149 PendingAck pendingRemove; 158 PendingAck pendingRemove;
150 OutgoingPacket ackedPacket; 159 OutgoingPacket ackedPacket;
151 while (m_pendingRemoves.TryDequeue(out pendingRemove)) 160 if (m_pendingRemoves != null)
152 { 161 {
153 if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) 162 while (m_pendingRemoves.TryDequeue(out pendingRemove))
154 { 163 {
155 m_packets.Remove(pendingRemove.SequenceNumber); 164 if (m_pendingRemoves != null && m_packets != null)
156
157 // Update stats
158 Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength);
159
160 if (!pendingRemove.FromResend)
161 { 165 {
162 // Calculate the round-trip time for this packet and its ACK 166 if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket))
163 int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; 167 {
164 if (rtt > 0) 168 m_packets.Remove(pendingRemove.SequenceNumber);
165 ackedPacket.Client.UpdateRoundTrip(rtt); 169
170 // Update stats
171 Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength);
172
173 if (!pendingRemove.FromResend)
174 {
175 // Calculate the round-trip time for this packet and its ACK
176 int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount;
177 if (rtt > 0)
178 ackedPacket.Client.UpdateRoundTrip(rtt);
179 }
180 }
166 } 181 }
167 } 182 }
168 } 183 }
169 } 184 }
170 } 185 }
171} \ No newline at end of file 186}