[#1959] Proposed fix to correctly handle timeouts that overflow the ticks in the wheel

This commit is contained in:
Norman Maurer 2013-10-31 06:13:27 +01:00
parent 6d436948a7
commit fb6d301090

View File

@ -506,9 +506,10 @@ public class HashedWheelTimer implements Timer {
this.task = task; this.task = task;
this.deadline = deadline; this.deadline = deadline;
final long ticks = Math.max(deadline / tickDuration, tick); // Ensure we don't schedule for past. long calculated = deadline / tickDuration;
final long ticks = Math.max(calculated, tick); // Ensure we don't schedule for past.
stopIndex = (int) (ticks & mask); stopIndex = (int) (ticks & mask);
remainingRounds = ticks / wheel.length; remainingRounds = (calculated - tick) / wheel.length;
} }
public Timer getTimer() { public Timer getTimer() {