Fix bug in timer wheel

This commit is contained in:
Ali Mashtizadeh 2015-01-16 15:25:13 -08:00
parent a01b839b67
commit 6953d03cb3

View File

@ -48,7 +48,7 @@ Timer_Create(uint64_t timeout, TimerCB cb, void *arg)
evt->arg = arg;
Spinlock_Lock(&timerLock);
slot = (timerHead + timeout) % TIMER_WHEEL_LENGTH;
slot = (timerHead + timeout + TIMER_WHEEL_LENGTH - 1) % TIMER_WHEEL_LENGTH;
// XXX: should insert into tail
LIST_INSERT_HEAD(&timerSlot[slot], evt, timerQueue);
Spinlock_Unlock(&timerLock);