diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2018-04-10 15:58:22 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2018-04-10 15:58:22 +0000 |
commit | d5031e8381d1d54e45858aea86db74ed6a13adc7 (patch) | |
tree | 417dbdb1adfa9c9d94169476285168d9a22b0699 /usr.sbin/sasyncd/sasyncd.c | |
parent | fd2f6a0c9e39aa13a271b7715bd663828c307d1b (diff) |
Schedule events against the monotonic clock.
So that events fire punctually, even if the system clock is changed.
ok jca@
Diffstat (limited to 'usr.sbin/sasyncd/sasyncd.c')
-rw-r--r-- | usr.sbin/sasyncd/sasyncd.c | 13 |
1 files changed, 7 insertions, 6 deletions
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 <sys/types.h> -#include <sys/time.h> + #include <errno.h> #include <fcntl.h> #include <pwd.h> @@ -39,6 +39,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <time.h> #include <unistd.h> #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()"); |