diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs | 39 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs | 3 |
3 files changed, 59 insertions, 47 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index 4964efc..5f26469 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | |||
@@ -99,8 +99,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
99 | // | 99 | // |
100 | private Dictionary<uint, uint> m_PendingAcks = new Dictionary<uint, uint>(); | 100 | private Dictionary<uint, uint> m_PendingAcks = new Dictionary<uint, uint>(); |
101 | 101 | ||
102 | private Dictionary<uint, LLQueItem> m_NeedAck = | 102 | // Dictionary of the packets that need acks from the client. |
103 | new Dictionary<uint, LLQueItem>(); | 103 | // |
104 | private class AckData | ||
105 | { | ||
106 | public AckData(Packet packet, Object identifier, int tickCount, int resends) | ||
107 | { | ||
108 | Packet = packet; | ||
109 | Identifier = identifier; | ||
110 | TickCount = tickCount; | ||
111 | Resends = resends; | ||
112 | } | ||
113 | |||
114 | public Packet Packet; | ||
115 | public Object Identifier; | ||
116 | public int TickCount; | ||
117 | public int Resends; | ||
118 | } | ||
119 | |||
120 | private Dictionary<uint, AckData> m_NeedAck = | ||
121 | new Dictionary<uint, AckData>(); | ||
104 | 122 | ||
105 | /// <summary> | 123 | /// <summary> |
106 | /// The number of milliseconds that can pass before a packet that needs an ack is resent. | 124 | /// The number of milliseconds that can pass before a packet that needs an ack is resent. |
@@ -296,9 +314,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
296 | item.throttleType = throttlePacketType; | 314 | item.throttleType = throttlePacketType; |
297 | item.TickCount = System.Environment.TickCount; | 315 | item.TickCount = System.Environment.TickCount; |
298 | item.Identifier = id; | 316 | item.Identifier = id; |
299 | item.Resends = 0; | ||
300 | item.Bytes = packet.ToBytes(); | ||
301 | item.Length = item.Bytes.Length; | ||
302 | 317 | ||
303 | m_PacketQueue.Enqueue(item); | 318 | m_PacketQueue.Enqueue(item); |
304 | m_PacketsSent++; | 319 | m_PacketsSent++; |
@@ -318,7 +333,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
318 | if (m_DropSafeTimeout > now || | 333 | if (m_DropSafeTimeout > now || |
319 | intervalMs > 500) // We were frozen! | 334 | intervalMs > 500) // We were frozen! |
320 | { | 335 | { |
321 | foreach (LLQueItem data in new List<LLQueItem> | 336 | foreach (AckData data in new List<AckData> |
322 | (m_NeedAck.Values)) | 337 | (m_NeedAck.Values)) |
323 | { | 338 | { |
324 | if (m_DropSafeTimeout > now) | 339 | if (m_DropSafeTimeout > now) |
@@ -349,7 +364,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
349 | 364 | ||
350 | int resent = 0; | 365 | int resent = 0; |
351 | 366 | ||
352 | foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values)) | 367 | foreach (AckData data in new List<AckData>(m_NeedAck.Values)) |
353 | { | 368 | { |
354 | Packet packet = data.Packet; | 369 | Packet packet = data.Packet; |
355 | 370 | ||
@@ -615,7 +630,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
615 | 630 | ||
616 | private void ProcessAck(uint id) | 631 | private void ProcessAck(uint id) |
617 | { | 632 | { |
618 | LLQueItem data; | 633 | AckData data; |
619 | Packet packet; | 634 | Packet packet; |
620 | 635 | ||
621 | lock (m_NeedAck) | 636 | lock (m_NeedAck) |
@@ -625,9 +640,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
625 | if (!m_NeedAck.TryGetValue(id, out data)) | 640 | if (!m_NeedAck.TryGetValue(id, out data)) |
626 | return; | 641 | return; |
627 | 642 | ||
643 | packet = data.Packet; | ||
644 | |||
628 | m_NeedAck.Remove(id); | 645 | m_NeedAck.Remove(id); |
646 | m_UnackedBytes -= packet.ToBytes().Length; | ||
629 | PacketPool.Instance.ReturnPacket(data.Packet); | 647 | PacketPool.Instance.ReturnPacket(data.Packet); |
630 | m_UnackedBytes -= data.Length; | ||
631 | } | 648 | } |
632 | } | 649 | } |
633 | 650 | ||
@@ -661,7 +678,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
661 | lock (m_NeedAck) | 678 | lock (m_NeedAck) |
662 | { | 679 | { |
663 | foreach (uint key in m_NeedAck.Keys) | 680 | foreach (uint key in m_NeedAck.Keys) |
664 | info.needAck.Add(key, m_NeedAck[key].Bytes); | 681 | info.needAck.Add(key, m_NeedAck[key].Packet.ToBytes()); |
665 | } | 682 | } |
666 | 683 | ||
667 | LLQueItem[] queitems = m_PacketQueue.GetQueueArray(); | 684 | LLQueItem[] queitems = m_PacketQueue.GetQueueArray(); |
@@ -669,7 +686,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
669 | for (int i = 0; i < queitems.Length; i++) | 686 | for (int i = 0; i < queitems.Length; i++) |
670 | { | 687 | { |
671 | if (queitems[i].Incoming == false) | 688 | if (queitems[i].Incoming == false) |
672 | info.out_packets.Add(queitems[i].Bytes); | 689 | info.out_packets.Add(queitems[i].Packet.ToBytes()); |
673 | } | 690 | } |
674 | 691 | ||
675 | info.sequence = m_Sequence; | 692 | info.sequence = m_Sequence; |
@@ -680,7 +697,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
680 | public void SetClientInfo(ClientInfo info) | 697 | public void SetClientInfo(ClientInfo info) |
681 | { | 698 | { |
682 | m_PendingAcks = info.pendingAcks; | 699 | m_PendingAcks = info.pendingAcks; |
683 | m_NeedAck = new Dictionary<uint, LLQueItem>(); | 700 | m_NeedAck = new Dictionary<uint, AckData>(); |
684 | 701 | ||
685 | Packet packet = null; | 702 | Packet packet = null; |
686 | int packetEnd = 0; | 703 | int packetEnd = 0; |
@@ -699,16 +716,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
699 | { | 716 | { |
700 | } | 717 | } |
701 | 718 | ||
702 | LLQueItem item = new LLQueItem(); | 719 | m_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount, 0)); |
703 | item.Packet = packet; | ||
704 | item.Incoming = false; | ||
705 | item.throttleType = 0; | ||
706 | item.TickCount = System.Environment.TickCount; | ||
707 | item.Identifier = 0; | ||
708 | item.Resends = 0; | ||
709 | item.Bytes = packet.ToBytes(); | ||
710 | item.Length = item.Bytes.Length; | ||
711 | m_NeedAck.Add(key, item); | ||
712 | } | 720 | } |
713 | 721 | ||
714 | m_Sequence = info.sequence; | 722 | m_Sequence = info.sequence; |
@@ -732,7 +740,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
732 | 740 | ||
733 | private void DropResend(Object id) | 741 | private void DropResend(Object id) |
734 | { | 742 | { |
735 | foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values)) | 743 | foreach (AckData data in new List<AckData>(m_NeedAck.Values)) |
736 | { | 744 | { |
737 | if (data.Identifier != null && data.Identifier == id) | 745 | if (data.Identifier != null && data.Identifier == id) |
738 | { | 746 | { |
@@ -769,12 +777,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
769 | // We want to see that packet arrive if it's reliable | 777 | // We want to see that packet arrive if it's reliable |
770 | if (packet.Header.Reliable) | 778 | if (packet.Header.Reliable) |
771 | { | 779 | { |
772 | m_UnackedBytes += item.Length; | 780 | m_UnackedBytes += packet.ToBytes().Length; |
773 | 781 | ||
774 | // Keep track of when this packet was sent out | 782 | // Keep track of when this packet was sent out |
775 | item.TickCount = System.Environment.TickCount; | 783 | m_NeedAck[packet.Header.Sequence] = new AckData(packet, |
776 | 784 | item.Identifier, System.Environment.TickCount, | |
777 | m_NeedAck[packet.Header.Sequence] = item; | 785 | 0); |
778 | } | 786 | } |
779 | } | 787 | } |
780 | } | 788 | } |
@@ -784,7 +792,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
784 | Abort(); | 792 | Abort(); |
785 | 793 | ||
786 | // Actually make the byte array and send it | 794 | // Actually make the byte array and send it |
787 | byte[] sendbuffer = item.Bytes; | 795 | byte[] sendbuffer = packet.ToBytes(); |
788 | 796 | ||
789 | //m_log.DebugFormat( | 797 | //m_log.DebugFormat( |
790 | // "[CLIENT]: In {0} sending packet {1}", | 798 | // "[CLIENT]: In {0} sending packet {1}", |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs index 4383493..2d02dfc 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs | |||
@@ -345,8 +345,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
345 | LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue(); | 345 | LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue(); |
346 | 346 | ||
347 | SendQueue.Enqueue(qpack); | 347 | SendQueue.Enqueue(qpack); |
348 | TotalThrottle.AddBytes(qpack.Length); | 348 | int qpackSize = qpack.Packet.ToBytes().Length; |
349 | ResendThrottle.AddBytes(qpack.Length); | 349 | TotalThrottle.AddBytes(qpackSize); |
350 | ResendThrottle.AddBytes(qpackSize); | ||
350 | 351 | ||
351 | qchanged = true; | 352 | qchanged = true; |
352 | } | 353 | } |
@@ -356,8 +357,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
356 | LLQueItem qpack = LandOutgoingPacketQueue.Dequeue(); | 357 | LLQueItem qpack = LandOutgoingPacketQueue.Dequeue(); |
357 | 358 | ||
358 | SendQueue.Enqueue(qpack); | 359 | SendQueue.Enqueue(qpack); |
359 | TotalThrottle.AddBytes(qpack.Length); | 360 | int qpackSize = qpack.Packet.ToBytes().Length; |
360 | LandThrottle.AddBytes(qpack.Length); | 361 | TotalThrottle.AddBytes(qpackSize); |
362 | LandThrottle.AddBytes(qpackSize); | ||
361 | qchanged = true; | 363 | qchanged = true; |
362 | } | 364 | } |
363 | 365 | ||
@@ -366,8 +368,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
366 | LLQueItem qpack = WindOutgoingPacketQueue.Dequeue(); | 368 | LLQueItem qpack = WindOutgoingPacketQueue.Dequeue(); |
367 | 369 | ||
368 | SendQueue.Enqueue(qpack); | 370 | SendQueue.Enqueue(qpack); |
369 | TotalThrottle.AddBytes(qpack.Length); | 371 | int qpackSize = qpack.Packet.ToBytes().Length; |
370 | WindThrottle.AddBytes(qpack.Length); | 372 | TotalThrottle.AddBytes(qpackSize); |
373 | WindThrottle.AddBytes(qpackSize); | ||
371 | qchanged = true; | 374 | qchanged = true; |
372 | } | 375 | } |
373 | 376 | ||
@@ -376,8 +379,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
376 | LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue(); | 379 | LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue(); |
377 | 380 | ||
378 | SendQueue.Enqueue(qpack); | 381 | SendQueue.Enqueue(qpack); |
379 | TotalThrottle.AddBytes(qpack.Length); | 382 | int qpackSize = qpack.Packet.ToBytes().Length; |
380 | CloudThrottle.AddBytes(qpack.Length); | 383 | TotalThrottle.AddBytes(qpackSize); |
384 | CloudThrottle.AddBytes(qpackSize); | ||
381 | qchanged = true; | 385 | qchanged = true; |
382 | } | 386 | } |
383 | 387 | ||
@@ -395,8 +399,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
395 | SendQueue.Enqueue(qpack); | 399 | SendQueue.Enqueue(qpack); |
396 | } | 400 | } |
397 | 401 | ||
398 | TotalThrottle.AddBytes(qpack.Length); | 402 | int qpackSize = qpack.Packet.ToBytes().Length; |
399 | TaskThrottle.AddBytes(qpack.Length); | 403 | TotalThrottle.AddBytes(qpackSize); |
404 | TaskThrottle.AddBytes(qpackSize); | ||
400 | qchanged = true; | 405 | qchanged = true; |
401 | } | 406 | } |
402 | 407 | ||
@@ -405,8 +410,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
405 | LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue(); | 410 | LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue(); |
406 | 411 | ||
407 | SendQueue.Enqueue(qpack); | 412 | SendQueue.Enqueue(qpack); |
408 | TotalThrottle.AddBytes(qpack.Length); | 413 | int qpackSize = qpack.Packet.ToBytes().Length; |
409 | TextureThrottle.AddBytes(qpack.Length); | 414 | TotalThrottle.AddBytes(qpackSize); |
415 | TextureThrottle.AddBytes(qpackSize); | ||
410 | qchanged = true; | 416 | qchanged = true; |
411 | } | 417 | } |
412 | 418 | ||
@@ -415,8 +421,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
415 | LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue(); | 421 | LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue(); |
416 | 422 | ||
417 | SendQueue.Enqueue(qpack); | 423 | SendQueue.Enqueue(qpack); |
418 | TotalThrottle.AddBytes(qpack.Length); | 424 | int qpackSize = qpack.Packet.ToBytes().Length; |
419 | AssetThrottle.AddBytes(qpack.Length); | 425 | TotalThrottle.AddBytes(qpackSize); |
426 | AssetThrottle.AddBytes(qpackSize); | ||
420 | qchanged = true; | 427 | qchanged = true; |
421 | } | 428 | } |
422 | } | 429 | } |
@@ -444,8 +451,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
444 | try | 451 | try |
445 | { | 452 | { |
446 | Monitor.Enter(this); | 453 | Monitor.Enter(this); |
447 | throttle.AddBytes(item.Length); | 454 | throttle.AddBytes(item.Packet.ToBytes().Length); |
448 | TotalThrottle.AddBytes(item.Length); | 455 | TotalThrottle.AddBytes(item.Packet.ToBytes().Length); |
449 | SendQueue.Enqueue(item); | 456 | SendQueue.Enqueue(item); |
450 | } | 457 | } |
451 | catch (Exception e) | 458 | catch (Exception e) |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs index 8df176f..494d62b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs | |||
@@ -42,8 +42,5 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
42 | public ThrottleOutPacketType throttleType; | 42 | public ThrottleOutPacketType throttleType; |
43 | public int TickCount; | 43 | public int TickCount; |
44 | public Object Identifier; | 44 | public Object Identifier; |
45 | public int Resends; | ||
46 | public Byte[] Bytes; | ||
47 | public int Length; | ||
48 | } | 45 | } |
49 | } | 46 | } |