diff options
author | BlueWall | 2011-01-27 08:53:57 -0500 |
---|---|---|
committer | BlueWall | 2011-01-27 08:53:57 -0500 |
commit | d89d9d1b1310d494fbb7712057eab8a196e10a04 (patch) | |
tree | 62834b7f5954aa8f013a159ee2fc3ccee385e673 /OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs | |
parent | Make FireAndForgetWrapper a singleton class (diff) | |
parent | Make it work (diff) | |
download | opensim-SC_OLD-d89d9d1b1310d494fbb7712057eab8a196e10a04.zip opensim-SC_OLD-d89d9d1b1310d494fbb7712057eab8a196e10a04.tar.gz opensim-SC_OLD-d89d9d1b1310d494fbb7712057eab8a196e10a04.tar.bz2 opensim-SC_OLD-d89d9d1b1310d494fbb7712057eab8a196e10a04.tar.xz |
Merge branch 'master' of /home/opensim/src/OpenSim/Core
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs index 4cb4aee..9d40688 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Threading; | ||
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | 33 | ||
33 | namespace OpenSim.Region.ClientStack.LindenUDP | 34 | namespace OpenSim.Region.ClientStack.LindenUDP |
@@ -77,6 +78,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
77 | public void Add(OutgoingPacket packet) | 78 | public void Add(OutgoingPacket packet) |
78 | { | 79 | { |
79 | m_pendingAdds.Enqueue(packet); | 80 | m_pendingAdds.Enqueue(packet); |
81 | Interlocked.Add(ref packet.Client.UnackedBytes, packet.Buffer.DataLength); | ||
80 | } | 82 | } |
81 | 83 | ||
82 | /// <summary> | 84 | /// <summary> |
@@ -139,46 +141,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
139 | private void ProcessQueues() | 141 | private void ProcessQueues() |
140 | { | 142 | { |
141 | // Process all the pending adds | 143 | // Process all the pending adds |
142 | |||
143 | OutgoingPacket pendingAdd; | 144 | OutgoingPacket pendingAdd; |
144 | if (m_pendingAdds != null) | 145 | while (m_pendingAdds.TryDequeue(out pendingAdd)) |
145 | { | 146 | m_packets[pendingAdd.SequenceNumber] = pendingAdd; |
146 | while (m_pendingAdds.TryDequeue(out pendingAdd)) | ||
147 | { | ||
148 | if (pendingAdd != null && m_packets != null) | ||
149 | { | ||
150 | m_packets[pendingAdd.SequenceNumber] = pendingAdd; | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | 147 | ||
155 | // Process all the pending removes, including updating statistics and round-trip times | 148 | // Process all the pending removes, including updating statistics and round-trip times |
156 | PendingAck pendingRemove; | 149 | PendingAck pendingRemove; |
157 | OutgoingPacket ackedPacket; | 150 | OutgoingPacket ackedPacket; |
158 | if (m_pendingRemoves != null) | 151 | while (m_pendingRemoves.TryDequeue(out pendingRemove)) |
159 | { | 152 | { |
160 | while (m_pendingRemoves.TryDequeue(out pendingRemove)) | 153 | if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) |
161 | { | 154 | { |
162 | if (m_pendingRemoves != null && m_packets != null) | 155 | m_packets.Remove(pendingRemove.SequenceNumber); |
156 | |||
157 | // Update stats | ||
158 | Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); | ||
159 | |||
160 | if (!pendingRemove.FromResend) | ||
163 | { | 161 | { |
164 | if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) | 162 | // Calculate the round-trip time for this packet and its ACK |
165 | { | 163 | int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; |
166 | m_packets.Remove(pendingRemove.SequenceNumber); | 164 | if (rtt > 0) |
167 | 165 | 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 | } | 166 | } |
180 | } | 167 | } |
181 | } | 168 | } |
182 | } | 169 | } |
183 | } | 170 | } |
184 | } | 171 | } \ No newline at end of file |