From d299eeb48576639ef8916fd78a7503fb453fcd79 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 5 Apr 2013 13:44:51 +0900 Subject: [PATCH] Fix a bug in AbstractTrafficShapingHandler.getTimeToWait() where it doesn't work OK when system time goes back. --- .../traffic/AbstractTrafficShapingHandler.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java b/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java index d8de674e43..239fd8b52f 100644 --- a/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java @@ -202,14 +202,11 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler } /** - * - * @return the time that should be necessary to wait to respect limit. Can - * be negative time - */ - private static long getTimeToWait(long limit, long bytes, long lastTime, - long curtime) { + * @return the time that should be necessary to wait to respect limit. Can be negative time + */ + private static long getTimeToWait(long limit, long bytes, long lastTime, long curtime) { long interval = curtime - lastTime; - if (interval == 0) { + if (interval <= 0) { // Time is too short, so just lets continue return 0; }