-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EVFILT_TIMER for Linux/POSIX Does Not Correctly Honor Event Data Changes across Calls to kqueue #116
Comments
Thanks for reporting this, and I do think that libkqueue should change it's behavior to match the native behavior of kqueue. Here's my quick take on what's happening. Feel free to correct any misunderstanding I may have. In your test program, the timer is created in one call to kevent(), and then in a second call to kevent() the data value is changed. Here's the relevant lines of code:
The bug in libkqueue is that we haven't implemented the
@gerickson I would like to add your test program to the libkqueue testsuite. Would you mind submitting an updated version that includes a copyright and license statement at the top in the following format:
|
@mheily may still be worth pulling this in as a test case. Most of the test program is duplicating functions we already have in the test suite so I'd rather not pull it in in its entirety. |
In contrast to the kernel-native implementation on BSD-based systems such as Darwin, libkqueue deviates from that/those implementations and the specification, insofar as the man page is a proxy for one in that not all changes to extant entries in the queue are not honored across calls to
kqueue
:The
kqueue
man page cites:This is particularly evident with
EVFILT_TIMER
in which the only opportunity to influence and set the timeout value is inevfilt_timer_knote_create
in src/linux/timer.c.This is demonstrated with the attached sample program, compiled and executed with:
on Darwin and with:
on Linux. On Darwin, the changes to the EVFILT_TIMER
data
value are observed acrosskqueue
calls and the wait correctly expires four (4) times at the second of the two data values pushed for the event, as expected. However, on Linux, using libkqueue-2.5.1, the wait only expires two (2) of the four (4) expected and does so at the first of the two data values pushed for those events.The as-implemented behavior makes using
kqueue
via libkqueue for CFRunLoop timer support in opencflite problematic when multiple timers are at play when a later-added timer has a smaller or larger expiry than the prior timer, requiring the timer event in the kqueue to be adjusted downward or upward.The text was updated successfully, but these errors were encountered: