* Added some *VERY* experimental highly dodgy throttling of outbound packets to help alleviate clients borking during massive amounts of updates. Needs work.

afrisby
Adam Frisby 2007-11-09 02:22:01 +00:00
parent 3a5ae43d5e
commit 5099667844
1 changed files with 31 additions and 4 deletions

View File

@ -87,6 +87,13 @@ namespace OpenSim.Region.ClientStack
private int probesWithNoIngressPackets = 0;
private int lastPacketsReceived = 0;
private int throttleOutbound = 32768; // 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 Timer throttleTimer;
public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager,
IScene scene, AssetCache assetCache, PacketServer packServer,
AgentCircuitManager authenSessions)
@ -110,10 +117,14 @@ namespace OpenSim.Region.ClientStack
PacketQueue = new BlockingQueue<QueItem>();
//this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
AckTimer = new Timer(500);
AckTimer = new Timer(750);
AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
AckTimer.Start();
throttleTimer = new Timer(1000);
throttleTimer.Elapsed += new ElapsedEventHandler(throttleTimer_Elapsed);
throttleTimer.Start();
RegisterLocalPacketHandlers();
ClientThread = new Thread(new ThreadStart(AuthUser));
@ -121,6 +132,11 @@ namespace OpenSim.Region.ClientStack
ClientThread.Start();
}
void throttleTimer_Elapsed(object sender, ElapsedEventArgs e)
{
throttleSentPeriod = 0;
}
public LLUUID SessionId
{
get { return m_sessionId; }
@ -246,12 +262,23 @@ namespace OpenSim.Region.ClientStack
}
else
{
// Throw it back on the queue if it's going to cause us to flood the client
if (throttleSentPeriod > throttleOutbound)
{
PacketQueue.Enqueue(nextPacket);
Thread.Sleep(100); // Wait a little while, should prevent a CPU spike during high transmission periods
}
else
{
throttleSentPeriod += 768; // Average large packet size for now.
//is a out going packet
DebugPacket("OUT", nextPacket.Packet);
ProcessOutPacket(nextPacket.Packet);
}
}
}
}
# endregion