diff options
author | 2013-03-10 23:32:53 +0000 | |
---|---|---|
committer | 2013-03-10 23:32:53 +0000 | |
commit | fd1841a32c2961a48d081d9f7268f6ae44577069 (patch) | |
tree | dd6dc36750306f44785ea2c1416903e0c5da1dca /usr.sbin/relayd/log.c | |
parent | document REGRESS -> TEST (diff) | |
download | wireguard-openbsd-fd1841a32c2961a48d081d9f7268f6ae44577069.tar.xz wireguard-openbsd-fd1841a32c2961a48d081d9f7268f6ae44577069.zip |
This diff changes relayd to use the monotonic clock instead of
gettimeofday(). It was also bugging me for some time to have all
these checks of gettimeofday()'s return value: it should not fail. So
this diff introduces a void getmonotime(struct timeval *tv) that calls
clock_gettime(CLOCK_MONOTONIC, &ts) and converts the output to a
struct timeval that can be used with the existing code and the
timeval-specific timer functions (timerclear, timersub, ...). It does
not return a status but calls fatal() on error-that-should-not-happen.
ok sthen@ chris@
Diffstat (limited to 'usr.sbin/relayd/log.c')
-rw-r--r-- | usr.sbin/relayd/log.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.sbin/relayd/log.c b/usr.sbin/relayd/log.c index da5a2fb2fa6..3e0ba36f1c2 100644 --- a/usr.sbin/relayd/log.c +++ b/usr.sbin/relayd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.18 2012/11/27 05:00:28 guenther Exp $ */ +/* $OpenBSD: log.c,v 1.19 2013/03/10 23:32:53 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -455,3 +455,14 @@ printb_flags(const u_int32_t v, const char *bits) return (r); } + +void +getmonotime(struct timeval *tv) +{ + struct timespec ts; + + if (clock_gettime(CLOCK_MONOTONIC, &ts)) + fatal("clock_gettime"); + + TIMESPEC_TO_TIMEVAL(tv, &ts); +} |