aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorAdam Frisby2007-11-09 02:22:01 +0000
committerAdam Frisby2007-11-09 02:22:01 +0000
commit509966784446a867681e077d37b6d0e43fa75846 (patch)
tree7fc30863166faaa663e1f5b955692b50c5a4c7a3 /OpenSim/Region
parent* Fixed compile issue. (diff)
downloadopensim-SC-509966784446a867681e077d37b6d0e43fa75846.zip
opensim-SC-509966784446a867681e077d37b6d0e43fa75846.tar.gz
opensim-SC-509966784446a867681e077d37b6d0e43fa75846.tar.bz2
opensim-SC-509966784446a867681e077d37b6d0e43fa75846.tar.xz
* Added some *VERY* experimental highly dodgy throttling of outbound packets to help alleviate clients borking during massive amounts of updates. Needs work.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs35
1 files changed, 31 insertions, 4 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 0e35488..dfbf74c 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -87,6 +87,13 @@ namespace OpenSim.Region.ClientStack
87 private int probesWithNoIngressPackets = 0; 87 private int probesWithNoIngressPackets = 0;
88 private int lastPacketsReceived = 0; 88 private int lastPacketsReceived = 0;
89 89
90
91 private int throttleOutbound = 32768; // Number of bytes allowed to go out per second. (256kbps per client)
92 // TODO: Make this variable. Lower throttle on un-ack. Raise over time?
93 private int throttleSentPeriod = 0; // Number of bytes sent this period
94
95 private Timer throttleTimer;
96
90 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, 97 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager,
91 IScene scene, AssetCache assetCache, PacketServer packServer, 98 IScene scene, AssetCache assetCache, PacketServer packServer,
92 AgentCircuitManager authenSessions) 99 AgentCircuitManager authenSessions)
@@ -110,10 +117,14 @@ namespace OpenSim.Region.ClientStack
110 PacketQueue = new BlockingQueue<QueItem>(); 117 PacketQueue = new BlockingQueue<QueItem>();
111 118
112 //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); 119 //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
113 AckTimer = new Timer(500); 120 AckTimer = new Timer(750);
114 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); 121 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
115 AckTimer.Start(); 122 AckTimer.Start();
116 123
124 throttleTimer = new Timer(1000);
125 throttleTimer.Elapsed += new ElapsedEventHandler(throttleTimer_Elapsed);
126 throttleTimer.Start();
127
117 RegisterLocalPacketHandlers(); 128 RegisterLocalPacketHandlers();
118 129
119 ClientThread = new Thread(new ThreadStart(AuthUser)); 130 ClientThread = new Thread(new ThreadStart(AuthUser));
@@ -121,6 +132,11 @@ namespace OpenSim.Region.ClientStack
121 ClientThread.Start(); 132 ClientThread.Start();
122 } 133 }
123 134
135 void throttleTimer_Elapsed(object sender, ElapsedEventArgs e)
136 {
137 throttleSentPeriod = 0;
138 }
139
124 public LLUUID SessionId 140 public LLUUID SessionId
125 { 141 {
126 get { return m_sessionId; } 142 get { return m_sessionId; }
@@ -246,9 +262,20 @@ namespace OpenSim.Region.ClientStack
246 } 262 }
247 else 263 else
248 { 264 {
249 //is a out going packet 265 // Throw it back on the queue if it's going to cause us to flood the client
250 DebugPacket("OUT", nextPacket.Packet); 266 if (throttleSentPeriod > throttleOutbound)
251 ProcessOutPacket(nextPacket.Packet); 267 {
268 PacketQueue.Enqueue(nextPacket);
269 Thread.Sleep(100); // Wait a little while, should prevent a CPU spike during high transmission periods
270 }
271 else
272 {
273 throttleSentPeriod += 768; // Average large packet size for now.
274
275 //is a out going packet
276 DebugPacket("OUT", nextPacket.Packet);
277 ProcessOutPacket(nextPacket.Packet);
278 }
252 } 279 }
253 } 280 }
254 } 281 }