summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-10-27 10:55:28 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-10-27 10:55:28 +0000
commite5296d07b2ef80c76526ae67c9284564d8d26cdd (patch)
tree80024128b1639c9c98b38d7e3c5893752ec0aaa8 /usr.sbin
parent2441748b1fa247daf8166febde8ce69fd9162625 (diff)
use clock_getres(3) and calculate precision from that, and fill the
precision field when we reply in server mode accordingly. from phessler
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ntpd/ntp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 88016a5743d..b3878e96493 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.38 2004/10/22 21:17:37 henning Exp $ */
+/* $OpenBSD: ntp.c,v 1.39 2004/10/27 10:55:27 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -18,6 +18,7 @@
*/
#include <sys/param.h>
+#include <sys/time.h>
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
@@ -59,7 +60,7 @@ ntp_sighdlr(int sig)
pid_t
ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
{
- int nfds, i, j, idx_peers, timeout, nullfd;
+ int a, b, nfds, i, j, idx_peers, timeout, nullfd;
u_int pfd_elms = 0, idx2peer_elms = 0;
u_int listener_cnt, new_cnt;
pid_t pid;
@@ -69,6 +70,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
struct listen_addr *la;
struct ntp_peer *p;
struct ntp_peer **idx2peer = NULL;
+ struct timespec tp;
time_t nextaction;
void *newp;
@@ -130,6 +132,10 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
bzero(&conf->status, sizeof(conf->status));
conf->status.leap = LI_ALARM;
+ clock_getres(CLOCK_REALTIME, &tp);
+ for (a = 0, b = tp.tv_nsec; b > 0; a--, b >>= 1);
+ conf->status.precision = a;
+
log_info("ntp engine ready");