aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
diff options
context:
space:
mode:
authorDr Scofield2009-06-25 08:00:43 +0000
committerDr Scofield2009-06-25 08:00:43 +0000
commit1b06da0c5458465a2d616d1f926271758267e509 (patch)
tree9b95223532a11248af6861cac03e4139185035c5 /OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
parentstreamling m_PendingAcks logic to get rid of gratuitous List<...> (diff)
downloadopensim-SC-1b06da0c5458465a2d616d1f926271758267e509.zip
opensim-SC-1b06da0c5458465a2d616d1f926271758267e509.tar.gz
opensim-SC-1b06da0c5458465a2d616d1f926271758267e509.tar.bz2
opensim-SC-1b06da0c5458465a2d616d1f926271758267e509.tar.xz
streamlining m_NeedAck logic
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs60
1 files changed, 29 insertions, 31 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
index a889110..093e51f 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
@@ -276,46 +276,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP
276 lock (m_NeedAck) 276 lock (m_NeedAck)
277 { 277 {
278 if (m_DropSafeTimeout > now || 278 if (m_DropSafeTimeout > now ||
279 intervalMs > 500) // We were frozen! 279 intervalMs > 500) // We were frozen!
280 { 280 {
281 foreach (LLQueItem data in new List<LLQueItem> 281 foreach (LLQueItem data in m_NeedAck.Values)
282 (m_NeedAck.Values))
283 { 282 {
284 if (m_DropSafeTimeout > now) 283 if (m_DropSafeTimeout > now)
285 { 284 {
286 m_NeedAck[data.Packet.Header.Sequence]. 285 m_NeedAck[data.Packet.Header.Sequence].TickCount = now;
287 TickCount = now;
288 } 286 }
289 else 287 else
290 { 288 {
291 m_NeedAck[data.Packet.Header.Sequence]. 289 m_NeedAck[data.Packet.Header.Sequence].TickCount += intervalMs;
292 TickCount += intervalMs;
293 } 290 }
294 } 291 }
295 } 292 }
296 }
297 m_LastResend = now;
298 293
299 // Unless we have received at least one ack, don't bother resending 294 m_LastResend = now;
300 // anything. There may not be a client there, don't clog up the 295
301 // pipes. 296 // Unless we have received at least one ack, don't bother resending
302 // 297 // anything. There may not be a client there, don't clog up the
303 lock (m_NeedAck) 298 // pipes.
304 { 299
300
305 // Nothing to do 301 // Nothing to do
306 // 302 //
307 if (m_NeedAck.Count == 0) 303 if (m_NeedAck.Count == 0)
308 return; 304 return;
309 305
310 int resent = 0; 306 int resent = 0;
307 long dueDate = now - m_ResendTimeout;
311 308
312 foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values)) 309 List<LLQueItem> dropped = new List<LLQueItem>();
310 foreach (LLQueItem data in m_NeedAck.Values)
313 { 311 {
314 Packet packet = data.Packet; 312 Packet packet = data.Packet;
315 313
316 // Packets this old get resent 314 // Packets this old get resent
317 // 315 //
318 if ((now - data.TickCount) > m_ResendTimeout && data.Sequence != 0 && !m_PacketQueue.Contains(data.Sequence)) 316 if (data.TickCount < dueDate && data.Sequence != 0 && !m_PacketQueue.Contains(data.Sequence))
319 { 317 {
320 if (resent < 20) // Was 20 (= Max 117kbit/sec resends) 318 if (resent < 20) // Was 20 (= Max 117kbit/sec resends)
321 { 319 {
@@ -325,31 +323,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
325 // that it should reset its sequence to that packet number. 323 // that it should reset its sequence to that packet number.
326 packet.Header.Resent = true; 324 packet.Header.Resent = true;
327 325
328 if ((m_NeedAck[packet.Header.Sequence].Resends >= 326 if ((m_NeedAck[packet.Header.Sequence].Resends >= m_MaxReliableResends) &&
329 m_MaxReliableResends) && (!m_ReliableIsImportant)) 327 (!m_ReliableIsImportant))
330 { 328 {
331 m_NeedAck.Remove(packet.Header.Sequence); 329 dropped.Add(data);
332 TriggerOnPacketDrop(packet, data.Identifier);
333 m_PacketQueue.Cancel(packet.Header.Sequence);
334 PacketPool.Instance.ReturnPacket(packet);
335 continue; 330 continue;
336 } 331 }
337 332
338 m_NeedAck[packet.Header.Sequence].TickCount = 333 m_NeedAck[packet.Header.Sequence].TickCount = Environment.TickCount;
339 Environment.TickCount; 334 QueuePacket(packet, ThrottleOutPacketType.Resend, data.Identifier);
340
341 QueuePacket(packet, ThrottleOutPacketType.Resend,
342 data.Identifier);
343
344 resent++; 335 resent++;
345 } 336 }
346 else 337 else
347 { 338 {
348 m_NeedAck[packet.Header.Sequence].TickCount += 339 m_NeedAck[packet.Header.Sequence].TickCount += intervalMs;
349 intervalMs;
350 } 340 }
351 } 341 }
352 } 342 }
343
344 foreach(LLQueItem data in dropped)
345 {
346 m_NeedAck.Remove(data.Packet.Header.Sequence);
347 TriggerOnPacketDrop(data.Packet, data.Identifier);
348 m_PacketQueue.Cancel(data.Packet.Header.Sequence);
349 PacketPool.Instance.ReturnPacket(data.Packet);
350 }
353 } 351 }
354 } 352 }
355 353