mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-11-23 11:49:50 +00:00
Fixes for kqueue timers (darlinghq/darling#420)
This commit is contained in:
parent
2c12e86fc6
commit
7ac3d4fbb1
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user