reversing the r2599 patch, as this started causing CreateThread errors for

me on Mono 1.2.4, which led to client crashes.  I think the Timer.Stop() 
wasn't doing what was desired on Mono.  The Queue refactoring should address
the readability issues lbsa71 was working on as soon as I get the merge together.
afrisby
Sean Dague 2007-12-06 20:13:02 +00:00
parent 73599c0f25
commit 1ad83bcf1b
3 changed files with 267 additions and 303 deletions

View File

@ -776,13 +776,8 @@ namespace OpenSim.Framework.Communications.Cache
im.Header.Reliable = false; im.Header.Reliable = false;
im.ImageID.Packet = (ushort) (req.PacketCounter); im.ImageID.Packet = (ushort) (req.PacketCounter);
im.ImageID.ID = req.ImageInfo.FullID; im.ImageID.ID = req.ImageInfo.FullID;
int size = req.ImageInfo.Data.Length - 600 - (1000*(req.PacketCounter - 1)); int size = req.ImageInfo.Data.Length - 600 - (1000*(req.PacketCounter - 1));
if (size > 1000) if (size > 1000) size = 1000;
{
size = 1000;
}
//Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size);
im.ImageData.Data = new byte[size]; im.ImageData.Data = new byte[size];
Array.Copy(req.ImageInfo.Data, 600 + (1000*(req.PacketCounter - 1)), im.ImageData.Data, 0, size); Array.Copy(req.ImageInfo.Data, 600 + (1000*(req.PacketCounter - 1)), im.ImageData.Data, 0, size);

View File

@ -91,62 +91,62 @@ namespace OpenSim.Region.ClientStack
protected AgentCircuitManager m_authenticateSessionsHandler; protected AgentCircuitManager m_authenticateSessionsHandler;
private Encoding enc = Encoding.ASCII; private Encoding enc = Encoding.ASCII;
// Dead client detection vars // Dead client detection vars
private Timer m_clientPingTimer; private Timer clientPingTimer;
private int m_packetsReceived = 0; private int packetsReceived = 0;
private int m_probesWithNoIngressPackets = 0; private int probesWithNoIngressPackets = 0;
private int m_lastPacketsReceived = 0; private int lastPacketsReceived = 0;
// 1536000 // 1536000
private int m_throttleOutboundMax = 1536000; // Number of bytes allowed to go out per second. (256kbps per client) private int throttleOutboundMax = 1536000; // Number of bytes allowed to go out per second. (256kbps per client)
// TODO: Make this variable. Lower throttle on un-ack. Raise over time? // TODO: Make this variable. Lower throttle on un-ack. Raise over time?
private int m_bytesSent = 0; // Number of bytes sent this period private int bytesSent = 0; // Number of bytes sent this period
private int m_throttleOutbound = 162144; // Number of bytes allowed to go out per second. (256kbps per client) private int throttleOutbound = 162144; // Number of bytes allowed to go out per second. (256kbps per client)
// TODO: Make this variable. Lower throttle on un-ack. Raise over time // TODO: Make this variable. Lower throttle on un-ack. Raise over time
// All throttle times and number of bytes are calculated by dividing by this value // All throttle times and number of bytes are calculated by dividing by this value
// This value also determines how many times per throttletimems the timer will run // This value also determines how many times per throttletimems the timer will run
// If throttleimems is 1000 ms, then the timer will fire every 1000/7 milliseconds // If throttleimems is 1000 ms, then the timer will fire every 1000/7 milliseconds
private int m_throttleTimeDivisor = 7; private int throttleTimeDivisor = 7;
private int m_throttletimems = 1000; private int throttletimems = 1000;
// Maximum -per type- throttle // Maximum -per type- throttle
private int m_resendthrottleMAX = 100000; private int ResendthrottleMAX = 100000;
private int m_landthrottleMax = 100000; private int LandthrottleMax = 100000;
private int m_windthrottleMax = 100000; private int WindthrottleMax = 100000;
private int m_cloudthrottleMax = 100000; private int CloudthrottleMax = 100000;
private int m_taskthrottleMax = 800000; private int TaskthrottleMax = 800000;
private int m_assetthrottleMax = 800000; private int AssetthrottleMax = 800000;
private int m_texturethrottleMax = 800000; private int TexturethrottleMax = 800000;
// Minimum -per type- throttle // Minimum -per type- throttle
private int m_resendthrottleMin = 5000; // setting resendmin to 0 results in mostly dropped packets private int ResendthrottleMin = 5000; // setting resendmin to 0 results in mostly dropped packets
private int m_landthrottleMin = 1000; private int LandthrottleMin = 1000;
private int m_windthrottleMin = 1000; private int WindthrottleMin = 1000;
private int m_cloudthrottleMin = 1000; private int CloudthrottleMin = 1000;
private int m_taskthrottleMin = 1000; private int TaskthrottleMin = 1000;
private int m_assetthrottleMin = 1000; private int AssetthrottleMin = 1000;
private int m_texturethrottleMin = 1000; private int TexturethrottleMin = 1000;
// Sim default per-client settings. // Sim default per-client settings.
private int m_resendthrottleOutbound = 50000; private int ResendthrottleOutbound = 50000;
private int m_resendBytesSent = 0; private int ResendBytesSent = 0;
private int m_landthrottleOutbound = 100000; private int LandthrottleOutbound = 100000;
private int m_landBytesSent = 0; private int LandBytesSent = 0;
private int m_windthrottleOutbound = 10000; private int WindthrottleOutbound = 10000;
private int m_windBytesSent = 0; private int WindBytesSent = 0;
private int m_cloudthrottleOutbound = 5000; private int CloudthrottleOutbound = 5000;
private int m_cloudBytesSent = 0; private int CloudBytesSent = 0;
private int m_taskthrottleOutbound = 100000; private int TaskthrottleOutbound = 100000;
private int m_taskBytesSent = 0; private int TaskBytesSent = 0;
private int m_assetthrottleOutbound = 80000; private int AssetthrottleOutbound = 80000;
private int m_assetBytesSent = 0; private int AssetBytesSent = 0;
private int m_texturethrottleOutbound = 100000; private int TexturethrottleOutbound = 100000;
private int m_textureBytesSent = 0; private int TextureBytesSent = 0;
private Timer m_throttleTimer; private Timer throttleTimer;
public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager,
IScene scene, AssetCache assetCache, PacketServer packServer, IScene scene, AssetCache assetCache, PacketServer packServer,
@ -174,17 +174,17 @@ namespace OpenSim.Region.ClientStack
// in it to process. it's an on-purpose threadlock though because // in it to process. it's an on-purpose threadlock though because
// without it, the clientloop will suck up all sim resources. // without it, the clientloop will suck up all sim resources.
m_packetQueue = new BlockingQueue<QueItem>(); PacketQueue = new BlockingQueue<QueItem>();
m_incomingPacketQueue = new Queue<QueItem>(); IncomingPacketQueue = new Queue<QueItem>();
m_outgoingPacketQueue = new Queue<QueItem>(); OutgoingPacketQueue = new Queue<QueItem>();
m_resendOutgoingPacketQueue = new Queue<QueItem>(); ResendOutgoingPacketQueue = new Queue<QueItem>();
m_landOutgoingPacketQueue = new Queue<QueItem>(); LandOutgoingPacketQueue = new Queue<QueItem>();
m_windOutgoingPacketQueue = new Queue<QueItem>(); WindOutgoingPacketQueue = new Queue<QueItem>();
m_cloudOutgoingPacketQueue = new Queue<QueItem>(); CloudOutgoingPacketQueue = new Queue<QueItem>();
m_taskOutgoingPacketQueue = new Queue<QueItem>(); TaskOutgoingPacketQueue = new Queue<QueItem>();
m_textureOutgoingPacketQueue = new Queue<QueItem>(); TextureOutgoingPacketQueue = new Queue<QueItem>();
m_assetOutgoingPacketQueue = new Queue<QueItem>(); AssetOutgoingPacketQueue = new Queue<QueItem>();
//this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
@ -192,9 +192,9 @@ namespace OpenSim.Region.ClientStack
AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
AckTimer.Start(); AckTimer.Start();
m_throttleTimer = new Timer((int)(m_throttletimems/m_throttleTimeDivisor)); throttleTimer = new Timer((int)(throttletimems/throttleTimeDivisor));
m_throttleTimer.Elapsed += throttleTimer_Elapsed; throttleTimer.Elapsed += new ElapsedEventHandler(throttleTimer_Elapsed);
m_throttleTimer.Start(); throttleTimer.Start();
RegisterLocalPacketHandlers(); RegisterLocalPacketHandlers();
@ -205,24 +205,14 @@ namespace OpenSim.Region.ClientStack
void throttleTimer_Elapsed(object sender, ElapsedEventArgs e) void throttleTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
// We need to stop the timer so that another timer event won't cause queue races. bytesSent = 0;
m_throttleTimer.Stop(); ResendBytesSent = 0;
LandBytesSent = 0;
ProcessThrottleQueues(); WindBytesSent = 0;
CloudBytesSent = 0;
m_throttleTimer.Start(); TaskBytesSent = 0;
} AssetBytesSent = 0;
TextureBytesSent = 0;
private void ProcessThrottleQueues()
{
m_bytesSent = 0;
m_resendBytesSent = 0;
m_landBytesSent = 0;
m_windBytesSent = 0;
m_cloudBytesSent = 0;
m_taskBytesSent = 0;
m_assetBytesSent = 0;
m_textureBytesSent = 0;
// I was considering this.. Will an event fire if the thread it's on is blocked? // I was considering this.. Will an event fire if the thread it's on is blocked?
@ -235,96 +225,76 @@ namespace OpenSim.Region.ClientStack
// We're going to dequeue all of the saved up packets until // We're going to dequeue all of the saved up packets until
// we've hit the throttle limit or there's no more packets to send // we've hit the throttle limit or there's no more packets to send
while ((bytesSent <= ((int)(throttleOutbound/throttleTimeDivisor)) &&
(ResendOutgoingPacketQueue.Count > 0 ||
LandOutgoingPacketQueue.Count > 0 ||
while (TimeToDequeue( m_bytesSent, m_throttleOutbound ) && WindOutgoingPacketQueue.Count > 0 ||
(m_resendOutgoingPacketQueue.Count > 0 || CloudOutgoingPacketQueue.Count > 0 ||
m_landOutgoingPacketQueue.Count > 0 || TaskOutgoingPacketQueue.Count > 0 ||
m_windOutgoingPacketQueue.Count > 0 || AssetOutgoingPacketQueue.Count > 0 ||
m_cloudOutgoingPacketQueue.Count > 0 || TextureOutgoingPacketQueue.Count > 0)) && throttleLoops <= MaxThrottleLoops)
m_taskOutgoingPacketQueue.Count > 0 ||
m_assetOutgoingPacketQueue.Count > 0 ||
m_textureOutgoingPacketQueue.Count > 0) && ( throttleLoops <= MaxThrottleLoops))
{ {
throttleLoops++; throttleLoops++;
//Now comes the fun part.. we dump all our elements into PacketQueue that we've saved up. //Now comes the fun part.. we dump all our elements into PacketQueue that we've saved up.
if (ResendBytesSent <= ((int)(ResendthrottleOutbound/throttleTimeDivisor)) && ResendOutgoingPacketQueue.Count > 0)
if (TimeToDequeue(m_resendBytesSent, m_resendthrottleOutbound))
{ {
m_resendBytesSent += ProcessQueue(m_resendOutgoingPacketQueue); QueItem qpack = ResendOutgoingPacketQueue.Dequeue();
}
if (TimeToDequeue(m_landBytesSent, m_landthrottleOutbound)) PacketQueue.Enqueue(qpack);
bytesSent += qpack.Packet.ToBytes().Length;
ResendBytesSent += qpack.Packet.ToBytes().Length;
}
if (LandBytesSent <= ((int)(LandthrottleOutbound/throttleTimeDivisor)) && LandOutgoingPacketQueue.Count > 0)
{ {
m_landBytesSent += ProcessQueue(m_landOutgoingPacketQueue); QueItem qpack = LandOutgoingPacketQueue.Dequeue();
PacketQueue.Enqueue(qpack);
bytesSent += qpack.Packet.ToBytes().Length;
LandBytesSent += qpack.Packet.ToBytes().Length;
} }
if (WindBytesSent <= ((int)(WindthrottleOutbound/throttleTimeDivisor)) && WindOutgoingPacketQueue.Count > 0)
// -- TODO: Well, do the same for the rest of them
if (m_windBytesSent <= ((int)(m_windthrottleOutbound/m_throttleTimeDivisor)) && m_windOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = m_windOutgoingPacketQueue.Dequeue(); QueItem qpack = WindOutgoingPacketQueue.Dequeue();
m_packetQueue.Enqueue(qpack); PacketQueue.Enqueue(qpack);
m_bytesSent += qpack.Packet.ToBytes().Length; bytesSent += qpack.Packet.ToBytes().Length;
m_windBytesSent += qpack.Packet.ToBytes().Length; WindBytesSent += qpack.Packet.ToBytes().Length;
} }
if (m_cloudBytesSent <= ((int)(m_cloudthrottleOutbound/m_throttleTimeDivisor)) && m_cloudOutgoingPacketQueue.Count > 0) if (CloudBytesSent <= ((int)(CloudthrottleOutbound/throttleTimeDivisor)) && CloudOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = m_cloudOutgoingPacketQueue.Dequeue(); QueItem qpack = CloudOutgoingPacketQueue.Dequeue();
m_packetQueue.Enqueue(qpack); PacketQueue.Enqueue(qpack);
m_bytesSent += qpack.Packet.ToBytes().Length; bytesSent += qpack.Packet.ToBytes().Length;
m_cloudBytesSent += qpack.Packet.ToBytes().Length; CloudBytesSent += qpack.Packet.ToBytes().Length;
} }
if (m_taskBytesSent <= ((int)(m_taskthrottleOutbound/m_throttleTimeDivisor)) && m_taskOutgoingPacketQueue.Count > 0) if (TaskBytesSent <= ((int)(TaskthrottleOutbound/throttleTimeDivisor)) && TaskOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = m_taskOutgoingPacketQueue.Dequeue(); QueItem qpack = TaskOutgoingPacketQueue.Dequeue();
m_packetQueue.Enqueue(qpack); PacketQueue.Enqueue(qpack);
m_bytesSent += qpack.Packet.ToBytes().Length; bytesSent += qpack.Packet.ToBytes().Length;
m_taskBytesSent += qpack.Packet.ToBytes().Length; TaskBytesSent += qpack.Packet.ToBytes().Length;
} }
if (m_textureBytesSent <= ((int)(m_texturethrottleOutbound/m_throttleTimeDivisor)) && m_textureOutgoingPacketQueue.Count > 0) if (TextureBytesSent <= ((int)(TexturethrottleOutbound/throttleTimeDivisor)) && TextureOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = m_textureOutgoingPacketQueue.Dequeue(); QueItem qpack = TextureOutgoingPacketQueue.Dequeue();
m_packetQueue.Enqueue(qpack); PacketQueue.Enqueue(qpack);
m_bytesSent += qpack.Packet.ToBytes().Length; bytesSent += qpack.Packet.ToBytes().Length;
m_textureBytesSent += qpack.Packet.ToBytes().Length; TextureBytesSent += qpack.Packet.ToBytes().Length;
} }
if (m_assetBytesSent <= ((int)(m_assetthrottleOutbound/m_throttleTimeDivisor)) && m_assetOutgoingPacketQueue.Count > 0) if (AssetBytesSent <= ((int)(AssetthrottleOutbound/throttleTimeDivisor)) && AssetOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = m_assetOutgoingPacketQueue.Dequeue(); QueItem qpack = AssetOutgoingPacketQueue.Dequeue();
m_packetQueue.Enqueue(qpack); PacketQueue.Enqueue(qpack);
m_bytesSent += qpack.Packet.ToBytes().Length; bytesSent += qpack.Packet.ToBytes().Length;
m_assetBytesSent += qpack.Packet.ToBytes().Length; AssetBytesSent += qpack.Packet.ToBytes().Length;
} }
} }
}
private int ProcessQueue(Queue<QueItem> queue)
{
if (queue.Count > 0)
{
QueItem qpack = queue.Dequeue();
m_packetQueue.Enqueue(qpack);
int packLength = qpack.Packet.ToBytes().Length;
m_bytesSent += packLength;
return packLength;
}
return 0;
}
private bool TimeToDequeue(int bytesSent, int outboundThrottle)
{
return bytesSent <= ((int)(outboundThrottle / m_throttleTimeDivisor));
} }
public LLUUID SessionId public LLUUID SessionId
@ -341,7 +311,7 @@ namespace OpenSim.Region.ClientStack
public void Close() public void Close()
{ {
m_clientPingTimer.Stop(); clientPingTimer.Stop();
m_scene.RemoveClient(AgentId); m_scene.RemoveClient(AgentId);
@ -363,7 +333,7 @@ namespace OpenSim.Region.ClientStack
} }
public void Stop() public void Stop()
{ {
m_clientPingTimer.Stop(); clientPingTimer.Stop();
libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket();
OutPacket(disable, ThrottleOutPacketType.Task); OutPacket(disable, ThrottleOutPacketType.Task);
@ -464,7 +434,7 @@ namespace OpenSim.Region.ClientStack
MainLog.Instance.Verbose("CLIENT", "Entered loop"); MainLog.Instance.Verbose("CLIENT", "Entered loop");
while (true) while (true)
{ {
QueItem nextPacket = m_packetQueue.Dequeue(); QueItem nextPacket = PacketQueue.Dequeue();
if (nextPacket.Incoming) if (nextPacket.Incoming)
{ {
queuedLast = false; queuedLast = false;
@ -472,7 +442,7 @@ namespace OpenSim.Region.ClientStack
//is a incoming packet //is a incoming packet
if (nextPacket.Packet.Type != PacketType.AgentUpdate) if (nextPacket.Packet.Type != PacketType.AgentUpdate)
{ {
m_packetsReceived++; packetsReceived++;
} }
DebugPacket("IN", nextPacket.Packet); DebugPacket("IN", nextPacket.Packet);
ProcessInPacket(nextPacket.Packet); ProcessInPacket(nextPacket.Packet);
@ -480,9 +450,9 @@ namespace OpenSim.Region.ClientStack
else else
{ {
// Throw it back on the queue if it's going to cause us to flood the client // Throw it back on the queue if it's going to cause us to flood the client
if (m_bytesSent > m_throttleOutboundMax) if (bytesSent > throttleOutboundMax)
{ {
m_packetQueue.Enqueue(nextPacket); PacketQueue.Enqueue(nextPacket);
MainLog.Instance.Verbose("THROTTLE", "Client over throttle limit, requeuing packet"); MainLog.Instance.Verbose("THROTTLE", "Client over throttle limit, requeuing packet");
if (queuedLast) if (queuedLast)
@ -501,7 +471,7 @@ namespace OpenSim.Region.ClientStack
//Don't throttle AvatarPickerReplies!, they return a null .ToBytes()! //Don't throttle AvatarPickerReplies!, they return a null .ToBytes()!
if (nextPacket.Packet.Type != PacketType.AvatarPickerReply) if (nextPacket.Packet.Type != PacketType.AvatarPickerReply)
m_bytesSent += nextPacket.Packet.ToBytes().Length; bytesSent += nextPacket.Packet.ToBytes().Length;
//is a out going packet //is a out going packet
@ -517,10 +487,10 @@ namespace OpenSim.Region.ClientStack
protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) protected void CheckClientConnectivity(object sender, ElapsedEventArgs e)
{ {
if (m_packetsReceived == m_lastPacketsReceived) if (packetsReceived == lastPacketsReceived)
{ {
m_probesWithNoIngressPackets++; probesWithNoIngressPackets++;
if (m_probesWithNoIngressPackets > 30) if (probesWithNoIngressPackets > 30)
{ {
if (OnConnectionClosed != null) if (OnConnectionClosed != null)
{ {
@ -536,8 +506,8 @@ namespace OpenSim.Region.ClientStack
else else
{ {
// Something received in the meantime - we can reset the counters // Something received in the meantime - we can reset the counters
m_probesWithNoIngressPackets = 0; probesWithNoIngressPackets = 0;
m_lastPacketsReceived = m_packetsReceived; lastPacketsReceived = packetsReceived;
} }
} }
@ -545,9 +515,9 @@ namespace OpenSim.Region.ClientStack
protected virtual void InitNewClient() protected virtual void InitNewClient()
{ {
m_clientPingTimer = new Timer(5000); clientPingTimer = new Timer(5000);
m_clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity);
m_clientPingTimer.Enabled = true; clientPingTimer.Enabled = true;
MainLog.Instance.Verbose("CLIENT", "Adding viewer agent to scene"); MainLog.Instance.Verbose("CLIENT", "Adding viewer agent to scene");
m_scene.AddNewClient(this, true); m_scene.AddNewClient(this, true);
@ -2233,20 +2203,20 @@ namespace OpenSim.Region.ClientStack
} }
// Previously ClientView.PacketQueue // Previously ClientView.PacketQueue
protected BlockingQueue<QueItem> m_packetQueue; protected BlockingQueue<QueItem> PacketQueue;
protected Queue<QueItem> m_incomingPacketQueue; protected Queue<QueItem> IncomingPacketQueue;
protected Queue<QueItem> m_outgoingPacketQueue; protected Queue<QueItem> OutgoingPacketQueue;
protected Queue<QueItem> m_resendOutgoingPacketQueue; protected Queue<QueItem> ResendOutgoingPacketQueue;
protected Queue<QueItem> m_landOutgoingPacketQueue; protected Queue<QueItem> LandOutgoingPacketQueue;
protected Queue<QueItem> m_windOutgoingPacketQueue; protected Queue<QueItem> WindOutgoingPacketQueue;
protected Queue<QueItem> m_cloudOutgoingPacketQueue; protected Queue<QueItem> CloudOutgoingPacketQueue;
protected Queue<QueItem> m_taskOutgoingPacketQueue; protected Queue<QueItem> TaskOutgoingPacketQueue;
protected Queue<QueItem> m_textureOutgoingPacketQueue; protected Queue<QueItem> TextureOutgoingPacketQueue;
protected Queue<QueItem> m_assetOutgoingPacketQueue; protected Queue<QueItem> AssetOutgoingPacketQueue;
protected Dictionary<uint, uint> m_pendingAcks = new Dictionary<uint, uint>(); protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
protected Dictionary<uint, Packet> m_needAck = new Dictionary<uint, Packet>(); protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
protected Timer AckTimer; protected Timer AckTimer;
protected uint Sequence = 0; protected uint Sequence = 0;
@ -2288,13 +2258,13 @@ namespace OpenSim.Region.ClientStack
protected void AddAck(Packet Pack) protected void AddAck(Packet Pack)
{ {
lock (m_needAck) lock (NeedAck)
{ {
if (!m_needAck.ContainsKey(Pack.Header.Sequence)) if (!NeedAck.ContainsKey(Pack.Header.Sequence))
{ {
try try
{ {
m_needAck.Add(Pack.Header.Sequence, Pack); NeedAck.Add(Pack.Header.Sequence, Pack);
} }
catch (Exception e) // HACKY catch (Exception e) // HACKY
{ {
@ -2308,7 +2278,7 @@ namespace OpenSim.Region.ClientStack
else else
{ {
// Client.Log("Attempted to add a duplicate sequence number (" + // Client.Log("Attempted to add a duplicate sequence number (" +
// packet.Header.Sequence + ") to the m_needAck dictionary for packet type " + // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " +
// packet.Type.ToString(), Helpers.LogLevel.Warning); // packet.Type.ToString(), Helpers.LogLevel.Warning);
} }
} }
@ -2317,21 +2287,21 @@ namespace OpenSim.Region.ClientStack
protected virtual void SetPendingAcks(ref Packet Pack) protected virtual void SetPendingAcks(ref Packet Pack)
{ {
// Append any ACKs that need to be sent out to this packet // Append any ACKs that need to be sent out to this packet
lock (m_pendingAcks) lock (PendingAcks)
{ {
// TODO: If we are over MAX_APPENDED_ACKS we should drain off some of these // TODO: If we are over MAX_APPENDED_ACKS we should drain off some of these
if (m_pendingAcks.Count > 0 && m_pendingAcks.Count < MAX_APPENDED_ACKS) if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS)
{ {
Pack.Header.AckList = new uint[m_pendingAcks.Count]; Pack.Header.AckList = new uint[PendingAcks.Count];
int i = 0; int i = 0;
foreach (uint ack in m_pendingAcks.Values) foreach (uint ack in PendingAcks.Values)
{ {
Pack.Header.AckList[i] = ack; Pack.Header.AckList[i] = ack;
i++; i++;
} }
m_pendingAcks.Clear(); PendingAcks.Clear();
Pack.Header.AppendedAcks = true; Pack.Header.AppendedAcks = true;
} }
} }
@ -2387,11 +2357,11 @@ namespace OpenSim.Region.ClientStack
// Handle appended ACKs // Handle appended ACKs
if (NewPack.Header.AppendedAcks) if (NewPack.Header.AppendedAcks)
{ {
lock (m_needAck) lock (NeedAck)
{ {
foreach (uint ack in NewPack.Header.AckList) foreach (uint ack in NewPack.Header.AckList)
{ {
m_needAck.Remove(ack); NeedAck.Remove(ack);
} }
} }
} }
@ -2401,11 +2371,11 @@ namespace OpenSim.Region.ClientStack
{ {
PacketAckPacket ackPacket = (PacketAckPacket) NewPack; PacketAckPacket ackPacket = (PacketAckPacket) NewPack;
lock (m_needAck) lock (NeedAck)
{ {
foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
{ {
m_needAck.Remove(block.ID); NeedAck.Remove(block.ID);
} }
} }
} }
@ -2422,7 +2392,7 @@ namespace OpenSim.Region.ClientStack
QueItem item = new QueItem(); QueItem item = new QueItem();
item.Packet = NewPack; item.Packet = NewPack;
item.Incoming = true; item.Incoming = true;
m_packetQueue.Enqueue(item); PacketQueue.Enqueue(item);
} }
} }
@ -2434,11 +2404,11 @@ namespace OpenSim.Region.ClientStack
// wait for the timer to fire to put things into the // wait for the timer to fire to put things into the
// output queue // output queue
if((q.Count == 0) && (TypeBytesSent <= ((int)(Throttle / m_throttleTimeDivisor)))) if((q.Count == 0) && (TypeBytesSent <= ((int)(Throttle / throttleTimeDivisor))))
{ {
m_bytesSent += item.Packet.ToBytes().Length; bytesSent += item.Packet.ToBytes().Length;
TypeBytesSent += item.Packet.ToBytes().Length; TypeBytesSent += item.Packet.ToBytes().Length;
m_packetQueue.Enqueue(item); PacketQueue.Enqueue(item);
} }
else else
{ {
@ -2458,34 +2428,34 @@ namespace OpenSim.Region.ClientStack
switch (throttlePacketType) switch (throttlePacketType)
{ {
case ThrottleOutPacketType.Resend: case ThrottleOutPacketType.Resend:
ThrottleCheck(ref m_resendBytesSent, m_resendthrottleOutbound, ref m_resendOutgoingPacketQueue, item); ThrottleCheck(ref ResendBytesSent, ResendthrottleOutbound, ref ResendOutgoingPacketQueue, item);
break; break;
case ThrottleOutPacketType.Texture: case ThrottleOutPacketType.Texture:
ThrottleCheck(ref m_textureBytesSent, m_texturethrottleOutbound, ref m_textureOutgoingPacketQueue, item); ThrottleCheck(ref TextureBytesSent, TexturethrottleOutbound, ref TextureOutgoingPacketQueue, item);
break; break;
case ThrottleOutPacketType.Task: case ThrottleOutPacketType.Task:
ThrottleCheck(ref m_taskBytesSent, m_taskthrottleOutbound, ref m_taskOutgoingPacketQueue, item); ThrottleCheck(ref TaskBytesSent, TaskthrottleOutbound, ref TaskOutgoingPacketQueue, item);
break; break;
case ThrottleOutPacketType.Land: case ThrottleOutPacketType.Land:
ThrottleCheck(ref m_landBytesSent, m_landthrottleOutbound, ref m_landOutgoingPacketQueue, item); ThrottleCheck(ref LandBytesSent, LandthrottleOutbound, ref LandOutgoingPacketQueue, item);
break; break;
case ThrottleOutPacketType.Asset: case ThrottleOutPacketType.Asset:
ThrottleCheck(ref m_assetBytesSent, m_assetthrottleOutbound, ref m_assetOutgoingPacketQueue, item); ThrottleCheck(ref AssetBytesSent, AssetthrottleOutbound, ref AssetOutgoingPacketQueue, item);
break; break;
case ThrottleOutPacketType.Cloud: case ThrottleOutPacketType.Cloud:
ThrottleCheck(ref m_cloudBytesSent, m_cloudthrottleOutbound, ref m_cloudOutgoingPacketQueue, item); ThrottleCheck(ref CloudBytesSent, CloudthrottleOutbound, ref CloudOutgoingPacketQueue, item);
break; break;
case ThrottleOutPacketType.Wind: case ThrottleOutPacketType.Wind:
ThrottleCheck(ref m_windBytesSent, m_windthrottleOutbound, ref m_windOutgoingPacketQueue, item); ThrottleCheck(ref WindBytesSent, WindthrottleOutbound, ref WindOutgoingPacketQueue, item);
break; break;
default: default:
// Acknowledgements and other such stuff should go directly to the blocking Queue // Acknowledgements and other such stuff should go directly to the blocking Queue
// Throttling them may and likely 'will' be problematic // Throttling them may and likely 'will' be problematic
m_packetQueue.Enqueue(item); PacketQueue.Enqueue(item);
break; break;
} }
//m_outgoingPacketQueue.Enqueue(item); //OutgoingPacketQueue.Enqueue(item);
} }
# region Low Level Packet Methods # region Low Level Packet Methods
@ -2505,10 +2475,10 @@ namespace OpenSim.Region.ClientStack
/* /*
if (Pack.Header.Reliable) if (Pack.Header.Reliable)
{ {
lock (m_pendingAcks) lock (PendingAcks)
{ {
uint sequence = (uint)Pack.Header.Sequence; uint sequence = (uint)Pack.Header.Sequence;
if (!m_pendingAcks.ContainsKey(sequence)) { m_pendingAcks[sequence] = sequence; } if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
} }
}*/ }*/
} }
@ -2517,9 +2487,9 @@ namespace OpenSim.Region.ClientStack
{ {
int now = System.Environment.TickCount; int now = System.Environment.TickCount;
lock (m_needAck) lock (NeedAck)
{ {
foreach (Packet packet in m_needAck.Values) foreach (Packet packet in NeedAck.Values)
{ {
if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
{ {
@ -2535,11 +2505,11 @@ namespace OpenSim.Region.ClientStack
protected void SendAcks() protected void SendAcks()
{ {
lock (m_pendingAcks) lock (PendingAcks)
{ {
if (m_pendingAcks.Count > 0) if (PendingAcks.Count > 0)
{ {
if (m_pendingAcks.Count > 250) if (PendingAcks.Count > 250)
{ {
// FIXME: Handle the odd case where we have too many pending ACKs queued up // FIXME: Handle the odd case where we have too many pending ACKs queued up
MainLog.Instance.Verbose("NETWORK", "Too many ACKs queued up!"); MainLog.Instance.Verbose("NETWORK", "Too many ACKs queued up!");
@ -2550,9 +2520,9 @@ namespace OpenSim.Region.ClientStack
int i = 0; int i = 0;
PacketAckPacket acks = new PacketAckPacket(); PacketAckPacket acks = new PacketAckPacket();
acks.Packets = new PacketAckPacket.PacketsBlock[m_pendingAcks.Count]; acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
foreach (uint ack in m_pendingAcks.Values) foreach (uint ack in PendingAcks.Values)
{ {
acks.Packets[i] = new PacketAckPacket.PacketsBlock(); acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = ack; acks.Packets[i].ID = ack;
@ -2562,7 +2532,7 @@ namespace OpenSim.Region.ClientStack
acks.Header.Reliable = false; acks.Header.Reliable = false;
OutPacket(acks, ThrottleOutPacketType.Unknown); OutPacket(acks, ThrottleOutPacketType.Unknown);
m_pendingAcks.Clear(); PendingAcks.Clear();
} }
} }
} }
@ -3415,7 +3385,7 @@ namespace OpenSim.Region.ClientStack
// If the client didn't send acceptable values.... // If the client didn't send acceptable values....
// Scale the clients values down until they are acceptable. // Scale the clients values down until they are acceptable.
if (tall <= m_throttleOutboundMax) if (tall <= throttleOutboundMax)
{ {
// Sanity // Sanity
// Making sure the client sends sane values // Making sure the client sends sane values
@ -3424,61 +3394,61 @@ namespace OpenSim.Region.ClientStack
// Then Check Min of type // Then Check Min of type
// Resend throttle // Resend throttle
if (tResend <= m_resendthrottleMAX) if (tResend <= ResendthrottleMAX)
m_resendthrottleOutbound = tResend; ResendthrottleOutbound = tResend;
if (tResend < m_resendthrottleMin) if (tResend < ResendthrottleMin)
m_resendthrottleOutbound = m_resendthrottleMin; ResendthrottleOutbound = ResendthrottleMin;
// Land throttle // Land throttle
if (tLand <= m_landthrottleMax) if (tLand <= LandthrottleMax)
m_landthrottleOutbound = tLand; LandthrottleOutbound = tLand;
if (tLand < m_landthrottleMin) if (tLand < LandthrottleMin)
m_landthrottleOutbound = m_landthrottleMin; LandthrottleOutbound = LandthrottleMin;
// Wind throttle // Wind throttle
if (tWind <= m_windthrottleMax) if (tWind <= WindthrottleMax)
m_windthrottleOutbound = tWind; WindthrottleOutbound = tWind;
if (tWind < m_windthrottleMin) if (tWind < WindthrottleMin)
m_windthrottleOutbound = m_windthrottleMin; WindthrottleOutbound = WindthrottleMin;
// Cloud throttle // Cloud throttle
if (tCloud <= m_cloudthrottleMax) if (tCloud <= CloudthrottleMax)
m_cloudthrottleOutbound = tCloud; CloudthrottleOutbound = tCloud;
if (tCloud < m_cloudthrottleMin) if (tCloud < CloudthrottleMin)
m_cloudthrottleOutbound = m_cloudthrottleMin; CloudthrottleOutbound = CloudthrottleMin;
// Task throttle // Task throttle
if (tTask <= m_taskthrottleMax) if (tTask <= TaskthrottleMax)
m_taskthrottleOutbound = tTask; TaskthrottleOutbound = tTask;
if (tTask < m_taskthrottleMin) if (tTask < TaskthrottleMin)
m_taskthrottleOutbound = m_taskthrottleMin; TaskthrottleOutbound = TaskthrottleMin;
// Texture throttle // Texture throttle
if (tTexture <= m_texturethrottleMax) if (tTexture <= TexturethrottleMax)
m_texturethrottleOutbound = tTexture; TexturethrottleOutbound = tTexture;
if (tTexture < m_texturethrottleMin) if (tTexture < TexturethrottleMin)
m_texturethrottleOutbound = m_texturethrottleMin; TexturethrottleOutbound = TexturethrottleMin;
//Asset throttle //Asset throttle
if (tAsset <= m_assetthrottleMax) if (tAsset <= AssetthrottleMax)
m_assetthrottleOutbound = tAsset; AssetthrottleOutbound = tAsset;
if (tAsset < m_assetthrottleMin) if (tAsset < AssetthrottleMin)
m_assetthrottleOutbound = m_assetthrottleMin; AssetthrottleOutbound = AssetthrottleMin;
/* MainLog.Instance.Verbose("THROTTLE", "Using:resendbytes=" + m_resendthrottleOutbound + /* MainLog.Instance.Verbose("THROTTLE", "Using:resendbytes=" + ResendthrottleOutbound +
" landbytes=" + m_landthrottleOutbound + " landbytes=" + LandthrottleOutbound +
" windbytes=" + m_windthrottleOutbound + " windbytes=" + WindthrottleOutbound +
" cloudbytes=" + m_cloudthrottleOutbound + " cloudbytes=" + CloudthrottleOutbound +
" taskbytes=" + m_taskthrottleOutbound + " taskbytes=" + TaskthrottleOutbound +
" texturebytes=" + m_texturethrottleOutbound + " texturebytes=" + TexturethrottleOutbound +
" Assetbytes=" + m_assetthrottleOutbound + " Assetbytes=" + AssetthrottleOutbound +
" Allbytes=" + tall); " Allbytes=" + tall);
*/ */
} }
@ -3498,23 +3468,23 @@ namespace OpenSim.Region.ClientStack
// it's client recommended level (won't scale it down) // it's client recommended level (won't scale it down)
// unless it's beyond sane values itself. // unless it's beyond sane values itself.
if (tResend <= m_resendthrottleMAX) if (tResend <= ResendthrottleMAX)
{ {
// This is nexted because we only want to re-set the values // This is nexted because we only want to re-set the values
// the packet throttler uses once. // the packet throttler uses once.
if (tResend >= m_resendthrottleMin) if (tResend >= ResendthrottleMin)
{ {
m_resendthrottleOutbound = tResend; ResendthrottleOutbound = tResend;
} }
else else
{ {
m_resendthrottleOutbound = m_resendthrottleMin; ResendthrottleOutbound = ResendthrottleMin;
} }
} }
else else
{ {
m_resendthrottleOutbound = m_resendthrottleMAX; ResendthrottleOutbound = ResendthrottleMAX;
} }
@ -3529,12 +3499,12 @@ namespace OpenSim.Region.ClientStack
// Okay.. now we've got the percentages of total communication. // Okay.. now we've got the percentages of total communication.
// Apply them to a new max total // Apply them to a new max total
int tLandResult = (int)(LandPercent * m_throttleOutboundMax); int tLandResult = (int)(LandPercent * throttleOutboundMax);
int tWindResult = (int)(WindPercent * m_throttleOutboundMax); int tWindResult = (int)(WindPercent * throttleOutboundMax);
int tCloudResult = (int)(CloudPercent * m_throttleOutboundMax); int tCloudResult = (int)(CloudPercent * throttleOutboundMax);
int tTaskResult = (int)(TaskPercent * m_throttleOutboundMax); int tTaskResult = (int)(TaskPercent * throttleOutboundMax);
int tTextureResult = (int)(TexturePercent * m_throttleOutboundMax); int tTextureResult = (int)(TexturePercent * throttleOutboundMax);
int tAssetResult = (int)(AssetPercent * m_throttleOutboundMax); int tAssetResult = (int)(AssetPercent * throttleOutboundMax);
// Now we have to check our scaled values for sanity // Now we have to check our scaled values for sanity
@ -3542,54 +3512,54 @@ namespace OpenSim.Region.ClientStack
// Then Check Min of type // Then Check Min of type
// Land throttle // Land throttle
if (tLandResult <= m_landthrottleMax) if (tLandResult <= LandthrottleMax)
m_landthrottleOutbound = tLandResult; LandthrottleOutbound = tLandResult;
if (tLandResult < m_landthrottleMin) if (tLandResult < LandthrottleMin)
m_landthrottleOutbound = m_landthrottleMin; LandthrottleOutbound = LandthrottleMin;
// Wind throttle // Wind throttle
if (tWindResult <= m_windthrottleMax) if (tWindResult <= WindthrottleMax)
m_windthrottleOutbound = tWindResult; WindthrottleOutbound = tWindResult;
if (tWindResult < m_windthrottleMin) if (tWindResult < WindthrottleMin)
m_windthrottleOutbound = m_windthrottleMin; WindthrottleOutbound = WindthrottleMin;
// Cloud throttle // Cloud throttle
if (tCloudResult <= m_cloudthrottleMax) if (tCloudResult <= CloudthrottleMax)
m_cloudthrottleOutbound = tCloudResult; CloudthrottleOutbound = tCloudResult;
if (tCloudResult < m_cloudthrottleMin) if (tCloudResult < CloudthrottleMin)
m_cloudthrottleOutbound = m_cloudthrottleMin; CloudthrottleOutbound = CloudthrottleMin;
// Task throttle // Task throttle
if (tTaskResult <= m_taskthrottleMax) if (tTaskResult <= TaskthrottleMax)
m_taskthrottleOutbound = tTaskResult; TaskthrottleOutbound = tTaskResult;
if (tTaskResult < m_taskthrottleMin) if (tTaskResult < TaskthrottleMin)
m_taskthrottleOutbound = m_taskthrottleMin; TaskthrottleOutbound = TaskthrottleMin;
// Texture throttle // Texture throttle
if (tTextureResult <= m_texturethrottleMax) if (tTextureResult <= TexturethrottleMax)
m_texturethrottleOutbound = tTextureResult; TexturethrottleOutbound = tTextureResult;
if (tTextureResult < m_texturethrottleMin) if (tTextureResult < TexturethrottleMin)
m_texturethrottleOutbound = m_texturethrottleMin; TexturethrottleOutbound = TexturethrottleMin;
//Asset throttle //Asset throttle
if (tAssetResult <= m_assetthrottleMax) if (tAssetResult <= AssetthrottleMax)
m_assetthrottleOutbound = tAssetResult; AssetthrottleOutbound = tAssetResult;
if (tAssetResult < m_assetthrottleMin) if (tAssetResult < AssetthrottleMin)
m_assetthrottleOutbound = m_assetthrottleMin; AssetthrottleOutbound = AssetthrottleMin;
/* MainLog.Instance.Verbose("THROTTLE", "Using:resendbytes=" + m_resendthrottleOutbound + /* MainLog.Instance.Verbose("THROTTLE", "Using:resendbytes=" + ResendthrottleOutbound +
" landbytes=" + m_landthrottleOutbound + " landbytes=" + LandthrottleOutbound +
" windbytes=" + m_windthrottleOutbound + " windbytes=" + WindthrottleOutbound +
" cloudbytes=" + m_cloudthrottleOutbound + " cloudbytes=" + CloudthrottleOutbound +
" taskbytes=" + m_taskthrottleOutbound + " taskbytes=" + TaskthrottleOutbound +
" texturebytes=" + m_texturethrottleOutbound + " texturebytes=" + TexturethrottleOutbound +
" Assetbytes=" + m_assetthrottleOutbound + " Assetbytes=" + AssetthrottleOutbound +
" Allbytes=" + tall); " Allbytes=" + tall);
*/ */
} }
@ -3597,20 +3567,20 @@ namespace OpenSim.Region.ClientStack
{ {
// The client sent a stupid value.. // The client sent a stupid value..
// We're going to set the throttles to the minimum possible // We're going to set the throttles to the minimum possible
m_resendthrottleOutbound = m_resendthrottleMin; ResendthrottleOutbound = ResendthrottleMin;
m_landthrottleOutbound = m_landthrottleMin; LandthrottleOutbound = LandthrottleMin;
m_windthrottleOutbound = m_windthrottleMin; WindthrottleOutbound = WindthrottleMin;
m_cloudthrottleOutbound = m_cloudthrottleMin; CloudthrottleOutbound = CloudthrottleMin;
m_taskthrottleOutbound = m_taskthrottleMin; TaskthrottleOutbound = TaskthrottleMin;
m_texturethrottleOutbound = m_texturethrottleMin; TexturethrottleOutbound = TexturethrottleMin;
m_assetthrottleOutbound = m_assetthrottleMin; AssetthrottleOutbound = AssetthrottleMin;
MainLog.Instance.Verbose("THROTTLE", "ClientSentBadThrottle Using:resendbytes=" + m_resendthrottleOutbound + MainLog.Instance.Verbose("THROTTLE", "ClientSentBadThrottle Using:resendbytes=" + ResendthrottleOutbound +
" landbytes=" + m_landthrottleOutbound + " landbytes=" + LandthrottleOutbound +
" windbytes=" + m_windthrottleOutbound + " windbytes=" + WindthrottleOutbound +
" cloudbytes=" + m_cloudthrottleOutbound + " cloudbytes=" + CloudthrottleOutbound +
" taskbytes=" + m_taskthrottleOutbound + " taskbytes=" + TaskthrottleOutbound +
" texturebytes=" + m_texturethrottleOutbound + " texturebytes=" + TexturethrottleOutbound +
" Assetbytes=" + m_assetthrottleOutbound + " Assetbytes=" + AssetthrottleOutbound +
" Allbytes=" + tall); " Allbytes=" + tall);
} }
} }
@ -3618,13 +3588,13 @@ namespace OpenSim.Region.ClientStack
// This has the effect of 'wiggling the slider // This has the effect of 'wiggling the slider
// causes prim and stuck textures that didn't download to download // causes prim and stuck textures that didn't download to download
m_resendBytesSent = 0; ResendBytesSent = 0;
m_landBytesSent = 0; LandBytesSent = 0;
m_windBytesSent = 0; WindBytesSent = 0;
m_cloudBytesSent = 0; CloudBytesSent = 0;
m_taskBytesSent = 0; TaskBytesSent = 0;
m_assetBytesSent = 0; AssetBytesSent = 0;
m_textureBytesSent = 0; TextureBytesSent = 0;
//Yay, we've finally handled the agent Throttle packet! //Yay, we've finally handled the agent Throttle packet!
break; break;

View File

@ -396,7 +396,6 @@ namespace OpenSim.Region.Environment.Scenes
module.Close(); module.Close();
} }
} }
Modules.Clear(); Modules.Clear();
base.Close(); base.Close();