[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ratelimit: restrict the delay time to a non-negative value
From: |
Alberto Garcia |
Subject: |
Re: [PATCH] ratelimit: restrict the delay time to a non-negative value |
Date: |
Tue, 20 Sep 2022 13:18:54 +0000 |
On Tue 20 Sep 2022 08:33:50 PM +08, wangliangzz@126.com wrote:
> From: Wang Liang <wangliangzz@inspur.com>
>
> The delay time should never be a negative value.
>
> - return limit->slice_end_time - now;
> + return MAX(limit->slice_end_time - now, 0);
How can this be negative? slice_end_time is guaranteed to be larger than
now:
if (limit->slice_end_time < now) {
/* Previous, possibly extended, time slice finished; reset the
* accounting. */
limit->slice_start_time = now;
limit->slice_end_time = now + limit->slice_ns;
limit->dispatched = 0;
}
Berto