diff options
author | Melanie | 2012-11-20 01:20:59 +0000 |
---|---|---|
committer | Melanie | 2012-11-20 01:20:59 +0000 |
commit | ccc81183b042a62752b7be4b16e0ccc7dbd03b3f (patch) | |
tree | e556eb6a576393799aa5eaa38afb35e0d64785ed /OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |
parent | Merge branch 'master' into careminster (diff) | |
parent | * Fixes mesh loading issues in last commit. (diff) | |
download | opensim-SC-ccc81183b042a62752b7be4b16e0ccc7dbd03b3f.zip opensim-SC-ccc81183b042a62752b7be4b16e0ccc7dbd03b3f.tar.gz opensim-SC-ccc81183b042a62752b7be4b16e0ccc7dbd03b3f.tar.bz2 opensim-SC-ccc81183b042a62752b7be4b16e0ccc7dbd03b3f.tar.xz |
Merge commit '619c39e5144f15aca129d6d999bcc5c34133ee64' into careminster
Conflicts:
OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 121 |
1 files changed, 61 insertions, 60 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index d1ec4aa..dd87671 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -361,80 +361,81 @@ namespace OpenSim.Region.ClientStack.Linden | |||
361 | poolreq.thepoll.Process(poolreq); | 361 | poolreq.thepoll.Process(poolreq); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | } | 364 | internal sealed class CapsDataThrottler |
365 | |||
366 | internal sealed class CapsDataThrottler | ||
367 | { | ||
368 | |||
369 | private volatile int currenttime = 0; | ||
370 | private volatile int lastTimeElapsed = 0; | ||
371 | private volatile int BytesSent = 0; | ||
372 | private int oversizedImages = 0; | ||
373 | public CapsDataThrottler(int pBytes, int max, int min) | ||
374 | { | ||
375 | ThrottleBytes = pBytes; | ||
376 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
377 | } | ||
378 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) | ||
379 | { | 365 | { |
380 | PassTime(); | 366 | |
381 | // Note, this is called IN LOCK | 367 | private volatile int currenttime = 0; |
382 | bool haskey = responses.ContainsKey(key); | 368 | private volatile int lastTimeElapsed = 0; |
383 | if (!haskey) | 369 | private volatile int BytesSent = 0; |
370 | private int oversizedImages = 0; | ||
371 | public CapsDataThrottler(int pBytes, int max, int min) | ||
384 | { | 372 | { |
385 | return false; | 373 | ThrottleBytes = pBytes; |
374 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
386 | } | 375 | } |
387 | GetTextureModule.aPollResponse response; | 376 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) |
388 | if (responses.TryGetValue(key,out response)) | ||
389 | { | 377 | { |
390 | 378 | PassTime(); | |
391 | // Normal | 379 | // Note, this is called IN LOCK |
392 | if (BytesSent + response.bytes <= ThrottleBytes) | 380 | bool haskey = responses.ContainsKey(key); |
381 | if (!haskey) | ||
393 | { | 382 | { |
394 | BytesSent += response.bytes; | 383 | return false; |
395 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; | ||
396 | //m_actions.Add(timeBasedAction); | ||
397 | return true; | ||
398 | } | ||
399 | // Big textures | ||
400 | else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes%50000) + 1)) | ||
401 | { | ||
402 | Interlocked.Increment(ref oversizedImages); | ||
403 | BytesSent += response.bytes; | ||
404 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; | ||
405 | //m_actions.Add(timeBasedAction); | ||
406 | return true; | ||
407 | } | 384 | } |
408 | else | 385 | GetTextureModule.aPollResponse response; |
386 | if (responses.TryGetValue(key, out response)) | ||
409 | { | 387 | { |
410 | return false; | 388 | |
389 | // Normal | ||
390 | if (BytesSent + response.bytes <= ThrottleBytes) | ||
391 | { | ||
392 | BytesSent += response.bytes; | ||
393 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; | ||
394 | //m_actions.Add(timeBasedAction); | ||
395 | return true; | ||
396 | } | ||
397 | // Big textures | ||
398 | else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes % 50000) + 1)) | ||
399 | { | ||
400 | Interlocked.Increment(ref oversizedImages); | ||
401 | BytesSent += response.bytes; | ||
402 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; | ||
403 | //m_actions.Add(timeBasedAction); | ||
404 | return true; | ||
405 | } | ||
406 | else | ||
407 | { | ||
408 | return false; | ||
409 | } | ||
411 | } | 410 | } |
411 | |||
412 | return haskey; | ||
413 | } | ||
414 | public void ProcessTime() | ||
415 | { | ||
416 | PassTime(); | ||
412 | } | 417 | } |
413 | 418 | ||
414 | return haskey; | 419 | |
415 | } | 420 | private void PassTime() |
416 | public void ProcessTime() | ||
417 | { | ||
418 | PassTime(); | ||
419 | } | ||
420 | |||
421 | |||
422 | private void PassTime() | ||
423 | { | ||
424 | currenttime = Util.EnvironmentTickCount(); | ||
425 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); | ||
426 | //processTimeBasedActions(responses); | ||
427 | if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) | ||
428 | { | 421 | { |
429 | lastTimeElapsed = Util.EnvironmentTickCount(); | 422 | currenttime = Util.EnvironmentTickCount(); |
430 | BytesSent -= ThrottleBytes; | 423 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); |
431 | if (BytesSent < 0) BytesSent = 0; | 424 | //processTimeBasedActions(responses); |
432 | if (BytesSent < ThrottleBytes) | 425 | if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) |
433 | { | 426 | { |
434 | oversizedImages = 0; | 427 | lastTimeElapsed = Util.EnvironmentTickCount(); |
428 | BytesSent -= ThrottleBytes; | ||
429 | if (BytesSent < 0) BytesSent = 0; | ||
430 | if (BytesSent < ThrottleBytes) | ||
431 | { | ||
432 | oversizedImages = 0; | ||
433 | } | ||
435 | } | 434 | } |
436 | } | 435 | } |
436 | public int ThrottleBytes; | ||
437 | } | 437 | } |
438 | public int ThrottleBytes; | ||
439 | } | 438 | } |
439 | |||
440 | |||
440 | } | 441 | } |