diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index ce9798b..b01c7dc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -220,7 +220,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
220 | new Dictionary<UUID, aPollResponse>(); | 220 | new Dictionary<UUID, aPollResponse>(); |
221 | 221 | ||
222 | private Scene m_scene; | 222 | private Scene m_scene; |
223 | private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000); | 223 | private CapsDataThrottler m_throttler = new CapsDataThrottler(100000); |
224 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : | 224 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : |
225 | base(null, "", null, null, null, pId, int.MaxValue) | 225 | base(null, "", null, null, null, pId, int.MaxValue) |
226 | { | 226 | { |
@@ -231,7 +231,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
231 | lock (responses) | 231 | lock (responses) |
232 | { | 232 | { |
233 | bool ret = m_throttler.hasEvents(x, responses); | 233 | bool ret = m_throttler.hasEvents(x, responses); |
234 | m_throttler.ProcessTime(); | ||
235 | return ret; | 234 | return ret; |
236 | 235 | ||
237 | } | 236 | } |
@@ -247,6 +246,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
247 | finally | 246 | finally |
248 | { | 247 | { |
249 | responses.Remove(x); | 248 | responses.Remove(x); |
249 | m_throttler.PassTime(); | ||
250 | } | 250 | } |
251 | } | 251 | } |
252 | }; | 252 | }; |
@@ -271,6 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
271 | } | 271 | } |
272 | } | 272 | } |
273 | m_queue.Enqueue(reqinfo); | 273 | m_queue.Enqueue(reqinfo); |
274 | m_throttler.PassTime(); | ||
274 | }; | 275 | }; |
275 | 276 | ||
276 | // this should never happen except possible on shutdown | 277 | // this should never happen except possible on shutdown |
@@ -351,14 +352,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
351 | }; | 352 | }; |
352 | 353 | ||
353 | } | 354 | } |
354 | m_throttler.ProcessTime(); | 355 | m_throttler.PassTime(); |
355 | } | 356 | } |
356 | 357 | ||
357 | internal void UpdateThrottle(int pimagethrottle) | 358 | internal void UpdateThrottle(int pimagethrottle) |
358 | { | 359 | { |
359 | m_throttler.ThrottleBytes = 2 * pimagethrottle; | 360 | int tmp = 2 * pimagethrottle; |
360 | if(m_throttler.ThrottleBytes < 10000) | 361 | if(tmp < 10000) |
361 | m_throttler.ThrottleBytes = 10000; | 362 | tmp = 10000; |
363 | m_throttler.ThrottleBytes = tmp; | ||
362 | } | 364 | } |
363 | } | 365 | } |
364 | 366 | ||
@@ -426,16 +428,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
426 | 428 | ||
427 | internal sealed class CapsDataThrottler | 429 | internal sealed class CapsDataThrottler |
428 | { | 430 | { |
429 | 431 | private double lastTimeElapsed = 0; | |
430 | private volatile int currenttime = 0; | ||
431 | private volatile int lastTimeElapsed = 0; | ||
432 | private volatile int BytesSent = 0; | 432 | private volatile int BytesSent = 0; |
433 | public CapsDataThrottler(int pBytes, int max, int min) | 433 | public CapsDataThrottler(int pBytes) |
434 | { | 434 | { |
435 | if(pBytes < 10000) | ||
436 | pBytes = 10000; | ||
435 | ThrottleBytes = pBytes; | 437 | ThrottleBytes = pBytes; |
436 | if(ThrottleBytes < 10000) | 438 | lastTimeElapsed = Util.GetTimeStampMS(); |
437 | ThrottleBytes = 10000; | ||
438 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
439 | } | 439 | } |
440 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) | 440 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) |
441 | { | 441 | { |
@@ -468,20 +468,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
468 | return haskey; | 468 | return haskey; |
469 | } | 469 | } |
470 | 470 | ||
471 | public void ProcessTime() | 471 | public void PassTime() |
472 | { | ||
473 | PassTime(); | ||
474 | } | ||
475 | |||
476 | private void PassTime() | ||
477 | { | 472 | { |
478 | currenttime = Util.EnvironmentTickCount(); | 473 | double currenttime = Util.GetTimeStampMS(); |
479 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); | 474 | double timeElapsed = currenttime - lastTimeElapsed; |
480 | //processTimeBasedActions(responses); | 475 | if(timeElapsed < 50.0) |
481 | if (timeElapsed >= 100) | 476 | return; |
477 | int add = (int)(ThrottleBytes * timeElapsed * 0.001); | ||
478 | if (add >= 1000) | ||
482 | { | 479 | { |
483 | lastTimeElapsed = currenttime; | 480 | lastTimeElapsed = currenttime; |
484 | BytesSent -= (ThrottleBytes * timeElapsed / 1000); | 481 | BytesSent -= add; |
485 | if (BytesSent < 0) BytesSent = 0; | 482 | if (BytesSent < 0) BytesSent = 0; |
486 | } | 483 | } |
487 | } | 484 | } |