diff options
* Prep work switching the GetMeshModule over to a poll service.
* This still has the image throttler in it.. as is... so it's not suitable for live yet.... The throttler keeps track of the task throttle but doesn't balance the UDP throttle yet.
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 8cba6c8..c8c709a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -364,80 +364,81 @@ namespace OpenSim.Region.ClientStack.Linden | |||
364 | poolreq.thepoll.Process(poolreq); | 364 | poolreq.thepoll.Process(poolreq); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | } | 367 | internal sealed class CapsDataThrottler |
368 | |||
369 | internal sealed class CapsDataThrottler | ||
370 | { | ||
371 | |||
372 | private volatile int currenttime = 0; | ||
373 | private volatile int lastTimeElapsed = 0; | ||
374 | private volatile int BytesSent = 0; | ||
375 | private int oversizedImages = 0; | ||
376 | public CapsDataThrottler(int pBytes, int max, int min) | ||
377 | { | ||
378 | ThrottleBytes = pBytes; | ||
379 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
380 | } | ||
381 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) | ||
382 | { | 368 | { |
383 | PassTime(); | 369 | |
384 | // Note, this is called IN LOCK | 370 | private volatile int currenttime = 0; |
385 | bool haskey = responses.ContainsKey(key); | 371 | private volatile int lastTimeElapsed = 0; |
386 | if (!haskey) | 372 | private volatile int BytesSent = 0; |
373 | private int oversizedImages = 0; | ||
374 | public CapsDataThrottler(int pBytes, int max, int min) | ||
387 | { | 375 | { |
388 | return false; | 376 | ThrottleBytes = pBytes; |
377 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
389 | } | 378 | } |
390 | GetTextureModule.aPollResponse response; | 379 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) |
391 | if (responses.TryGetValue(key,out response)) | ||
392 | { | 380 | { |
393 | 381 | PassTime(); | |
394 | // Normal | 382 | // Note, this is called IN LOCK |
395 | if (BytesSent + response.bytes <= ThrottleBytes) | 383 | bool haskey = responses.ContainsKey(key); |
384 | if (!haskey) | ||
396 | { | 385 | { |
397 | BytesSent += response.bytes; | 386 | return false; |
398 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; | ||
399 | //m_actions.Add(timeBasedAction); | ||
400 | return true; | ||
401 | } | ||
402 | // Big textures | ||
403 | else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes%50000) + 1)) | ||
404 | { | ||
405 | Interlocked.Increment(ref oversizedImages); | ||
406 | BytesSent += response.bytes; | ||
407 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; | ||
408 | //m_actions.Add(timeBasedAction); | ||
409 | return true; | ||
410 | } | 387 | } |
411 | else | 388 | GetTextureModule.aPollResponse response; |
389 | if (responses.TryGetValue(key, out response)) | ||
412 | { | 390 | { |
413 | return false; | 391 | |
392 | // Normal | ||
393 | if (BytesSent + response.bytes <= ThrottleBytes) | ||
394 | { | ||
395 | BytesSent += response.bytes; | ||
396 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; | ||
397 | //m_actions.Add(timeBasedAction); | ||
398 | return true; | ||
399 | } | ||
400 | // Big textures | ||
401 | else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes % 50000) + 1)) | ||
402 | { | ||
403 | Interlocked.Increment(ref oversizedImages); | ||
404 | BytesSent += response.bytes; | ||
405 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; | ||
406 | //m_actions.Add(timeBasedAction); | ||
407 | return true; | ||
408 | } | ||
409 | else | ||
410 | { | ||
411 | return false; | ||
412 | } | ||
414 | } | 413 | } |
414 | |||
415 | return haskey; | ||
416 | } | ||
417 | public void ProcessTime() | ||
418 | { | ||
419 | PassTime(); | ||
415 | } | 420 | } |
416 | 421 | ||
417 | return haskey; | 422 | |
418 | } | 423 | private void PassTime() |
419 | public void ProcessTime() | ||
420 | { | ||
421 | PassTime(); | ||
422 | } | ||
423 | |||
424 | |||
425 | private void PassTime() | ||
426 | { | ||
427 | currenttime = Util.EnvironmentTickCount(); | ||
428 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); | ||
429 | //processTimeBasedActions(responses); | ||
430 | if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) | ||
431 | { | 424 | { |
432 | lastTimeElapsed = Util.EnvironmentTickCount(); | 425 | currenttime = Util.EnvironmentTickCount(); |
433 | BytesSent -= ThrottleBytes; | 426 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); |
434 | if (BytesSent < 0) BytesSent = 0; | 427 | //processTimeBasedActions(responses); |
435 | if (BytesSent < ThrottleBytes) | 428 | if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) |
436 | { | 429 | { |
437 | oversizedImages = 0; | 430 | lastTimeElapsed = Util.EnvironmentTickCount(); |
431 | BytesSent -= ThrottleBytes; | ||
432 | if (BytesSent < 0) BytesSent = 0; | ||
433 | if (BytesSent < ThrottleBytes) | ||
434 | { | ||
435 | oversizedImages = 0; | ||
436 | } | ||
438 | } | 437 | } |
439 | } | 438 | } |
439 | public int ThrottleBytes; | ||
440 | } | 440 | } |
441 | public int ThrottleBytes; | ||
442 | } | 441 | } |
442 | |||
443 | |||
443 | } | 444 | } |