remove disabled timer from pqueue
@@ -60,19 +60,22 @@ timer register_periodic_timer(timestamp interval, thunk n)
*/
timestamp timer_check()
{
- timestamp here;
+ timestamp here = 0;
timer current = 0;
while ((current = pqueue_peek(timers)) &&
(here = now(), current->w < here)) {
- if (!current->disable) {
pqueue_pop(timers);
+ if(!current->disable) {
apply(current->t);
if (current->interval) {
current->w += current->interval;
pqueue_insert(timers, current);
}
- } // XXX fix the leak
+ } else {
+ deallocate(theap, current, sizeof(struct timer));
+ current = 0;
+ }
}
if (current) {
timestamp dt = current->w - here;
