diff options
author | Melanie Thielker | 2008-12-17 18:56:47 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-12-17 18:56:47 +0000 |
commit | 0d3a9b45aecdccf5920f1100a407be25c4324b88 (patch) | |
tree | 2422d0fc04698a3a6c2f983214ce13886466ef5a /OpenSim/Region/ClientStack/LindenUDP | |
parent | * remove mono compiler warnings (diff) | |
download | opensim-SC_OLD-0d3a9b45aecdccf5920f1100a407be25c4324b88.zip opensim-SC_OLD-0d3a9b45aecdccf5920f1100a407be25c4324b88.tar.gz opensim-SC_OLD-0d3a9b45aecdccf5920f1100a407be25c4324b88.tar.bz2 opensim-SC_OLD-0d3a9b45aecdccf5920f1100a407be25c4324b88.tar.xz |
Marry AckData to LLQueItem, and store packet data and length there for
use everywhere. Each packet gets serialized only once now in PacketHandler
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs | 3 |
2 files changed, 31 insertions, 36 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index 4e8d4f9..83e77b7 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | |||
@@ -99,26 +99,8 @@ 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 | // Dictionary of the packets that need acks from the client. | 102 | private Dictionary<uint, LLQueItem> m_NeedAck = |
103 | // | 103 | new Dictionary<uint, LLQueItem>(); |
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>(); | ||
122 | 104 | ||
123 | /// <summary> | 105 | /// <summary> |
124 | /// The number of milliseconds that can pass before a packet that needs an ack is resent. | 106 | /// The number of milliseconds that can pass before a packet that needs an ack is resent. |
@@ -314,6 +296,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
314 | item.throttleType = throttlePacketType; | 296 | item.throttleType = throttlePacketType; |
315 | item.TickCount = System.Environment.TickCount; | 297 | item.TickCount = System.Environment.TickCount; |
316 | item.Identifier = id; | 298 | item.Identifier = id; |
299 | item.Resends = 0; | ||
300 | item.Bytes = packet.ToBytes(); | ||
301 | item.Length = item.Bytes.Length; | ||
317 | 302 | ||
318 | m_PacketQueue.Enqueue(item); | 303 | m_PacketQueue.Enqueue(item); |
319 | m_PacketsSent++; | 304 | m_PacketsSent++; |
@@ -333,7 +318,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
333 | if (m_DropSafeTimeout > now || | 318 | if (m_DropSafeTimeout > now || |
334 | intervalMs > 500) // We were frozen! | 319 | intervalMs > 500) // We were frozen! |
335 | { | 320 | { |
336 | foreach (AckData data in new List<AckData> | 321 | foreach (LLQueItem data in new List<LLQueItem> |
337 | (m_NeedAck.Values)) | 322 | (m_NeedAck.Values)) |
338 | { | 323 | { |
339 | if (m_DropSafeTimeout > now) | 324 | if (m_DropSafeTimeout > now) |
@@ -364,7 +349,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
364 | 349 | ||
365 | int resent = 0; | 350 | int resent = 0; |
366 | 351 | ||
367 | foreach (AckData data in new List<AckData>(m_NeedAck.Values)) | 352 | foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values)) |
368 | { | 353 | { |
369 | Packet packet = data.Packet; | 354 | Packet packet = data.Packet; |
370 | 355 | ||
@@ -629,7 +614,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
629 | 614 | ||
630 | private void ProcessAck(uint id) | 615 | private void ProcessAck(uint id) |
631 | { | 616 | { |
632 | AckData data; | 617 | LLQueItem data; |
633 | Packet packet; | 618 | Packet packet; |
634 | 619 | ||
635 | lock (m_NeedAck) | 620 | lock (m_NeedAck) |
@@ -639,10 +624,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
639 | if (!m_NeedAck.TryGetValue(id, out data)) | 624 | if (!m_NeedAck.TryGetValue(id, out data)) |
640 | return; | 625 | return; |
641 | 626 | ||
642 | packet = data.Packet; | ||
643 | |||
644 | m_NeedAck.Remove(id); | 627 | m_NeedAck.Remove(id); |
645 | m_UnackedBytes -= packet.ToBytes().Length; | 628 | m_UnackedBytes -= data.Length; |
646 | } | 629 | } |
647 | } | 630 | } |
648 | 631 | ||
@@ -676,7 +659,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
676 | lock (m_NeedAck) | 659 | lock (m_NeedAck) |
677 | { | 660 | { |
678 | foreach (uint key in m_NeedAck.Keys) | 661 | foreach (uint key in m_NeedAck.Keys) |
679 | info.needAck.Add(key, m_NeedAck[key].Packet.ToBytes()); | 662 | info.needAck.Add(key, m_NeedAck[key].Bytes); |
680 | } | 663 | } |
681 | 664 | ||
682 | LLQueItem[] queitems = m_PacketQueue.GetQueueArray(); | 665 | LLQueItem[] queitems = m_PacketQueue.GetQueueArray(); |
@@ -684,7 +667,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
684 | for (int i = 0; i < queitems.Length; i++) | 667 | for (int i = 0; i < queitems.Length; i++) |
685 | { | 668 | { |
686 | if (queitems[i].Incoming == false) | 669 | if (queitems[i].Incoming == false) |
687 | info.out_packets.Add(queitems[i].Packet.ToBytes()); | 670 | info.out_packets.Add(queitems[i].Bytes); |
688 | } | 671 | } |
689 | 672 | ||
690 | info.sequence = m_Sequence; | 673 | info.sequence = m_Sequence; |
@@ -695,7 +678,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
695 | public void SetClientInfo(ClientInfo info) | 678 | public void SetClientInfo(ClientInfo info) |
696 | { | 679 | { |
697 | m_PendingAcks = info.pendingAcks; | 680 | m_PendingAcks = info.pendingAcks; |
698 | m_NeedAck = new Dictionary<uint, AckData>(); | 681 | m_NeedAck = new Dictionary<uint, LLQueItem>(); |
699 | 682 | ||
700 | Packet packet = null; | 683 | Packet packet = null; |
701 | int packetEnd = 0; | 684 | int packetEnd = 0; |
@@ -714,7 +697,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
714 | { | 697 | { |
715 | } | 698 | } |
716 | 699 | ||
717 | m_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount, 0)); | 700 | LLQueItem item = new LLQueItem(); |
701 | item.Packet = packet; | ||
702 | item.Incoming = false; | ||
703 | item.throttleType = 0; | ||
704 | item.TickCount = System.Environment.TickCount; | ||
705 | item.Identifier = 0; | ||
706 | item.Resends = 0; | ||
707 | item.Bytes = packet.ToBytes(); | ||
708 | item.Length = item.Bytes.Length; | ||
709 | m_NeedAck.Add(key, item); | ||
718 | } | 710 | } |
719 | 711 | ||
720 | m_Sequence = info.sequence; | 712 | m_Sequence = info.sequence; |
@@ -738,7 +730,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
738 | 730 | ||
739 | private void DropResend(Object id) | 731 | private void DropResend(Object id) |
740 | { | 732 | { |
741 | foreach (AckData data in new List<AckData>(m_NeedAck.Values)) | 733 | foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values)) |
742 | { | 734 | { |
743 | if (data.Identifier != null && data.Identifier == id) | 735 | if (data.Identifier != null && data.Identifier == id) |
744 | { | 736 | { |
@@ -774,12 +766,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
774 | // We want to see that packet arrive if it's reliable | 766 | // We want to see that packet arrive if it's reliable |
775 | if (packet.Header.Reliable) | 767 | if (packet.Header.Reliable) |
776 | { | 768 | { |
777 | m_UnackedBytes += packet.ToBytes().Length; | 769 | m_UnackedBytes += item.Length; |
778 | 770 | ||
779 | // Keep track of when this packet was sent out | 771 | // Keep track of when this packet was sent out |
780 | m_NeedAck[packet.Header.Sequence] = new AckData(packet, | 772 | item.TickCount = System.Environment.TickCount; |
781 | item.Identifier, System.Environment.TickCount, | 773 | |
782 | 0); | 774 | m_NeedAck[packet.Header.Sequence] = item; |
783 | } | 775 | } |
784 | } | 776 | } |
785 | } | 777 | } |
@@ -789,7 +781,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
789 | Abort(); | 781 | Abort(); |
790 | 782 | ||
791 | // Actually make the byte array and send it | 783 | // Actually make the byte array and send it |
792 | byte[] sendbuffer = packet.ToBytes(); | 784 | byte[] sendbuffer = item.Bytes; |
793 | 785 | ||
794 | //m_log.DebugFormat( | 786 | //m_log.DebugFormat( |
795 | // "[CLIENT]: In {0} sending packet {1}", | 787 | // "[CLIENT]: In {0} sending packet {1}", |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs index 494d62b..8df176f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs | |||
@@ -42,5 +42,8 @@ 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; | ||
45 | } | 48 | } |
46 | } | 49 | } |