diff options
author | Justin Clark-Casey (justincc) | 2011-07-31 02:30:40 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-07-31 02:30:40 +0100 |
commit | 450bdb36579889aca3de3fc14caf3b0069408bfd (patch) | |
tree | 9ed9ca43229866ebc7ebea1e0b4667930d153fd9 /OpenSim/Framework/PacketPool.cs | |
parent | Remove _mesh field since the mesh data no longer needs to be stored after it'... (diff) | |
download | opensim-SC_OLD-450bdb36579889aca3de3fc14caf3b0069408bfd.zip opensim-SC_OLD-450bdb36579889aca3de3fc14caf3b0069408bfd.tar.gz opensim-SC_OLD-450bdb36579889aca3de3fc14caf3b0069408bfd.tar.bz2 opensim-SC_OLD-450bdb36579889aca3de3fc14caf3b0069408bfd.tar.xz |
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
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/PacketPool.cs | 17 |
1 files 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 | |||
144 | m_log.WarnFormat("[PACKETPOOL]: Failed to get packet of type {0}", type); | 144 | m_log.WarnFormat("[PACKETPOOL]: Failed to get packet of type {0}", type); |
145 | else | 145 | else |
146 | packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); | 146 | packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); |
147 | |||
147 | return packet; | 148 | return packet; |
148 | } | 149 | } |
149 | 150 | ||
@@ -160,19 +161,18 @@ namespace OpenSim.Framework | |||
160 | case PacketType.ObjectUpdate: | 161 | case PacketType.ObjectUpdate: |
161 | ObjectUpdatePacket oup = (ObjectUpdatePacket)packet; | 162 | ObjectUpdatePacket oup = (ObjectUpdatePacket)packet; |
162 | 163 | ||
163 | foreach (ObjectUpdatePacket.ObjectDataBlock oupod in | 164 | foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData) |
164 | oup.ObjectData) | ||
165 | ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod); | 165 | ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod); |
166 | |||
166 | oup.ObjectData = null; | 167 | oup.ObjectData = null; |
167 | break; | 168 | break; |
168 | 169 | ||
169 | case PacketType.ImprovedTerseObjectUpdate: | 170 | case PacketType.ImprovedTerseObjectUpdate: |
170 | ImprovedTerseObjectUpdatePacket itoup = | 171 | ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet; |
171 | (ImprovedTerseObjectUpdatePacket)packet; | ||
172 | 172 | ||
173 | foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock | 173 | foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData) |
174 | itoupod in itoup.ObjectData) | ||
175 | ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod); | 174 | ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod); |
175 | |||
176 | itoup.ObjectData = null; | 176 | itoup.ObjectData = null; |
177 | break; | 177 | break; |
178 | } | 178 | } |
@@ -194,6 +194,7 @@ namespace OpenSim.Framework | |||
194 | { | 194 | { |
195 | pool[type] = new Stack<Packet>(); | 195 | pool[type] = new Stack<Packet>(); |
196 | } | 196 | } |
197 | |||
197 | if ((pool[type]).Count < 50) | 198 | if ((pool[type]).Count < 50) |
198 | { | 199 | { |
199 | (pool[type]).Push(packet); | 200 | (pool[type]).Push(packet); |
@@ -223,6 +224,7 @@ namespace OpenSim.Framework | |||
223 | { | 224 | { |
224 | DataBlocks[typeof(T)] = new Stack<Object>(); | 225 | DataBlocks[typeof(T)] = new Stack<Object>(); |
225 | } | 226 | } |
227 | |||
226 | return new T(); | 228 | return new T(); |
227 | } | 229 | } |
228 | } | 230 | } |
@@ -234,6 +236,9 @@ namespace OpenSim.Framework | |||
234 | 236 | ||
235 | lock (DataBlocks) | 237 | lock (DataBlocks) |
236 | { | 238 | { |
239 | if (!DataBlocks.ContainsKey(typeof(T))) | ||
240 | DataBlocks[typeof(T)] = new Stack<Object>(); | ||
241 | |||
237 | if (DataBlocks[typeof(T)].Count < 50) | 242 | if (DataBlocks[typeof(T)].Count < 50) |
238 | DataBlocks[typeof(T)].Push(block); | 243 | DataBlocks[typeof(T)].Push(block); |
239 | } | 244 | } |