From 450bdb36579889aca3de3fc14caf3b0069408bfd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 31 Jul 2011 02:30:40 +0100 Subject: In the packetpool, if we encounter a data block that somehow wasn't retrieved via GetDataBlock() then create a new stack instead of throwing an exception --- OpenSim/Framework/PacketPool.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Framework/PacketPool.cs index 7e2860e..41d17c5 100644 --- a/OpenSim/Framework/PacketPool.cs +++ b/OpenSim/Framework/PacketPool.cs @@ -144,6 +144,7 @@ namespace OpenSim.Framework m_log.WarnFormat("[PACKETPOOL]: Failed to get packet of type {0}", type); else packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); + return packet; } @@ -160,19 +161,18 @@ namespace OpenSim.Framework case PacketType.ObjectUpdate: ObjectUpdatePacket oup = (ObjectUpdatePacket)packet; - foreach (ObjectUpdatePacket.ObjectDataBlock oupod in - oup.ObjectData) + foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData) ReturnDataBlock(oupod); + oup.ObjectData = null; break; case PacketType.ImprovedTerseObjectUpdate: - ImprovedTerseObjectUpdatePacket itoup = - (ImprovedTerseObjectUpdatePacket)packet; + ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet; - foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock - itoupod in itoup.ObjectData) + foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData) ReturnDataBlock(itoupod); + itoup.ObjectData = null; break; } @@ -194,6 +194,7 @@ namespace OpenSim.Framework { pool[type] = new Stack(); } + if ((pool[type]).Count < 50) { (pool[type]).Push(packet); @@ -223,6 +224,7 @@ namespace OpenSim.Framework { DataBlocks[typeof(T)] = new Stack(); } + return new T(); } } @@ -234,6 +236,9 @@ namespace OpenSim.Framework lock (DataBlocks) { + if (!DataBlocks.ContainsKey(typeof(T))) + DataBlocks[typeof(T)] = new Stack(); + if (DataBlocks[typeof(T)].Count < 50) DataBlocks[typeof(T)].Push(block); } -- cgit v1.1