diff options
author | UbitUmarov | 2017-07-20 11:30:12 +0100 |
---|---|---|
committer | UbitUmarov | 2017-07-20 11:30:12 +0100 |
commit | fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540 (patch) | |
tree | 44ae3d8b00f3d2f6bf78bc0226a779f99ed6dc48 /OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |
parent | Merge branch 'master' into httptests (diff) | |
parent | fix object updates throttle for scripts doing motion by direct change of posi... (diff) | |
download | opensim-SC-fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540.zip opensim-SC-fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540.tar.gz opensim-SC-fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540.tar.bz2 opensim-SC-fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540.tar.xz |
merge
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 80 |
1 files changed, 25 insertions, 55 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 414b9bf..87ded7b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -220,7 +220,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
220 | PollServiceMeshEventArgs args; | 220 | PollServiceMeshEventArgs args; |
221 | if (m_pollservices.TryGetValue(user, out args)) | 221 | if (m_pollservices.TryGetValue(user, out args)) |
222 | { | 222 | { |
223 | args.UpdateThrottle(imagethrottle, p); | 223 | args.UpdateThrottle(imagethrottle); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
@@ -238,14 +238,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
238 | base(null, uri, null, null, null, null, pId, int.MaxValue) | 238 | base(null, uri, null, null, null, null, pId, int.MaxValue) |
239 | { | 239 | { |
240 | m_scene = scene; | 240 | m_scene = scene; |
241 | m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId); | 241 | m_throttler = new MeshCapsDataThrottler(100000); |
242 | // x is request id, y is userid | 242 | // x is request id, y is userid |
243 | HasEvents = (x, y) => | 243 | HasEvents = (x, y) => |
244 | { | 244 | { |
245 | lock (responses) | 245 | lock (responses) |
246 | { | 246 | { |
247 | bool ret = m_throttler.hasEvents(x, responses); | 247 | bool ret = m_throttler.hasEvents(x, responses); |
248 | m_throttler.ProcessTime(); | ||
249 | return ret; | 248 | return ret; |
250 | 249 | ||
251 | } | 250 | } |
@@ -271,8 +270,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
271 | } | 270 | } |
272 | finally | 271 | finally |
273 | { | 272 | { |
274 | m_throttler.ProcessTime(); | ||
275 | responses.Remove(x); | 273 | responses.Remove(x); |
274 | m_throttler.PassTime(); | ||
276 | } | 275 | } |
277 | } | 276 | } |
278 | }; | 277 | }; |
@@ -285,6 +284,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
285 | reqinfo.request = y; | 284 | reqinfo.request = y; |
286 | 285 | ||
287 | m_queue.Enqueue(reqinfo); | 286 | m_queue.Enqueue(reqinfo); |
287 | m_throttler.PassTime(); | ||
288 | }; | 288 | }; |
289 | 289 | ||
290 | // this should never happen except possible on shutdown | 290 | // this should never happen except possible on shutdown |
@@ -364,12 +364,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
364 | }; | 364 | }; |
365 | 365 | ||
366 | } | 366 | } |
367 | m_throttler.ProcessTime(); | 367 | m_throttler.PassTime(); |
368 | } | 368 | } |
369 | 369 | ||
370 | internal void UpdateThrottle(int pimagethrottle, ScenePresence p) | 370 | internal void UpdateThrottle(int pthrottle) |
371 | { | 371 | { |
372 | m_throttler.UpdateThrottle(pimagethrottle, p); | 372 | int tmp = 2 * pthrottle; |
373 | if(tmp < 10000) | ||
374 | tmp = 10000; | ||
375 | m_throttler.ThrottleBytes = tmp; | ||
373 | } | 376 | } |
374 | } | 377 | } |
375 | 378 | ||
@@ -423,24 +426,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
423 | 426 | ||
424 | internal sealed class MeshCapsDataThrottler | 427 | internal sealed class MeshCapsDataThrottler |
425 | { | 428 | { |
429 | private double lastTimeElapsed = 0; | ||
430 | private double BytesSent = 0; | ||
426 | 431 | ||
427 | private volatile int currenttime = 0; | 432 | public MeshCapsDataThrottler(int pBytes) |
428 | private volatile int lastTimeElapsed = 0; | ||
429 | private volatile int BytesSent = 0; | ||
430 | private int CapSetThrottle = 0; | ||
431 | private readonly Scene m_scene; | ||
432 | private ThrottleOutPacketType Throttle; | ||
433 | private readonly UUID User; | ||
434 | |||
435 | public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene, UUID puser) | ||
436 | { | 433 | { |
434 | if(pBytes < 10000) | ||
435 | pBytes = 10000; | ||
437 | ThrottleBytes = pBytes; | 436 | ThrottleBytes = pBytes; |
438 | if(ThrottleBytes < 10000) | 437 | lastTimeElapsed = Util.GetTimeStampMS(); |
439 | ThrottleBytes = 10000; | ||
440 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
441 | Throttle = ThrottleOutPacketType.Asset; | ||
442 | m_scene = pScene; | ||
443 | User = puser; | ||
444 | } | 438 | } |
445 | 439 | ||
446 | public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) | 440 | public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) |
@@ -470,46 +464,22 @@ namespace OpenSim.Region.ClientStack.Linden | |||
470 | return haskey; | 464 | return haskey; |
471 | } | 465 | } |
472 | 466 | ||
473 | public void ProcessTime() | 467 | public void PassTime() |
474 | { | 468 | { |
475 | PassTime(); | 469 | double currenttime = Util.GetTimeStampMS(); |
476 | } | 470 | double timeElapsed = currenttime - lastTimeElapsed; |
477 | 471 | if(timeElapsed < 50.0) | |
478 | private void PassTime() | 472 | return; |
473 | int add = (int)(ThrottleBytes * timeElapsed * 0.001); | ||
474 | if (add >= 1000) | ||
479 | { | 475 | { |
480 | currenttime = Util.EnvironmentTickCount(); | ||
481 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); | ||
482 | if (timeElapsed >= 100) | ||
483 | { | ||
484 | lastTimeElapsed = currenttime; | 476 | lastTimeElapsed = currenttime; |
485 | BytesSent -= (ThrottleBytes * timeElapsed / 1000); | 477 | BytesSent -= add; |
486 | if (BytesSent < 0) BytesSent = 0; | 478 | if (BytesSent < 0) BytesSent = 0; |
487 | } | 479 | } |
488 | } | 480 | } |
489 | 481 | ||
490 | private void AlterThrottle(int setting, ScenePresence p) | 482 | public int ThrottleBytes; |
491 | { | ||
492 | p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting); | ||
493 | } | 483 | } |
494 | |||
495 | public int ThrottleBytes | ||
496 | { | ||
497 | get { return CapSetThrottle; } | ||
498 | set | ||
499 | { | ||
500 | if (value > 10000) | ||
501 | CapSetThrottle = value; | ||
502 | else | ||
503 | CapSetThrottle = 10000; | ||
504 | } | 484 | } |
505 | } | ||
506 | |||
507 | internal void UpdateThrottle(int pimagethrottle, ScenePresence p) | ||
508 | { | ||
509 | // Client set throttle ! | ||
510 | CapSetThrottle = 2 * pimagethrottle; | ||
511 | ProcessTime(); | ||
512 | } | ||
513 | } | ||
514 | } | ||
515 | } | 485 | } |