From 8c3023d471ffa459b33aa8a8df3c279a9b7e3d84 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 17 Apr 2018 21:35:32 +0200 Subject: [PATCH] n-acd: use CLOCK_MONOTONIC timers on older kernels The README states that a kernel >= 3.0 is enough, however CLOCK_BOOTTIME is only available since kernel 3.15. Fall back to CLOCK_MONOTONIC when CLOCK_BOOTTIME is not available. See: https://github.com/nettools/n-acd/pull/3 Signed-off-by: Beniamino Galvani --- shared/n-acd/src/n-acd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shared/n-acd/src/n-acd.c b/shared/n-acd/src/n-acd.c index 266e5d6f2a..492bfde4ff 100644 --- a/shared/n-acd/src/n-acd.c +++ b/shared/n-acd/src/n-acd.c @@ -264,6 +264,13 @@ _public_ int n_acd_new(NAcd **acdp) { } acd->fd_timer = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC | TFD_NONBLOCK); + if (acd->fd_timer < 0 && errno == EINVAL) { + /* + * Fall back to CLOCK_MONOTONIC when CLOCK_BOOTTIME is + * not available (kernel < 3.15). + */ + acd->fd_timer = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); + } if (acd->fd_timer < 0) { r = -n_acd_errno(); goto error;