diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2013-03-10 23:32:54 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2013-03-10 23:32:54 +0000 |
commit | 16b3f6a9c07a4e81c2a14b6978aeab8915369e1c (patch) | |
tree | 38a3db963ab59d95cbde82b54839bccc78bbcfee /usr.sbin/relayctl | |
parent | cb0d5e08c6a44c73902ec94832a378ad121929e8 (diff) |
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/relayctl')
-rw-r--r-- | usr.sbin/relayctl/relayctl.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index 382f9551d84..c78886ec032 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.45 2011/05/20 09:43:53 reyk Exp $ */ +/* $OpenBSD: relayctl.c,v 1.46 2013/03/10 23:32:53 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -443,8 +443,7 @@ show_session_msg(struct imsg *imsg) a, ntohs(con->se_in.port), b, ntohs(con->se_out.port), con->se_done ? "DONE" : "RUNNING"); - if (gettimeofday(&tv_now, NULL)) - fatal("show_session_msg: gettimeofday"); + getmonotime(&tv_now); print_time(&tv_now, &con->se_tv_start, a, sizeof(a)); print_time(&tv_now, &con->se_tv_last, b, sizeof(b)); printf("\tage %s, idle %s, relay %u, pid %u", |