diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-09-18 20:27:58 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-09-18 20:27:58 +0000 |
commit | 287cceeeba650f4f5aa719de14cbffded33f79ac (patch) | |
tree | 23b4c06a038b3dbe66f1c032b26983d8c6355770 /usr.sbin | |
parent | db935e91e3580e7764611def9f74f0519e681862 (diff) |
don't call settimeofday() when the offset is smaller than 180 seconds,
adjtime() will fix that fast enough, from discussion in theo's living room
ok mcbride beck
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ntpd/ntpd.c | 6 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntpd.h | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c index f4955903e67..0a7ab12c295 100644 --- a/usr.sbin/ntpd/ntpd.c +++ b/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.18 2004/09/18 20:01:38 henning Exp $ */ +/* $OpenBSD: ntpd.c,v 1.19 2004/09/18 20:27:57 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -314,6 +314,10 @@ ntpd_settime(double d) char buf[80]; time_t tval; + /* if the offset is small, don't call settimeofday */ + if (d < SETTIME_MIN_OFFSET && d > -SETTIME_MIN_OFFSET) + return; + d_to_tv(d, &tv); if (gettimeofday(&curtime, NULL) == -1) log_warn("gettimeofday"); diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h index 19705d8a4b7..ac4cb360b91 100644 --- a/usr.sbin/ntpd/ntpd.h +++ b/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.38 2004/09/18 20:01:38 henning Exp $ */ +/* $OpenBSD: ntpd.h,v 1.39 2004/09/18 20:27:57 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -48,6 +48,7 @@ #define QUERYTIME_MAX 15 /* single query might take n secs max */ #define OFFSET_ARRAY_SIZE 8 +#define SETTIME_MIN_OFFSET 180 /* min offset for settime at start */ enum client_state { STATE_NONE, |