kqueue: can't delete timers?

Hi,

I'm trying to use kqueue/kevent timers, and sometime i have to delete a timer, but it doesn't seems to work. I mean, the event is still fired.

The code to register the event:
Code:
EV_SET(&(sys_events->changelist[sys_events->num_events]), (uintptr_t)(sys_events_timer_id), EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, timeout, udata);

The code to delete the event:
Code:
EV_SET(&(sys_events->changelist[sys_events->num_events]), (uintptr_t)(sys_events_timer_id), EVFILT_TIMER, EV_DELETE, 0, 0, NULL);

The pair (ident, filter) is the same when adding and deleting the event, but when deleting it, udata is NULL. Now after calling kevent(), i get a timer event with udata == NULL and my code throw an assert.

One workaround is to skip events with udata == NULL (all my other events use udata as a pointer to a structure describing a callback function and its parameters). But as far as i understand, EV_DELETE is supposed to delete the event.

It is a bug or do i miss something ?

Edit: modifying the timer event seems to work.
Edit: using EV_ADD without EV_ONESHOT, it works as expected (but or'ing EV_ONESHOT to EV_DELETE doesn't).

Thanks,
Tobé
 
Back
Top