From d5031e8381d1d54e45858aea86db74ed6a13adc7 Mon Sep 17 00:00:00 2001 From: cheloha Date: Tue, 10 Apr 2018 15:58:22 +0000 Subject: Schedule events against the monotonic clock. So that events fire punctually, even if the system clock is changed. ok jca@ --- usr.sbin/sasyncd/sasyncd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'usr.sbin/sasyncd/sasyncd.c') diff --git a/usr.sbin/sasyncd/sasyncd.c b/usr.sbin/sasyncd/sasyncd.c index 8214457e77c..96b19c75865 100644 --- a/usr.sbin/sasyncd/sasyncd.c +++ b/usr.sbin/sasyncd/sasyncd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sasyncd.c,v 1.27 2017/04/10 09:27:08 reyk Exp $ */ +/* $OpenBSD: sasyncd.c,v 1.28 2018/04/10 15:58:21 cheloha Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -31,7 +31,7 @@ #include -#include + #include #include #include @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "sasyncd.h" @@ -55,7 +56,7 @@ sasyncd_stop(int s) static int sasyncd_run(pid_t ppid) { - struct timeval *timeout, tv; + struct timespec *timeout, ts; fd_set *rfds, *wfds; size_t fdsetsize; int maxfd, n; @@ -101,10 +102,10 @@ sasyncd_run(pid_t ppid) if (cfgstate.route_socket + 1 > maxfd) maxfd = cfgstate.route_socket + 1; - timeout = &tv; - timer_next_event(&tv); + timeout = &ts; + timer_next_event(&ts); - n = select(maxfd, rfds, wfds, 0, timeout); + n = pselect(maxfd, rfds, wfds, NULL, timeout, NULL); if (n == -1) { if (errno != EINTR) { log_err("select()"); -- cgit v1.2.3