Skip to content
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

timerfd_create fails with CLOCK_BOOTTIME #45

Open
jbeich opened this issue Mar 1, 2023 · 5 comments
Open

timerfd_create fails with CLOCK_BOOTTIME #45

jbeich opened this issue Mar 1, 2023 · 5 comments

Comments

@jbeich
Copy link
Contributor

jbeich commented Mar 1, 2023

FreeBSD >= 13.1 added CLOCK_BOOTTIME but it appears to work differently from what consumers expect.

$ pkg install git meson pkgconf libepoll-shim json-glib
$ git clone https://gitlab.gnome.org/guidog/gmobile.git
$ git -C gmobile fetch origin merge-requests/11/head
$ git -C gmobile merge FETCH_HEAD
$ meson setup gmobile_build gmobile
$ meson compile -C gmobile_build
$ meson test -C gmobile_build timeout
[...]
1/1 timeout        TIMEOUT        30.02s   killed by signal 15 SIGTERM

$ gmobile_build/examples/gm-timeout -s 1
** Message: 19:01:38.768: Arming timer with 1 seconds
** Message: 19:01:38.769: Now 19:01:38
^T
load: 0.08  cmd: gm-timeout 9389 [select] 40.63r 0.00u 0.00s 0% 6152k
@jbeich
Copy link
Contributor Author

jbeich commented Mar 1, 2023

Neither feedbackd nor phoc use gm_timeout_add_seconds_*, so it's not critical to get right in ports/ because gmobile doesn't support system-wide installation.

@valpackett
Copy link

hmm:

epoll-shim/src/timerfd.c

Lines 121 to 123 in 702e845

if (clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME) {
return EINVAL;
}

does that consumer check the returned error?

@jbeich
Copy link
Contributor Author

jbeich commented Mar 1, 2023

From gmobile/src/gm-timeout.c:

static GSource *
gm_timeout_source_once_new (gulong timeout_ms)
{
...
  timer->fd = timerfd_create (CLOCK_BOOTTIME, 0);
  if (timer->fd == -1)
    return (GSource*)timer;
...
static gboolean
gm_timeout_once_prepare (GSource *source, gint *timeout)
{
...
  if (timer->fd == -1)
    return FALSE;

@jbeich
Copy link
Contributor Author

jbeich commented Dec 6, 2023

Native timerfd on NetBSD and FreeBSD is also limited to CLOCK_REALTIME and CLOCK_MONOTONIC.

@jbeich
Copy link
Contributor Author

jbeich commented Dec 6, 2023

Looking at illumos/illumos-gate@6a72db4a7fa1 I can't find what it does with unsupported clocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants