Fixed a case where HashedWheelTimer notifies a timeout one round later

This commit is contained in:
Trustin Lee 2009-06-05 17:05:42 +00:00
parent bb6f5a6104
commit afb7e511ad

View File

@ -309,12 +309,12 @@ public class HashedWheelTimer implements Timer {
List<HashedWheelTimeout> expiredTimeouts,
ReusableIterator<HashedWheelTimeout> i) {
long currentTime = System.currentTimeMillis();
long currentDeadline = System.currentTimeMillis() + tickDuration;
i.rewind();
while (i.hasNext()) {
HashedWheelTimeout timeout = i.next();
if (timeout.remainingRounds <= 0) {
if (timeout.deadline <= currentTime) {
if (timeout.deadline < currentDeadline) {
i.remove();
expiredTimeouts.add(timeout);
} else {