aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie Thielker2009-05-02 21:21:20 +0000
committerMelanie Thielker2009-05-02 21:21:20 +0000
commit229a4d54cac83d2b7796392382b8676419ab1324 (patch)
tree5128cb03e68a5943098e8a67dd52446982bbef59 /OpenSim/Region
parentHandle resends better (diff)
downloadopensim-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.cs52
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
28using System; 28using System;
29using System.Reflection;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Net.Sockets; 31using System.Net.Sockets;
31using System.Threading; 32using System.Threading;
32using System.Timers; 33using System.Timers;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
36using log4net;
35using OpenSim.Framework; 37using OpenSim.Framework;
36using Timer=System.Timers.Timer; 38using 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