summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sasyncd/sasyncd.c
diff options
context:
space:
mode:
authorcheloha <cheloha@openbsd.org>2018-04-10 15:58:21 +0000
committercheloha <cheloha@openbsd.org>2018-04-10 15:58:21 +0000
commit17cf054f4d325b04643bef73711ad537dbc23137 (patch)
tree0ba67c8024538e2a1347b215267c63a65df6292a /usr.sbin/sasyncd/sasyncd.c
parenttweak usage() (diff)
downloadwireguard-openbsd-17cf054f4d325b04643bef73711ad537dbc23137.tar.xz
wireguard-openbsd-17cf054f4d325b04643bef73711ad537dbc23137.zip
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.c13
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()");