avoid data references stuck in packet pools

0.9.1.0-post-fixes
UbitUmarov 2018-11-25 18:38:37 +00:00
parent 91986445a6
commit d179b2dda1
3 changed files with 48 additions and 48 deletions

View File

@ -2142,7 +2142,6 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
HTTPDRunning = false; HTTPDRunning = false;
StatsManager.DeregisterStat(m_requestsProcessedStat); StatsManager.DeregisterStat(m_requestsProcessedStat);
try try

View File

@ -466,7 +466,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_circuitManager = circuitManager; m_circuitManager = circuitManager;
int sceneThrottleBps = 0; int sceneThrottleBps = 0;
bool usePools = false; // bool usePools = false;
IConfig config = configSource.Configs["ClientStack.LindenUDP"]; IConfig config = configSource.Configs["ClientStack.LindenUDP"];
if (config != null) if (config != null)
@ -497,8 +497,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (packetConfig != null) if (packetConfig != null)
{ {
PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); // PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
usePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", usePools); // usePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", usePools);
} }
#region BinaryStats #region BinaryStats
@ -896,7 +896,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method) LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
{ {
// CoarseLocationUpdate packets cannot be split in an automated way // CoarseLocationUpdate packets cannot be split in an automated way
if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting) if (allowSplitting && packet.Type == PacketType.CoarseLocationUpdate)
allowSplitting = false; allowSplitting = false;
// bool packetQueued = false; // bool packetQueued = false;
@ -1055,7 +1055,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SendPing(LLUDPClient udpClient) public void SendPing(LLUDPClient udpClient)
{ {
StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck); StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
pc.Header.Reliable = false;
pc.PingID.PingID = (byte)udpClient.CurrentPingSequence++; pc.PingID.PingID = (byte)udpClient.CurrentPingSequence++;
// We *could* get OldestUnacked, but it would hurt performance and not provide any benefit // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
@ -1963,7 +1962,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, Throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, Throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
client = new LLClientView(Scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); client = new LLClientView(Scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
client.OnLogout += LogoutHandler; client.OnLogout += LogoutHandler;
client.DebugPacketLevel = DefaultClientPacketDebugLevel; client.DebugPacketLevel = DefaultClientPacketDebugLevel;

View File

@ -105,7 +105,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
// defaults // defaults
RecyclePackets = true; RecyclePackets = true;
RecycleDataBlocks = true; // RecycleDataBlocks = true;
RecycleDataBlocks = false;
} }
/// <summary> /// <summary>
@ -198,60 +199,62 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="packet"></param> /// <param name="packet"></param>
public void ReturnPacket(Packet packet) public void ReturnPacket(Packet packet)
{ {
if (RecycleDataBlocks) if (!RecyclePackets)
{ return;
switch (packet.Type)
{
case PacketType.ObjectUpdate:
ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
bool trypool = false;
PacketType type = packet.Type;
switch (type)
{
case PacketType.ObjectUpdate:
ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
if (RecycleDataBlocks)
{
foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData) foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData)
ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod); ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod);
}
oup.ObjectData = null; oup.ObjectData = null;
break; trypool = true;
break;
case PacketType.ImprovedTerseObjectUpdate: case PacketType.ImprovedTerseObjectUpdate:
ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet; ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet;
if (RecycleDataBlocks)
{
foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData) foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData)
ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod); ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod);
}
itoup.ObjectData = null; itoup.ObjectData = null;
break; trypool = true;
} break;
case PacketType.AgentUpdate:
case PacketType.PacketAck:
trypool = true;
break;
default:
return;
} }
if (RecyclePackets) if(!trypool)
return;
lock (pool)
{ {
switch (packet.Type) if (!pool.ContainsKey(type))
{ {
// List pooling packets here pool[type] = new Stack<Packet>();
case PacketType.AgentUpdate: }
case PacketType.PacketAck:
case PacketType.ObjectUpdate:
case PacketType.ImprovedTerseObjectUpdate:
lock (pool)
{
PacketType type = packet.Type;
if (!pool.ContainsKey(type)) if ((pool[type]).Count < 50)
{ {
pool[type] = new Stack<Packet>(); // m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
} pool[type].Push(packet);
if ((pool[type]).Count < 50)
{
// m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
pool[type].Push(packet);
}
}
break;
// Other packets wont pool
default:
return;
} }
} }
} }