From cebdd069f49a5ba6e5bc84eb5e96a63320795226 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 27 Nov 2007 20:37:17 +0000 Subject: [PATCH] some variable renames to help me read the throttle code --- .../ClientStack/ClientView.PacketQueue.cs | 42 +++++----- .../ClientStack/ClientView.ProcessPackets.cs | 14 ++-- OpenSim/Region/ClientStack/ClientView.cs | 80 +++++++++---------- 3 files changed, 68 insertions(+), 68 deletions(-) diff --git a/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs b/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs index 4ca7bd96e6..5916d00478 100644 --- a/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs +++ b/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs @@ -232,10 +232,10 @@ namespace OpenSim.Region.ClientStack switch (throttlePacketType) { case ThrottleOutPacketType.Resend: - if (ResendthrottleSentPeriod <= ((int)(ResendthrottleOutbound / throttleTimeDivisor)) && ResendOutgoingPacketQueue.Count == 0) + if (ResendBytesSent <= ((int)(ResendthrottleOutbound / throttleTimeDivisor)) && ResendOutgoingPacketQueue.Count == 0) { - throttleSentPeriod += item.Packet.ToBytes().Length; - ResendthrottleSentPeriod += item.Packet.ToBytes().Length; + bytesSent += item.Packet.ToBytes().Length; + ResendBytesSent += item.Packet.ToBytes().Length; PacketQueue.Enqueue(item); } else @@ -244,10 +244,10 @@ namespace OpenSim.Region.ClientStack } break; case ThrottleOutPacketType.Texture: - if (TexturethrottleSentPeriod <= ((int)(TexturethrottleOutbound / throttleTimeDivisor)) && TextureOutgoingPacketQueue.Count == 0) + if (TextureBytesSent <= ((int)(TexturethrottleOutbound / throttleTimeDivisor)) && TextureOutgoingPacketQueue.Count == 0) { - throttleSentPeriod += item.Packet.ToBytes().Length; - TexturethrottleSentPeriod += item.Packet.ToBytes().Length; + bytesSent += item.Packet.ToBytes().Length; + TextureBytesSent += item.Packet.ToBytes().Length; PacketQueue.Enqueue(item); } else @@ -256,10 +256,10 @@ namespace OpenSim.Region.ClientStack } break; case ThrottleOutPacketType.Task: - if (TaskthrottleSentPeriod <= ((int)(TexturethrottleOutbound / throttleTimeDivisor)) && TaskOutgoingPacketQueue.Count == 0) + if (TaskBytesSent <= ((int)(TexturethrottleOutbound / throttleTimeDivisor)) && TaskOutgoingPacketQueue.Count == 0) { - throttleSentPeriod += item.Packet.ToBytes().Length; - TaskthrottleSentPeriod += item.Packet.ToBytes().Length; + bytesSent += item.Packet.ToBytes().Length; + TaskBytesSent += item.Packet.ToBytes().Length; PacketQueue.Enqueue(item); } else @@ -268,10 +268,10 @@ namespace OpenSim.Region.ClientStack } break; case ThrottleOutPacketType.Land: - if (LandthrottleSentPeriod <= ((int)(LandthrottleOutbound / throttleTimeDivisor)) && LandOutgoingPacketQueue.Count == 0) + if (LandBytesSent <= ((int)(LandthrottleOutbound / throttleTimeDivisor)) && LandOutgoingPacketQueue.Count == 0) { - throttleSentPeriod += item.Packet.ToBytes().Length; - LandthrottleSentPeriod += item.Packet.ToBytes().Length; + bytesSent += item.Packet.ToBytes().Length; + LandBytesSent += item.Packet.ToBytes().Length; PacketQueue.Enqueue(item); } else @@ -280,10 +280,10 @@ namespace OpenSim.Region.ClientStack } break; case ThrottleOutPacketType.Asset: - if (AssetthrottleSentPeriod <= ((int)(AssetthrottleOutbound / throttleTimeDivisor)) && AssetOutgoingPacketQueue.Count == 0) + if (AssetBytesSent <= ((int)(AssetthrottleOutbound / throttleTimeDivisor)) && AssetOutgoingPacketQueue.Count == 0) { - throttleSentPeriod += item.Packet.ToBytes().Length; - AssetthrottleSentPeriod += item.Packet.ToBytes().Length; + bytesSent += item.Packet.ToBytes().Length; + AssetBytesSent += item.Packet.ToBytes().Length; PacketQueue.Enqueue(item); } else @@ -292,10 +292,10 @@ namespace OpenSim.Region.ClientStack } break; case ThrottleOutPacketType.Cloud: - if (CloudthrottleSentPeriod <= ((int)(CloudthrottleOutbound / throttleTimeDivisor)) && CloudOutgoingPacketQueue.Count == 0) + if (CloudBytesSent <= ((int)(CloudthrottleOutbound / throttleTimeDivisor)) && CloudOutgoingPacketQueue.Count == 0) { - throttleSentPeriod += item.Packet.ToBytes().Length; - CloudthrottleSentPeriod += item.Packet.ToBytes().Length; + bytesSent += item.Packet.ToBytes().Length; + CloudBytesSent += item.Packet.ToBytes().Length; PacketQueue.Enqueue(item); } else @@ -304,10 +304,10 @@ namespace OpenSim.Region.ClientStack } break; case ThrottleOutPacketType.Wind: - if (WindthrottleSentPeriod <= ((int)(WindthrottleOutbound / throttleTimeDivisor)) && WindOutgoingPacketQueue.Count == 0) + if (WindBytesSent <= ((int)(WindthrottleOutbound / throttleTimeDivisor)) && WindOutgoingPacketQueue.Count == 0) { - throttleSentPeriod += item.Packet.ToBytes().Length; - WindthrottleSentPeriod += item.Packet.ToBytes().Length; + bytesSent += item.Packet.ToBytes().Length; + WindBytesSent += item.Packet.ToBytes().Length; PacketQueue.Enqueue(item); } else diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index f46c199f0f..f7202778f5 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -1048,13 +1048,13 @@ namespace OpenSim.Region.ClientStack // This has the effect of 'wiggling the slider // causes prim and stuck textures that didn't download to download - ResendthrottleSentPeriod = 0; - LandthrottleSentPeriod = 0; - WindthrottleSentPeriod = 0; - CloudthrottleSentPeriod = 0; - TaskthrottleSentPeriod = 0; - AssetthrottleSentPeriod = 0; - TexturethrottleSentPeriod = 0; + ResendBytesSent = 0; + LandBytesSent = 0; + WindBytesSent = 0; + CloudBytesSent = 0; + TaskBytesSent = 0; + AssetBytesSent = 0; + TextureBytesSent = 0; //Yay, we've finally handled the agent Throttle packet! diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index fbe66dbb9f..28692bbb9d 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.ClientStack // 1536000 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? - private int throttleSentPeriod = 0; // Number of bytes sent this period + private int bytesSent = 0; // Number of bytes sent this period 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 @@ -123,19 +123,19 @@ namespace OpenSim.Region.ClientStack // Sim default per-client settings. private int ResendthrottleOutbound = 50000; - private int ResendthrottleSentPeriod = 0; + private int ResendBytesSent = 0; private int LandthrottleOutbound = 100000; - private int LandthrottleSentPeriod = 0; + private int LandBytesSent = 0; private int WindthrottleOutbound = 10000; - private int WindthrottleSentPeriod = 0; + private int WindBytesSent = 0; private int CloudthrottleOutbound = 5000; - private int CloudthrottleSentPeriod = 0; + private int CloudBytesSent = 0; private int TaskthrottleOutbound = 100000; - private int TaskthrottleSentPeriod = 0; + private int TaskBytesSent = 0; private int AssetthrottleOutbound = 80000; - private int AssetthrottleSentPeriod = 0; + private int AssetBytesSent = 0; private int TexturethrottleOutbound = 100000; - private int TexturethrottleSentPeriod = 0; + private int TextureBytesSent = 0; private Timer throttleTimer; @@ -196,14 +196,14 @@ namespace OpenSim.Region.ClientStack void throttleTimer_Elapsed(object sender, ElapsedEventArgs e) { - throttleSentPeriod = 0; - ResendthrottleSentPeriod = 0; - LandthrottleSentPeriod = 0; - WindthrottleSentPeriod = 0; - CloudthrottleSentPeriod = 0; - TaskthrottleSentPeriod = 0; - AssetthrottleSentPeriod = 0; - TexturethrottleSentPeriod = 0; + bytesSent = 0; + ResendBytesSent = 0; + LandBytesSent = 0; + WindBytesSent = 0; + CloudBytesSent = 0; + TaskBytesSent = 0; + AssetBytesSent = 0; + TextureBytesSent = 0; // I was considering this.. Will an event fire if the thread it's on is blocked? @@ -216,7 +216,7 @@ namespace OpenSim.Region.ClientStack // 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 - while ((throttleSentPeriod <= ((int)(throttleOutbound/throttleTimeDivisor)) && + while ((bytesSent <= ((int)(throttleOutbound/throttleTimeDivisor)) && (ResendOutgoingPacketQueue.Count > 0 || LandOutgoingPacketQueue.Count > 0 || WindOutgoingPacketQueue.Count > 0 || @@ -227,61 +227,61 @@ namespace OpenSim.Region.ClientStack { throttleLoops++; //Now comes the fun part.. we dump all our elements into PacketQueue that we've saved up. - if (ResendthrottleSentPeriod <= ((int)(ResendthrottleOutbound/throttleTimeDivisor)) && ResendOutgoingPacketQueue.Count > 0) + if (ResendBytesSent <= ((int)(ResendthrottleOutbound/throttleTimeDivisor)) && ResendOutgoingPacketQueue.Count > 0) { QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); PacketQueue.Enqueue(qpack); - throttleSentPeriod += qpack.Packet.ToBytes().Length; - ResendthrottleSentPeriod += qpack.Packet.ToBytes().Length; + bytesSent += qpack.Packet.ToBytes().Length; + ResendBytesSent += qpack.Packet.ToBytes().Length; } - if (LandthrottleSentPeriod <= ((int)(LandthrottleOutbound/throttleTimeDivisor)) && LandOutgoingPacketQueue.Count > 0) + if (LandBytesSent <= ((int)(LandthrottleOutbound/throttleTimeDivisor)) && LandOutgoingPacketQueue.Count > 0) { QueItem qpack = LandOutgoingPacketQueue.Dequeue(); PacketQueue.Enqueue(qpack); - throttleSentPeriod += qpack.Packet.ToBytes().Length; - LandthrottleSentPeriod += qpack.Packet.ToBytes().Length; + bytesSent += qpack.Packet.ToBytes().Length; + LandBytesSent += qpack.Packet.ToBytes().Length; } - if (WindthrottleSentPeriod <= ((int)(WindthrottleOutbound/throttleTimeDivisor)) && WindOutgoingPacketQueue.Count > 0) + if (WindBytesSent <= ((int)(WindthrottleOutbound/throttleTimeDivisor)) && WindOutgoingPacketQueue.Count > 0) { QueItem qpack = WindOutgoingPacketQueue.Dequeue(); PacketQueue.Enqueue(qpack); - throttleSentPeriod += qpack.Packet.ToBytes().Length; - WindthrottleSentPeriod += qpack.Packet.ToBytes().Length; + bytesSent += qpack.Packet.ToBytes().Length; + WindBytesSent += qpack.Packet.ToBytes().Length; } - if (CloudthrottleSentPeriod <= ((int)(CloudthrottleOutbound/throttleTimeDivisor)) && CloudOutgoingPacketQueue.Count > 0) + if (CloudBytesSent <= ((int)(CloudthrottleOutbound/throttleTimeDivisor)) && CloudOutgoingPacketQueue.Count > 0) { QueItem qpack = CloudOutgoingPacketQueue.Dequeue(); PacketQueue.Enqueue(qpack); - throttleSentPeriod += qpack.Packet.ToBytes().Length; - CloudthrottleSentPeriod += qpack.Packet.ToBytes().Length; + bytesSent += qpack.Packet.ToBytes().Length; + CloudBytesSent += qpack.Packet.ToBytes().Length; } - if (TaskthrottleSentPeriod <= ((int)(TaskthrottleOutbound/throttleTimeDivisor)) && TaskOutgoingPacketQueue.Count > 0) + if (TaskBytesSent <= ((int)(TaskthrottleOutbound/throttleTimeDivisor)) && TaskOutgoingPacketQueue.Count > 0) { QueItem qpack = TaskOutgoingPacketQueue.Dequeue(); PacketQueue.Enqueue(qpack); - throttleSentPeriod += qpack.Packet.ToBytes().Length; - TaskthrottleSentPeriod += qpack.Packet.ToBytes().Length; + bytesSent += qpack.Packet.ToBytes().Length; + TaskBytesSent += qpack.Packet.ToBytes().Length; } - if (TexturethrottleSentPeriod <= ((int)(TexturethrottleOutbound/throttleTimeDivisor)) && TextureOutgoingPacketQueue.Count > 0) + if (TextureBytesSent <= ((int)(TexturethrottleOutbound/throttleTimeDivisor)) && TextureOutgoingPacketQueue.Count > 0) { QueItem qpack = TextureOutgoingPacketQueue.Dequeue(); PacketQueue.Enqueue(qpack); - throttleSentPeriod += qpack.Packet.ToBytes().Length; - TexturethrottleSentPeriod += qpack.Packet.ToBytes().Length; + bytesSent += qpack.Packet.ToBytes().Length; + TextureBytesSent += qpack.Packet.ToBytes().Length; } - if (AssetthrottleSentPeriod <= ((int)(AssetthrottleOutbound/throttleTimeDivisor)) && AssetOutgoingPacketQueue.Count > 0) + if (AssetBytesSent <= ((int)(AssetthrottleOutbound/throttleTimeDivisor)) && AssetOutgoingPacketQueue.Count > 0) { QueItem qpack = AssetOutgoingPacketQueue.Dequeue(); PacketQueue.Enqueue(qpack); - throttleSentPeriod += qpack.Packet.ToBytes().Length; - AssetthrottleSentPeriod += qpack.Packet.ToBytes().Length; + bytesSent += qpack.Packet.ToBytes().Length; + AssetBytesSent += qpack.Packet.ToBytes().Length; } } @@ -441,7 +441,7 @@ namespace OpenSim.Region.ClientStack else { // Throw it back on the queue if it's going to cause us to flood the client - if (throttleSentPeriod > throttleOutboundMax) + if (bytesSent > throttleOutboundMax) { PacketQueue.Enqueue(nextPacket); MainLog.Instance.Verbose("Client over throttle limit, requeuing packet"); @@ -462,7 +462,7 @@ namespace OpenSim.Region.ClientStack //Don't throttle AvatarPickerReplies!, they return a null .ToBytes()! if (nextPacket.Packet.Type != PacketType.AvatarPickerReply) - throttleSentPeriod += nextPacket.Packet.ToBytes().Length; + bytesSent += nextPacket.Packet.ToBytes().Length; //is a out going packet