From 1cd951e5aedad4be809fc2674e57e34d0972b67c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 9 Feb 2011 09:39:53 -0800 Subject: Fix the negative number problem in TokenBucket. mantis #5365 --- OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index de8b521..0a8331f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -207,14 +207,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP int dripAmount = deltaMS * tokensPerMS; - if (dripAmount < 0) - Console.WriteLine("MAY DAY MAY DAY! Drip amount is " + dripAmount + ". This should not happen"); - content = Math.Min(content + dripAmount, maxBurst); lastDrip = now; - if (content < 0) - Console.WriteLine("MAY DAY MAY DAY! Content is " + content + ". This should not happen"); + if (dripAmount < 0 || content < 0) + // sim has been idle for too long, integer has overflown + // previous calculation is meaningless, let's put it at correct max + content = maxBurst; return true; } -- cgit v1.1