diff options
author | Melanie Thielker | 2009-05-02 21:21:20 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-05-02 21:21:20 +0000 |
commit | 229a4d54cac83d2b7796392382b8676419ab1324 (patch) | |
tree | 5128cb03e68a5943098e8a67dd52446982bbef59 /OpenSim/Region | |
parent | Handle resends better (diff) | |
download | opensim-SC_OLD-229a4d54cac83d2b7796392382b8676419ab1324.zip opensim-SC_OLD-229a4d54cac83d2b7796392382b8676419ab1324.tar.gz opensim-SC_OLD-229a4d54cac83d2b7796392382b8676419ab1324.tar.bz2 opensim-SC_OLD-229a4d54cac83d2b7796392382b8676419ab1324.tar.xz |
If a packet pooling blows up, fail gracefully instead of disconnecting
the user
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index c020b38..cabcb7d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | |||
@@ -26,12 +26,14 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
31 | using System.Threading; | 32 | using System.Threading; |
32 | using System.Timers; | 33 | using System.Timers; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenMetaverse.Packets; | 35 | using OpenMetaverse.Packets; |
36 | using log4net; | ||
35 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
36 | using Timer=System.Timers.Timer; | 38 | using Timer=System.Timers.Timer; |
37 | 39 | ||
@@ -39,8 +41,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
39 | { | 41 | { |
40 | public class LLPacketHandler : ILLPacketHandler | 42 | public class LLPacketHandler : ILLPacketHandler |
41 | { | 43 | { |
42 | //private static readonly ILog m_log | 44 | private static readonly ILog m_log |
43 | // = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 46 | ||
45 | //private int m_resentCount; | 47 | //private int m_resentCount; |
46 | 48 | ||
@@ -768,28 +770,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
768 | if (packet is KillPacket) | 770 | if (packet is KillPacket) |
769 | Abort(); | 771 | Abort(); |
770 | 772 | ||
771 | // Actually make the byte array and send it | 773 | try |
772 | byte[] sendbuffer = item.Packet.ToBytes(); | 774 | { |
775 | // If this packet has been reused/returned, the ToBytes | ||
776 | // will blow up in our face. | ||
777 | // Fail gracefully. | ||
778 | // | ||
773 | 779 | ||
774 | //m_log.DebugFormat( | 780 | // Actually make the byte array and send it |
775 | // "[CLIENT]: In {0} sending packet {1}", | 781 | byte[] sendbuffer = item.Packet.ToBytes(); |
776 | // m_Client.Scene.RegionInfo.ExternalEndPoint.Port, packet.Header.Sequence); | ||
777 | 782 | ||
778 | if (packet.Header.Zerocoded) | 783 | if (packet.Header.Zerocoded) |
779 | { | 784 | { |
780 | int packetsize = Helpers.ZeroEncode(sendbuffer, | 785 | int packetsize = Helpers.ZeroEncode(sendbuffer, |
781 | sendbuffer.Length, m_ZeroOutBuffer); | 786 | sendbuffer.Length, m_ZeroOutBuffer); |
782 | m_PacketServer.SendPacketTo(m_ZeroOutBuffer, packetsize, | 787 | m_PacketServer.SendPacketTo(m_ZeroOutBuffer, packetsize, |
783 | SocketFlags.None, m_Client.CircuitCode); | 788 | SocketFlags.None, m_Client.CircuitCode); |
789 | } | ||
790 | else | ||
791 | { | ||
792 | // Need some extra space in case we need to add proxy | ||
793 | // information to the message later | ||
794 | Buffer.BlockCopy(sendbuffer, 0, m_ZeroOutBuffer, 0, | ||
795 | sendbuffer.Length); | ||
796 | m_PacketServer.SendPacketTo(m_ZeroOutBuffer, | ||
797 | sendbuffer.Length, SocketFlags.None, m_Client.CircuitCode); | ||
798 | } | ||
784 | } | 799 | } |
785 | else | 800 | catch (NullReferenceException) |
786 | { | 801 | { |
787 | // Need some extra space in case we need to add proxy | 802 | m_log.Debug("[PACKET] Detected reuse of a returned packet"); |
788 | // information to the message later | 803 | m_PacketQueue.Cancel(item.Sequence); |
789 | Buffer.BlockCopy(sendbuffer, 0, m_ZeroOutBuffer, 0, | 804 | return; |
790 | sendbuffer.Length); | ||
791 | m_PacketServer.SendPacketTo(m_ZeroOutBuffer, | ||
792 | sendbuffer.Length, SocketFlags.None, m_Client.CircuitCode); | ||
793 | } | 805 | } |
794 | 806 | ||
795 | // If this is a reliable packet, we are still holding a ref | 807 | // If this is a reliable packet, we are still holding a ref |