aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-12-17 21:00:18 +0000
committerMelanie Thielker2008-12-17 21:00:18 +0000
commita9e38bcafcb14700fd707a74311f0e7588791014 (patch)
treeee5a95b2ad712af9b1f6ef1896fedef702cdcc37 /OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
parent* minor: Comment out "Informing neighbours" debug message that pops up whenev... (diff)
downloadopensim-SC-a9e38bcafcb14700fd707a74311f0e7588791014.zip
opensim-SC-a9e38bcafcb14700fd707a74311f0e7588791014.tar.gz
opensim-SC-a9e38bcafcb14700fd707a74311f0e7588791014.tar.bz2
opensim-SC-a9e38bcafcb14700fd707a74311f0e7588791014.tar.xz
Reapply the packet optimization patch, with changes
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs58
1 files changed, 24 insertions, 34 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
index 5f26469..89f3339 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,8 @@ 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.Length = packet.ToBytes().Length;
317 301
318 m_PacketQueue.Enqueue(item); 302 m_PacketQueue.Enqueue(item);
319 m_PacketsSent++; 303 m_PacketsSent++;
@@ -333,7 +317,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
333 if (m_DropSafeTimeout > now || 317 if (m_DropSafeTimeout > now ||
334 intervalMs > 500) // We were frozen! 318 intervalMs > 500) // We were frozen!
335 { 319 {
336 foreach (AckData data in new List<AckData> 320 foreach (LLQueItem data in new List<LLQueItem>
337 (m_NeedAck.Values)) 321 (m_NeedAck.Values))
338 { 322 {
339 if (m_DropSafeTimeout > now) 323 if (m_DropSafeTimeout > now)
@@ -364,7 +348,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
364 348
365 int resent = 0; 349 int resent = 0;
366 350
367 foreach (AckData data in new List<AckData>(m_NeedAck.Values)) 351 foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
368 { 352 {
369 Packet packet = data.Packet; 353 Packet packet = data.Packet;
370 354
@@ -630,7 +614,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
630 614
631 private void ProcessAck(uint id) 615 private void ProcessAck(uint id)
632 { 616 {
633 AckData data; 617 LLQueItem data;
634 Packet packet; 618 Packet packet;
635 619
636 lock (m_NeedAck) 620 lock (m_NeedAck)
@@ -640,11 +624,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
640 if (!m_NeedAck.TryGetValue(id, out data)) 624 if (!m_NeedAck.TryGetValue(id, out data))
641 return; 625 return;
642 626
643 packet = data.Packet;
644
645 m_NeedAck.Remove(id); 627 m_NeedAck.Remove(id);
646 m_UnackedBytes -= packet.ToBytes().Length;
647 PacketPool.Instance.ReturnPacket(data.Packet); 628 PacketPool.Instance.ReturnPacket(data.Packet);
629 m_UnackedBytes -= data.Length;
648 } 630 }
649 } 631 }
650 632
@@ -697,7 +679,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
697 public void SetClientInfo(ClientInfo info) 679 public void SetClientInfo(ClientInfo info)
698 { 680 {
699 m_PendingAcks = info.pendingAcks; 681 m_PendingAcks = info.pendingAcks;
700 m_NeedAck = new Dictionary<uint, AckData>(); 682 m_NeedAck = new Dictionary<uint, LLQueItem>();
701 683
702 Packet packet = null; 684 Packet packet = null;
703 int packetEnd = 0; 685 int packetEnd = 0;
@@ -716,7 +698,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
716 { 698 {
717 } 699 }
718 700
719 m_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount, 0)); 701 LLQueItem item = new LLQueItem();
702 item.Packet = packet;
703 item.Incoming = false;
704 item.throttleType = 0;
705 item.TickCount = System.Environment.TickCount;
706 item.Identifier = 0;
707 item.Resends = 0;
708 item.Length = packet.ToBytes().Length;
709 m_NeedAck.Add(key, item);
720 } 710 }
721 711
722 m_Sequence = info.sequence; 712 m_Sequence = info.sequence;
@@ -740,7 +730,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
740 730
741 private void DropResend(Object id) 731 private void DropResend(Object id)
742 { 732 {
743 foreach (AckData data in new List<AckData>(m_NeedAck.Values)) 733 foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
744 { 734 {
745 if (data.Identifier != null && data.Identifier == id) 735 if (data.Identifier != null && data.Identifier == id)
746 { 736 {
@@ -777,12 +767,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
777 // We want to see that packet arrive if it's reliable 767 // We want to see that packet arrive if it's reliable
778 if (packet.Header.Reliable) 768 if (packet.Header.Reliable)
779 { 769 {
780 m_UnackedBytes += packet.ToBytes().Length; 770 m_UnackedBytes += item.Length;
781 771
782 // Keep track of when this packet was sent out 772 // Keep track of when this packet was sent out
783 m_NeedAck[packet.Header.Sequence] = new AckData(packet, 773 item.TickCount = System.Environment.TickCount;
784 item.Identifier, System.Environment.TickCount, 774
785 0); 775 m_NeedAck[packet.Header.Sequence] = item;
786 } 776 }
787 } 777 }
788 } 778 }
@@ -792,7 +782,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
792 Abort(); 782 Abort();
793 783
794 // Actually make the byte array and send it 784 // Actually make the byte array and send it
795 byte[] sendbuffer = packet.ToBytes(); 785 byte[] sendbuffer = item.Packet.ToBytes();
796 786
797 //m_log.DebugFormat( 787 //m_log.DebugFormat(
798 // "[CLIENT]: In {0} sending packet {1}", 788 // "[CLIENT]: In {0} sending packet {1}",