fix the queue type in use

LSLKeyTest
UbitUmarov 2015-12-09 16:26:03 +00:00
parent eccec66359
commit 3ca4b6f319
1 changed files with 12 additions and 11 deletions

View File

@ -286,7 +286,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <summary>Incoming packets that are awaiting handling</summary> /// <summary>Incoming packets that are awaiting handling</summary>
//private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>(); //private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>();
private DoubleQueue<IncomingPacket> packetInbox = new DoubleQueue<IncomingPacket>(); private OpenSim.Framework.BlockingQueue<IncomingPacket> packetInbox = new OpenSim.Framework.BlockingQueue<IncomingPacket>();
/// <summary>Bandwidth throttle for this UDP server</summary> /// <summary>Bandwidth throttle for this UDP server</summary>
public TokenBucket Throttle { get; private set; } public TokenBucket Throttle { get; private set; }
@ -716,7 +716,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
scene.Name, scene.Name,
StatType.Pull, StatType.Pull,
MeasuresOfInterest.AverageChangeOverTime, MeasuresOfInterest.AverageChangeOverTime,
stat => stat.Value = packetInbox.Count, stat => stat.Value = packetInbox.Count(),
StatVerbosity.Debug)); StatVerbosity.Debug));
// XXX: These stats are also pool stats but we register them separately since they are currently not // XXX: These stats are also pool stats but we register them separately since they are currently not
@ -1552,9 +1552,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// if (incomingPacket.Packet.Type == PacketType.AgentUpdate || // if (incomingPacket.Packet.Type == PacketType.AgentUpdate ||
// incomingPacket.Packet.Type == PacketType.ChatFromViewer) // incomingPacket.Packet.Type == PacketType.ChatFromViewer)
if (incomingPacket.Packet.Type == PacketType.ChatFromViewer) if (incomingPacket.Packet.Type == PacketType.ChatFromViewer)
packetInbox.EnqueueHigh(incomingPacket); packetInbox.PriorityEnqueue(incomingPacket);
else else
packetInbox.EnqueueLow(incomingPacket); packetInbox.Enqueue(incomingPacket);
} }
@ -2012,7 +2012,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void IncomingPacketHandler() private void IncomingPacketHandler()
{ {
Thread.CurrentThread.Priority = ThreadPriority.Highest; Thread.CurrentThread.Priority = ThreadPriority.Highest;
IncomingPacket incomingPacket;
// Set this culture for the thread that incoming packets are received // Set this culture for the thread that incoming packets are received
// on to en-US to avoid number parsing issues // on to en-US to avoid number parsing issues
Culture.SetCurrentCulture(); Culture.SetCurrentCulture();
@ -2022,8 +2022,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Scene.ThreadAlive(1); Scene.ThreadAlive(1);
try try
{ {
IncomingPacket incomingPacket = null;
/* /*
// HACK: This is a test to try and rate limit packet handling on Mono. // HACK: This is a test to try and rate limit packet handling on Mono.
// If it works, a more elegant solution can be devised // If it works, a more elegant solution can be devised
@ -2033,14 +2031,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Thread.Sleep(30); Thread.Sleep(30);
} }
*/ */
incomingPacket = packetInbox.Dequeue(500);
if (packetInbox.Dequeue(100, ref incomingPacket))
if (incomingPacket != null)
{ {
ProcessInPacket(incomingPacket);//, incomingPacket); Util.FireAndForget(ProcessInPacket, incomingPacket); ProcessInPacket(incomingPacket);//, incomingPacket); Util.FireAndForget(ProcessInPacket, incomingPacket);
if (UsePools) if (UsePools)
m_incomingPacketPool.ReturnObject(incomingPacket); m_incomingPacketPool.ReturnObject(incomingPacket);
} }
incomingPacket = null;
} }
catch(Exception ex) catch(Exception ex)
{ {
@ -2050,8 +2051,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Watchdog.UpdateThread(); Watchdog.UpdateThread();
} }
if (packetInbox.Count > 0) if (packetInbox.Count() > 0)
m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count + " packets"); m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count() + " packets");
packetInbox.Clear(); packetInbox.Clear();
Watchdog.RemoveThread(); Watchdog.RemoveThread();