diff options
author | Melanie Thielker | 2009-05-02 13:16:41 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-05-02 13:16:41 +0000 |
commit | 62bcf0e69405ee1443f66eecd1f3fbd684f0c2a5 (patch) | |
tree | 24a887f787545c95fcc721cf41ac8c9b17d1ef85 /OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | |
parent | Also add these packet to the list of packets to be recycled. No enabled (diff) | |
download | opensim-SC_OLD-62bcf0e69405ee1443f66eecd1f3fbd684f0c2a5.zip opensim-SC_OLD-62bcf0e69405ee1443f66eecd1f3fbd684f0c2a5.tar.gz opensim-SC_OLD-62bcf0e69405ee1443f66eecd1f3fbd684f0c2a5.tar.bz2 opensim-SC_OLD-62bcf0e69405ee1443f66eecd1f3fbd684f0c2a5.tar.xz |
Numerous packet improvements.
Don't allow packets to be resent before they have actually been sent for the
first time. Switch from serializing a packet to get it's length to the LibOMV
provided Length property. Fix resend timing. Fix the use of dangling references
to Acked packets. Fix the packet handler to play nice with the packet pool.
Fix the packet pool. Add data block recycling to the packet pool. Packet pool
is now ENABLED by default. Add config option to disable packet and data block
reuse. Add ObjectUpdate and ImprovedTerseObjectUpdate to the packets being
recycled.
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index 2191ca7..6229237 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | |||
@@ -253,7 +253,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
253 | item.TickCount = Environment.TickCount; | 253 | item.TickCount = Environment.TickCount; |
254 | item.Identifier = id; | 254 | item.Identifier = id; |
255 | item.Resends = 0; | 255 | item.Resends = 0; |
256 | item.Length = packet.ToBytes().Length; | 256 | item.Length = packet.Length; |
257 | item.Sequence = packet.Header.Sequence; | ||
257 | 258 | ||
258 | m_PacketQueue.Enqueue(item); | 259 | m_PacketQueue.Enqueue(item); |
259 | m_PacketsSent++; | 260 | m_PacketsSent++; |
@@ -310,7 +311,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
310 | 311 | ||
311 | // Packets this old get resent | 312 | // Packets this old get resent |
312 | // | 313 | // |
313 | if ((now - data.TickCount) > m_ResendTimeout) | 314 | if ((now - data.TickCount) > m_ResendTimeout && data.Sequence != 0) |
314 | { | 315 | { |
315 | if (resent < 20) | 316 | if (resent < 20) |
316 | { | 317 | { |
@@ -325,6 +326,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
325 | { | 326 | { |
326 | m_NeedAck.Remove(packet.Header.Sequence); | 327 | m_NeedAck.Remove(packet.Header.Sequence); |
327 | TriggerOnPacketDrop(packet, data.Identifier); | 328 | TriggerOnPacketDrop(packet, data.Identifier); |
329 | m_PacketQueue.Cancel(packet.Header.Sequence); | ||
328 | PacketPool.Instance.ReturnPacket(packet); | 330 | PacketPool.Instance.ReturnPacket(packet); |
329 | continue; | 331 | continue; |
330 | } | 332 | } |
@@ -586,11 +588,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
586 | return; | 588 | return; |
587 | 589 | ||
588 | m_NeedAck.Remove(id); | 590 | m_NeedAck.Remove(id); |
589 | // We can't return this packet, it will just have to be GC'd | 591 | m_PacketQueue.Cancel(data.Sequence); |
590 | // Reason for that is that the packet may still be in the | 592 | PacketPool.Instance.ReturnPacket(data.Packet); |
591 | // send queue, and if it gets reused things get messy! | ||
592 | // | ||
593 | // PacketPool.Instance.ReturnPacket(data.Packet); | ||
594 | m_UnackedBytes -= data.Length; | 593 | m_UnackedBytes -= data.Length; |
595 | } | 594 | } |
596 | } | 595 | } |
@@ -680,7 +679,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
680 | item.TickCount = Environment.TickCount; | 679 | item.TickCount = Environment.TickCount; |
681 | item.Identifier = 0; | 680 | item.Identifier = 0; |
682 | item.Resends = 0; | 681 | item.Resends = 0; |
683 | item.Length = packet.ToBytes().Length; | 682 | item.Length = packet.Length; |
683 | item.Sequence = packet.Header.Sequence; | ||
684 | m_NeedAck.Add(key, item); | 684 | m_NeedAck.Add(key, item); |
685 | } | 685 | } |
686 | 686 | ||
@@ -719,6 +719,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
719 | if (data.Identifier != null && data.Identifier == id) | 719 | if (data.Identifier != null && data.Identifier == id) |
720 | { | 720 | { |
721 | m_NeedAck.Remove(data.Packet.Header.Sequence); | 721 | m_NeedAck.Remove(data.Packet.Header.Sequence); |
722 | m_PacketQueue.Cancel(data.Sequence); | ||
722 | PacketPool.Instance.ReturnPacket(data.Packet); | 723 | PacketPool.Instance.ReturnPacket(data.Packet); |
723 | return; | 724 | return; |
724 | } | 725 | } |
@@ -745,6 +746,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
745 | if (packet.Header.Sequence == 0) | 746 | if (packet.Header.Sequence == 0) |
746 | { | 747 | { |
747 | packet.Header.Sequence = NextPacketSequenceNumber(); | 748 | packet.Header.Sequence = NextPacketSequenceNumber(); |
749 | item.Sequence = packet.Header.Sequence; | ||
750 | item.TickCount = Environment.TickCount; | ||
748 | 751 | ||
749 | lock (m_NeedAck) | 752 | lock (m_NeedAck) |
750 | { | 753 | { |
@@ -793,7 +796,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
793 | // Dont't return in that case | 796 | // Dont't return in that case |
794 | // | 797 | // |
795 | if (!packet.Header.Reliable) | 798 | if (!packet.Header.Reliable) |
799 | { | ||
800 | m_PacketQueue.Cancel(item.Sequence); | ||
796 | PacketPool.Instance.ReturnPacket(packet); | 801 | PacketPool.Instance.ReturnPacket(packet); |
802 | } | ||
797 | } | 803 | } |
798 | 804 | ||
799 | private void Abort() | 805 | private void Abort() |