aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
diff options
context:
space:
mode:
authorUbitUmarov2018-11-25 18:38:37 +0000
committerUbitUmarov2018-11-25 18:38:37 +0000
commitd179b2dda1b4a378c18c431d2f51d437c443ce6b (patch)
tree0c4f1363571462b518bc719c8b28567a23c87b5d /OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
parentupdate contributors (diff)
downloadopensim-SC-d179b2dda1b4a378c18c431d2f51d437c443ce6b.zip
opensim-SC-d179b2dda1b4a378c18c431d2f51d437c443ce6b.tar.gz
opensim-SC-d179b2dda1b4a378c18c431d2f51d437c443ce6b.tar.bz2
opensim-SC-d179b2dda1b4a378c18c431d2f51d437c443ce6b.tar.xz
avoid data references stuck in packet pools
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs85
1 files changed, 44 insertions, 41 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
index f585bea..9b94a29 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
@@ -105,7 +105,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
105 { 105 {
106 // defaults 106 // defaults
107 RecyclePackets = true; 107 RecyclePackets = true;
108 RecycleDataBlocks = true; 108 // RecycleDataBlocks = true;
109 RecycleDataBlocks = false;
109 } 110 }
110 111
111 /// <summary> 112 /// <summary>
@@ -198,60 +199,62 @@ namespace OpenSim.Region.ClientStack.LindenUDP
198 /// <param name="packet"></param> 199 /// <param name="packet"></param>
199 public void ReturnPacket(Packet packet) 200 public void ReturnPacket(Packet packet)
200 { 201 {
201 if (RecycleDataBlocks) 202 if (!RecyclePackets)
203 return;
204
205 bool trypool = false;
206 PacketType type = packet.Type;
207
208 switch (type)
202 { 209 {
203 switch (packet.Type) 210 case PacketType.ObjectUpdate:
204 { 211 ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
205 case PacketType.ObjectUpdate:
206 ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
207 212
213 if (RecycleDataBlocks)
214 {
208 foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData) 215 foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData)
209 ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod); 216 ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod);
217 }
210 218
211 oup.ObjectData = null; 219 oup.ObjectData = null;
212 break; 220 trypool = true;
221 break;
213 222
214 case PacketType.ImprovedTerseObjectUpdate: 223 case PacketType.ImprovedTerseObjectUpdate:
215 ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet; 224 ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet;
216 225
226 if (RecycleDataBlocks)
227 {
217 foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData) 228 foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData)
218 ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod); 229 ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod);
230 }
219 231
220 itoup.ObjectData = null; 232 itoup.ObjectData = null;
221 break; 233 trypool = true;
222 } 234 break;
235
236 case PacketType.AgentUpdate:
237 case PacketType.PacketAck:
238 trypool = true;
239 break;
240 default:
241 return;
223 } 242 }
224 243
225 if (RecyclePackets) 244 if(!trypool)
245 return;
246
247 lock (pool)
226 { 248 {
227 switch (packet.Type) 249 if (!pool.ContainsKey(type))
250 {
251 pool[type] = new Stack<Packet>();
252 }
253
254 if ((pool[type]).Count < 50)
228 { 255 {
229 // List pooling packets here 256// m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
230 case PacketType.AgentUpdate: 257 pool[type].Push(packet);
231 case PacketType.PacketAck:
232 case PacketType.ObjectUpdate:
233 case PacketType.ImprovedTerseObjectUpdate:
234 lock (pool)
235 {
236 PacketType type = packet.Type;
237
238 if (!pool.ContainsKey(type))
239 {
240 pool[type] = new Stack<Packet>();
241 }
242
243 if ((pool[type]).Count < 50)
244 {
245// m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
246
247 pool[type].Push(packet);
248 }
249 }
250 break;
251
252 // Other packets wont pool
253 default:
254 return;
255 } 258 }
256 } 259 }
257 } 260 }