Fixes for kqueue timers (darlinghq/darling#420)

This commit is contained in:
Lubos Dolezel 2018-11-07 20:25:45 +01:00
parent 2c12e86fc6
commit 7ac3d4fbb1

View File

@ -210,10 +210,16 @@ int
evfilt_timer_knote_modify(struct filter *filt, struct knote *kn,
const struct kevent64_s *kev)
{
(void)filt;
(void)kn;
(void)kev;
return (0); /* STUB */
struct itimerspec ts;
int tfd = kn->data.pfd;
convert_to_itimerspec(&ts, kn->kev.data, kn->kev.flags & EV_ONESHOT, kn->kev.fflags);
if (timerfd_settime(tfd, 0, &ts, NULL) < 0) {
dbg_printf("timerfd_settime(2): %s", strerror(errno));
return (-1);
}
return (0);
}
int
@ -240,13 +246,23 @@ evfilt_timer_knote_delete(struct filter *filt, struct knote *kn)
int
evfilt_timer_knote_enable(struct filter *filt, struct knote *kn)
{
return evfilt_timer_knote_create(filt, kn);
return evfilt_timer_knote_modify(filt, kn, &kn->kev);
}
int
evfilt_timer_knote_disable(struct filter *filt, struct knote *kn)
{
return evfilt_timer_knote_delete(filt, kn);
struct itimerspec ts;
int tfd = kn->data.pfd;
memset(&ts, 0, sizeof(ts));
if (timerfd_settime(tfd, 0, &ts, NULL) < 0) {
dbg_printf("timerfd_settime(2): %s", strerror(errno));
return (-1);
}
return 0;
}
const struct filter evfilt_timer = {