aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs120
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs86
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs60
4 files changed, 96 insertions, 172 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
index a0471bb..72769c2 100644
--- a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
@@ -100,7 +100,6 @@ namespace OpenSim.Capabilities.Handlers
100 Hashtable responsedata = new Hashtable(); 100 Hashtable responsedata = new Hashtable();
101 responsedata["int_response_code"] = 400; //501; //410; //404; 101 responsedata["int_response_code"] = 400; //501; //410; //404;
102 responsedata["content_type"] = "text/plain"; 102 responsedata["content_type"] = "text/plain";
103 responsedata["str_response_string"] = "Request wasn't what was expected";
104 responsedata["int_bytes"] = 0; 103 responsedata["int_bytes"] = 0;
105 104
106 string meshStr = string.Empty; 105 string meshStr = string.Empty;
@@ -125,7 +124,6 @@ namespace OpenSim.Capabilities.Handlers
125 { 124 {
126 if (mesh.Type == (SByte)AssetType.Mesh) 125 if (mesh.Type == (SByte)AssetType.Mesh)
127 { 126 {
128
129 Hashtable headers = new Hashtable(); 127 Hashtable headers = new Hashtable();
130 responsedata["headers"] = headers; 128 responsedata["headers"] = headers;
131 129
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
index 542d52a..d4d7b33 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
@@ -87,7 +87,6 @@ namespace OpenSim.Region.ClientStack.Linden
87 87
88 private Dictionary<UUID, PollServiceMeshEventArgs> m_pollservices = new Dictionary<UUID, PollServiceMeshEventArgs>(); 88 private Dictionary<UUID, PollServiceMeshEventArgs> m_pollservices = new Dictionary<UUID, PollServiceMeshEventArgs>();
89 89
90
91 #region Region Module interfaceBase Members 90 #region Region Module interfaceBase Members
92 91
93 public Type ReplaceableInterface 92 public Type ReplaceableInterface
@@ -134,7 +133,6 @@ namespace OpenSim.Region.ClientStack.Linden
134 133
135 s.EventManager.OnRegisterCaps -= RegisterCaps; 134 s.EventManager.OnRegisterCaps -= RegisterCaps;
136 s.EventManager.OnDeregisterCaps -= DeregisterCaps; 135 s.EventManager.OnDeregisterCaps -= DeregisterCaps;
137 s.EventManager.OnThrottleUpdate -= ThrottleUpdate;
138 m_NumberScenes--; 136 m_NumberScenes--;
139 m_scene = null; 137 m_scene = null;
140 } 138 }
@@ -153,7 +151,6 @@ namespace OpenSim.Region.ClientStack.Linden
153 151
154 s.EventManager.OnRegisterCaps += RegisterCaps; 152 s.EventManager.OnRegisterCaps += RegisterCaps;
155 s.EventManager.OnDeregisterCaps += DeregisterCaps; 153 s.EventManager.OnDeregisterCaps += DeregisterCaps;
156 s.EventManager.OnThrottleUpdate += ThrottleUpdate;
157 154
158 m_NumberScenes++; 155 m_NumberScenes++;
159 156
@@ -212,18 +209,6 @@ namespace OpenSim.Region.ClientStack.Linden
212 } 209 }
213 } 210 }
214 211
215 // Now we know when the throttle is changed by the client in the case of a root agent or by a neighbor region in the case of a child agent.
216 public void ThrottleUpdate(ScenePresence p)
217 {
218 UUID user = p.UUID;
219 int imagethrottle = p.ControllingClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Asset);
220 PollServiceMeshEventArgs args;
221 if (m_pollservices.TryGetValue(user, out args))
222 {
223 args.UpdateThrottle(imagethrottle);
224 }
225 }
226
227 private class PollServiceMeshEventArgs : PollServiceEventArgs 212 private class PollServiceMeshEventArgs : PollServiceEventArgs
228 { 213 {
229 private List<Hashtable> requests = 214 private List<Hashtable> requests =
@@ -233,18 +218,28 @@ namespace OpenSim.Region.ClientStack.Linden
233 private HashSet<UUID> dropedResponses = new HashSet<UUID>(); 218 private HashSet<UUID> dropedResponses = new HashSet<UUID>();
234 219
235 private Scene m_scene; 220 private Scene m_scene;
236 private MeshCapsDataThrottler m_throttler; 221 private ScenePresence m_presence;
237 public PollServiceMeshEventArgs(string uri, UUID pId, Scene scene) : 222 public PollServiceMeshEventArgs(string uri, UUID pId, Scene scene) :
238 base(null, uri, null, null, null, null, pId, int.MaxValue) 223 base(null, uri, null, null, null, null, pId, int.MaxValue)
239 { 224 {
240 m_scene = scene; 225 m_scene = scene;
241 m_throttler = new MeshCapsDataThrottler(100000); 226
242 // x is request id, y is userid 227 // x is request id, y is userid
243 HasEvents = (x, y) => 228 HasEvents = (x, y) =>
244 { 229 {
245 lock (responses) 230 lock (responses)
246 { 231 {
247 return m_throttler.hasEvents(x, responses); 232 APollResponse response;
233 if (responses.TryGetValue(x, out response))
234 {
235 if (m_presence == null)
236 m_presence = m_scene.GetScenePresence(pId);
237
238 if (m_presence == null || m_presence.IsDeleted)
239 return true;
240 return m_presence.CapCanSendAsset(1, response.bytes);
241 }
242 return false;
248 } 243 }
249 }; 244 };
250 245
@@ -269,7 +264,6 @@ namespace OpenSim.Region.ClientStack.Linden
269 finally 264 finally
270 { 265 {
271 responses.Remove(x); 266 responses.Remove(x);
272 m_throttler.PassTime();
273 } 267 }
274 } 268 }
275 }; 269 };
@@ -282,7 +276,6 @@ namespace OpenSim.Region.ClientStack.Linden
282 reqinfo.request = y; 276 reqinfo.request = y;
283 277
284 m_queue.Add(reqinfo); 278 m_queue.Add(reqinfo);
285 m_throttler.PassTime();
286 }; 279 };
287 280
288 // this should never happen except possible on shutdown 281 // this should never happen except possible on shutdown
@@ -307,14 +300,14 @@ namespace OpenSim.Region.ClientStack.Linden
307 300
308 public void Process(APollRequest requestinfo) 301 public void Process(APollRequest requestinfo)
309 { 302 {
310 Hashtable response; 303 Hashtable curresponse;
311 304
312 UUID requestID = requestinfo.reqID; 305 UUID requestID = requestinfo.reqID;
313 306
314 if(m_scene.ShuttingDown) 307 if(m_scene.ShuttingDown)
315 return; 308 return;
316 309
317 lock(responses) 310 lock(responses)
318 { 311 {
319 lock(dropedResponses) 312 lock(dropedResponses)
320 { 313 {
@@ -324,25 +317,23 @@ namespace OpenSim.Region.ClientStack.Linden
324 return; 317 return;
325 } 318 }
326 } 319 }
327 320
328 // If the avatar is gone, don't bother to get the texture 321 // If the avatar is gone, don't bother to get the texture
329 if (m_scene.GetScenePresence(Id) == null) 322 if(m_scene.GetScenePresence(Id) == null)
330 { 323 {
331 response = new Hashtable(); 324 curresponse = new Hashtable();
332 325 curresponse["int_response_code"] = 500;
333 response["int_response_code"] = 500; 326 curresponse["str_response_string"] = "Script timeout";
334 response["str_response_string"] = "Script timeout"; 327 curresponse["content_type"] = "text/plain";
335 response["content_type"] = "text/plain"; 328 curresponse["keepalive"] = false;
336 response["keepalive"] = false; 329 responses[requestID] = new APollResponse() { bytes = 0, response = curresponse };
337 responses[requestID] = new APollResponse() { bytes = 0, response = response};
338
339 return; 330 return;
340 } 331 }
341 } 332 }
342 333
343 response = m_getMeshHandler.Handle(requestinfo.request); 334 curresponse = m_getMeshHandler.Handle(requestinfo.request);
344 335
345 lock (responses) 336 lock(responses)
346 { 337 {
347 lock(dropedResponses) 338 lock(dropedResponses)
348 { 339 {
@@ -355,20 +346,10 @@ namespace OpenSim.Region.ClientStack.Linden
355 346
356 responses[requestID] = new APollResponse() 347 responses[requestID] = new APollResponse()
357 { 348 {
358 bytes = (int)response["int_bytes"], 349 bytes = (int)curresponse["int_bytes"],
359 response = response 350 response = curresponse
360 }; 351 };
361
362 } 352 }
363 m_throttler.PassTime();
364 }
365
366 internal void UpdateThrottle(int pthrottle)
367 {
368 int tmp = 2 * pthrottle;
369 if(tmp < 10000)
370 tmp = 10000;
371 m_throttler.ThrottleBytes = tmp;
372 } 353 }
373 } 354 }
374 355
@@ -419,52 +400,5 @@ namespace OpenSim.Region.ClientStack.Linden
419 m_pollservices.Remove(agentID); 400 m_pollservices.Remove(agentID);
420 } 401 }
421 } 402 }
422
423 internal sealed class MeshCapsDataThrottler
424 {
425 private double lastTimeElapsed = 0;
426 private double BytesSent = 0;
427
428 public MeshCapsDataThrottler(int pBytes)
429 {
430 if(pBytes < 10000)
431 pBytes = 10000;
432 ThrottleBytes = pBytes;
433 lastTimeElapsed = Util.GetTimeStamp();
434 }
435
436 public bool hasEvents(UUID key, Dictionary<UUID, APollResponse> responses)
437 {
438 PassTime();
439 APollResponse response;
440 if (responses.TryGetValue(key, out response))
441 {
442 // Normal
443 if (response.bytes == 0 || BytesSent <= ThrottleBytes)
444 {
445 BytesSent += response.bytes;
446 return true;
447 }
448 }
449 return false;
450 }
451
452 public void PassTime()
453 {
454 double currenttime = Util.GetTimeStamp();
455 double timeElapsed = currenttime - lastTimeElapsed;
456 if(timeElapsed < .05)
457 return;
458 int add = (int)(ThrottleBytes * timeElapsed);
459 if (add >= 1000)
460 {
461 lastTimeElapsed = currenttime;
462 BytesSent -= add;
463 if (BytesSent < 0) BytesSent = 0;
464 }
465 }
466
467 public int ThrottleBytes;
468 }
469 } 403 }
470} 404}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
index 7d1a380..0588648 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
@@ -113,7 +113,6 @@ namespace OpenSim.Region.ClientStack.Linden
113 { 113 {
114 s.EventManager.OnRegisterCaps -= RegisterCaps; 114 s.EventManager.OnRegisterCaps -= RegisterCaps;
115 s.EventManager.OnDeregisterCaps -= DeregisterCaps; 115 s.EventManager.OnDeregisterCaps -= DeregisterCaps;
116 s.EventManager.OnThrottleUpdate -= ThrottleUpdate;
117 m_NumberScenes--; 116 m_NumberScenes--;
118 m_scene = null; 117 m_scene = null;
119 } 118 }
@@ -129,7 +128,6 @@ namespace OpenSim.Region.ClientStack.Linden
129 128
130 s.EventManager.OnRegisterCaps += RegisterCaps; 129 s.EventManager.OnRegisterCaps += RegisterCaps;
131 s.EventManager.OnDeregisterCaps += DeregisterCaps; 130 s.EventManager.OnDeregisterCaps += DeregisterCaps;
132 s.EventManager.OnThrottleUpdate += ThrottleUpdate;
133 131
134 m_NumberScenes++; 132 m_NumberScenes++;
135 133
@@ -149,19 +147,6 @@ namespace OpenSim.Region.ClientStack.Linden
149 } 147 }
150 } 148 }
151 } 149 }
152
153 // Now we know when the throttle is changed by the client in the case of a root agent or by a neighbor region in the case of a child agent.
154 public void ThrottleUpdate(ScenePresence p)
155 {
156 byte[] throttles = p.ControllingClient.GetThrottlesPacked(1);
157 UUID user = p.UUID;
158 int imagethrottle = p.ControllingClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Texture);
159 PollServiceTextureEventArgs args;
160 if (m_pollservices.TryGetValue(user,out args))
161 {
162 args.UpdateThrottle(imagethrottle);
163 }
164 }
165 150
166 public void PostInitialise() 151 public void PostInitialise()
167 { 152 {
@@ -198,20 +183,27 @@ namespace OpenSim.Region.ClientStack.Linden
198 private HashSet<UUID> dropedResponses = new HashSet<UUID>(); 183 private HashSet<UUID> dropedResponses = new HashSet<UUID>();
199 184
200 private Scene m_scene; 185 private Scene m_scene;
201 private CapsDataThrottler m_throttler; 186 private ScenePresence m_presence;
202 public PollServiceTextureEventArgs(UUID pId, Scene scene) : 187 public PollServiceTextureEventArgs(UUID pId, Scene scene) :
203 base(null, "", null, null, null, null, pId, int.MaxValue) 188 base(null, "", null, null, null, null, pId, int.MaxValue)
204 { 189 {
205 m_scene = scene; 190 m_scene = scene;
206 m_throttler = new CapsDataThrottler(100000);
207 // x is request id, y is userid 191 // x is request id, y is userid
208 HasEvents = (x, y) => 192 HasEvents = (x, y) =>
209 { 193 {
210 lock (responses) 194 lock (responses)
211 { 195 {
212 bool ret = m_throttler.hasEvents(x, responses); 196 APollResponse response;
213 return ret; 197 if (responses.TryGetValue(x, out response))
198 {
199 if (m_presence == null)
200 m_presence = m_scene.GetScenePresence(pId);
214 201
202 if (m_presence == null || m_presence.IsDeleted)
203 return true;
204 return m_presence.CapCanSendAsset(0, response.bytes);
205 }
206 return false;
215 } 207 }
216 }; 208 };
217 209
@@ -235,7 +227,6 @@ namespace OpenSim.Region.ClientStack.Linden
235 finally 227 finally
236 { 228 {
237 responses.Remove(x); 229 responses.Remove(x);
238 m_throttler.PassTime();
239 } 230 }
240 } 231 }
241 }; 232 };
@@ -260,7 +251,6 @@ namespace OpenSim.Region.ClientStack.Linden
260 } 251 }
261 } 252 }
262 m_queue.Add(reqinfo); 253 m_queue.Add(reqinfo);
263 m_throttler.PassTime();
264 }; 254 };
265 255
266 // this should never happen except possible on shutdown 256 // this should never happen except possible on shutdown
@@ -346,7 +336,6 @@ namespace OpenSim.Region.ClientStack.Linden
346 if(dropedResponses.Contains(requestID)) 336 if(dropedResponses.Contains(requestID))
347 { 337 {
348 dropedResponses.Remove(requestID); 338 dropedResponses.Remove(requestID);
349 m_throttler.PassTime();
350 return; 339 return;
351 } 340 }
352 } 341 }
@@ -356,15 +345,6 @@ namespace OpenSim.Region.ClientStack.Linden
356 response = response 345 response = response
357 }; 346 };
358 } 347 }
359 m_throttler.PassTime();
360 }
361
362 internal void UpdateThrottle(int pimagethrottle)
363 {
364 int tmp = 2 * pimagethrottle;
365 if(tmp < 10000)
366 tmp = 10000;
367 m_throttler.ThrottleBytes = tmp;
368 } 348 }
369 } 349 }
370 350
@@ -437,49 +417,5 @@ namespace OpenSim.Region.ClientStack.Linden
437 poolreq.thepoll.Process(poolreq); 417 poolreq.thepoll.Process(poolreq);
438 } 418 }
439 } 419 }
440
441 internal sealed class CapsDataThrottler
442 {
443 private double lastTimeElapsed = 0;
444 private volatile int BytesSent = 0;
445 public CapsDataThrottler(int pBytes)
446 {
447 if(pBytes < 10000)
448 pBytes = 10000;
449 ThrottleBytes = pBytes;
450 lastTimeElapsed = Util.GetTimeStamp();
451 }
452 public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.APollResponse> responses)
453 {
454 PassTime();
455 // Note, this is called IN LOCK
456 GetTextureModule.APollResponse response;
457 if (responses.TryGetValue(key, out response))
458 {
459 if (response.bytes == 0 || BytesSent <= ThrottleBytes)
460 {
461 BytesSent += response.bytes;
462 return true;
463 }
464 }
465 return false;
466 }
467
468 public void PassTime()
469 {
470 double currenttime = Util.GetTimeStamp();
471 double timeElapsed = currenttime - lastTimeElapsed;
472 if(timeElapsed < .05)
473 return;
474 int add = (int)(ThrottleBytes * timeElapsed);
475 if (add >= 1000)
476 {
477 lastTimeElapsed = currenttime;
478 BytesSent -= add;
479 if (BytesSent < 0) BytesSent = 0;
480 }
481 }
482 public int ThrottleBytes;
483 }
484 } 420 }
485} 421}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ed4cafa..bcae69f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1118,6 +1118,20 @@ namespace OpenSim.Region.Framework.Scenes
1118 m_LandingPointBehavior = LandingPointBehavior.SL; 1118 m_LandingPointBehavior = LandingPointBehavior.SL;
1119 } 1119 }
1120 1120
1121 m_bandwidth = 100000;
1122 m_lastBandwithTime = Util.GetTimeStamp() + 0.1;
1123 IConfig cconfig = m_scene.Config.Configs["ClientStack.LindenCaps"];
1124 if (cconfig != null)
1125 {
1126 m_capbandwidth = cconfig.GetInt("Cap_AssetThrottle", m_capbandwidth);
1127 if(m_capbandwidth > 0)
1128 {
1129 m_bandwidth = m_capbandwidth;
1130 if(m_bandwidth < 50000)
1131 m_bandwidth = 50000;
1132 }
1133 }
1134 m_bandwidthBurst = m_bandwidth / 5;
1121 ControllingClient.RefreshGroupMembership(); 1135 ControllingClient.RefreshGroupMembership();
1122 1136
1123 } 1137 }
@@ -4626,7 +4640,12 @@ namespace OpenSim.Region.Framework.Scenes
4626 4640
4627 private void RaiseUpdateThrottles() 4641 private void RaiseUpdateThrottles()
4628 { 4642 {
4629 m_scene.EventManager.TriggerThrottleUpdate(this); 4643 if(m_capbandwidth > 0)
4644 return;
4645 m_bandwidth = 4 * ControllingClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Texture);
4646 if(m_bandwidth < 50000)
4647 m_bandwidth = 50000;
4648 m_bandwidthBurst = m_bandwidth / 5;
4630 } 4649 }
4631 4650
4632 /// <summary> 4651 /// <summary>
@@ -5834,7 +5853,7 @@ namespace OpenSim.Region.Framework.Scenes
5834 { 5853 {
5835 if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) 5854 if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols))
5836 { 5855 {
5837 ScriptControlled sctc = takecontrols.eventControls; 5856 ScriptControlled sctc = takecontrols.eventControls;
5838 5857
5839 ControllingClient.SendTakeControls((int)sctc, false, false); 5858 ControllingClient.SendTakeControls((int)sctc, false, false);
5840 ControllingClient.SendTakeControls((int)sctc, true, false); 5859 ControllingClient.SendTakeControls((int)sctc, true, false);
@@ -6830,5 +6849,42 @@ namespace OpenSim.Region.Framework.Scenes
6830 { 6849 {
6831 return Overrides.GetOverriddenAnimation(animState); 6850 return Overrides.GetOverriddenAnimation(animState);
6832 } 6851 }
6852
6853 // http caps assets bandwidth control
6854 private int m_capbandwidth = -1;
6855 private int m_bandwidth = 100000;
6856 private int m_bandwidthBurst = 20000;
6857 private int m_bytesControl;
6858 private double m_lastBandwithTime;
6859
6860 public bool CapCanSendAsset(int type, int size)
6861 {
6862 if(size == 0)
6863 return true;
6864
6865 if(type > 1)
6866 {
6867 // not texture or mesh
6868 m_bytesControl -= size;
6869 return true;
6870 }
6871
6872 double currenttime = Util.GetTimeStamp();
6873 double timeElapsed = currenttime - m_lastBandwithTime;
6874 if (timeElapsed > .05)
6875 {
6876 m_lastBandwithTime = currenttime;
6877 int add = (int)(m_bandwidth * timeElapsed);
6878 m_bytesControl += add;
6879 if (m_bytesControl > m_bandwidthBurst)
6880 m_bytesControl = m_bandwidthBurst;
6881 }
6882 if (m_bytesControl > 0 )
6883 {
6884 m_bytesControl -= size;
6885 return true;
6886 }
6887 return false;
6888 }
6833 } 6889 }
6834} 6890}