diff options
author | Melanie Thielker | 2008-12-17 20:34:37 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-12-17 20:34:37 +0000 |
commit | 2bcf315ea2550a277fc59161724f1c6dad35e915 (patch) | |
tree | 99cb2180d15e0516c77100bcc6b93a07b4ad3cba /OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | |
parent | Stop packets that may be resent from being returned to the packet pool. (diff) | |
download | opensim-SC_OLD-2bcf315ea2550a277fc59161724f1c6dad35e915.zip opensim-SC_OLD-2bcf315ea2550a277fc59161724f1c6dad35e915.tar.gz opensim-SC_OLD-2bcf315ea2550a277fc59161724f1c6dad35e915.tar.bz2 opensim-SC_OLD-2bcf315ea2550a277fc59161724f1c6dad35e915.tar.xz |
Revert 7754 and 7755 pending a rework
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | 64 |
1 files changed, 36 insertions, 28 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}", |