Open sveyret opened 2 years ago
The problem seems to be that the parameters of timerfd_settime
and timerfd_gettime
, unlike the ones of timerfd_create
(which is not intercepted by libfaketime), give no indication about which clockid
is used for the timer. There also seems to be no other function (at least in the man pages) to determine the clockid
based on a given fd
.
Disabling timerfd
-related faking would therefore also disable it for other clockid
s, which is not something to expect solely based on DONT_FAKE_MONOTONIC
set.
As a fix for your specific case, you simply can rename the intercepted functions:
which effectively disables their interception. A cleaner fix probably would involve intercepting timerfd_create
as well and keeping track of which fd
s correspond to which clockid
libfaketime-internally. This sort of internal tracking across different function calls is actually something we never did before to keep things simple, but might be necessary here.
Thank you for your answer, @wolfcw .
Actually, I discovered in my app that I also use some real clock based timerfd
, so, contrary to what I said previously, totally disabling them is not possible.
I made a patch which is reading the file /proc/self/fdinfo/fd, but it is not very reliable as it requires CONFIG_PROC_FS
to be set in the kernel (which is generally the case) and depends on the way clockid
is displayed. Intercepting timerfd_create
and tracking clockid
matching with fd
as you suggest is probably the cleanest solution.
Hi! I have an app using
timerfd_create
,timerfd_settime
andtimerfd_gettime
with monotonic clock id. Because I don’t want to fake monotonic timers, I have setFAKETIME_DONT_FAKE_MONOTONIC=1
. The problem is that the type of timer is not detected and faked anyway, which makes my app wait for a very long time if the clock is set in the past, and even throw an exception if it is set in the future (it tries to wait for a negative amount of time). If there is no cleaner way to do it, it would be good to have at least an environment variable to deactivatetimerfd
(and onlytimerfd
) faking. Thank you.