If a packet pooling blows up, fail gracefully instead of disconnecting
the user0.6.5-rc1
parent
780f34275b
commit
229a4d54ca
|
@ -26,12 +26,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.Packets;
|
using OpenMetaverse.Packets;
|
||||||
|
using log4net;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using Timer=System.Timers.Timer;
|
using Timer=System.Timers.Timer;
|
||||||
|
|
||||||
|
@ -39,8 +41,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
public class LLPacketHandler : ILLPacketHandler
|
public class LLPacketHandler : ILLPacketHandler
|
||||||
{
|
{
|
||||||
//private static readonly ILog m_log
|
private static readonly ILog m_log
|
||||||
// = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
//private int m_resentCount;
|
//private int m_resentCount;
|
||||||
|
|
||||||
|
@ -768,13 +770,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
if (packet is KillPacket)
|
if (packet is KillPacket)
|
||||||
Abort();
|
Abort();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// If this packet has been reused/returned, the ToBytes
|
||||||
|
// will blow up in our face.
|
||||||
|
// Fail gracefully.
|
||||||
|
//
|
||||||
|
|
||||||
// Actually make the byte array and send it
|
// Actually make the byte array and send it
|
||||||
byte[] sendbuffer = item.Packet.ToBytes();
|
byte[] sendbuffer = item.Packet.ToBytes();
|
||||||
|
|
||||||
//m_log.DebugFormat(
|
|
||||||
// "[CLIENT]: In {0} sending packet {1}",
|
|
||||||
// m_Client.Scene.RegionInfo.ExternalEndPoint.Port, packet.Header.Sequence);
|
|
||||||
|
|
||||||
if (packet.Header.Zerocoded)
|
if (packet.Header.Zerocoded)
|
||||||
{
|
{
|
||||||
int packetsize = Helpers.ZeroEncode(sendbuffer,
|
int packetsize = Helpers.ZeroEncode(sendbuffer,
|
||||||
|
@ -791,6 +796,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
m_PacketServer.SendPacketTo(m_ZeroOutBuffer,
|
m_PacketServer.SendPacketTo(m_ZeroOutBuffer,
|
||||||
sendbuffer.Length, SocketFlags.None, m_Client.CircuitCode);
|
sendbuffer.Length, SocketFlags.None, m_Client.CircuitCode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (NullReferenceException)
|
||||||
|
{
|
||||||
|
m_log.Debug("[PACKET] Detected reuse of a returned packet");
|
||||||
|
m_PacketQueue.Cancel(item.Sequence);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If this is a reliable packet, we are still holding a ref
|
// If this is a reliable packet, we are still holding a ref
|
||||||
// Dont't return in that case
|
// Dont't return in that case
|
||||||
|
|
Loading…
Reference in New Issue