summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-06-26 08:10:46 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-06-26 08:10:46 +0000
commit9abd639bf8257142a2ac7b7ca00dc39667ec858a (patch)
tree09f461f1d57f174cda8636d3b02117d96145f3c4
parentdb22ea763c241fd8b9418d7bfbe911bc468493f6 (diff)
Reset adjtime() on startup; having an adjtime() active while starting
up causes overcompensation and confusing debug log entries; noticed by dtucker@
-rw-r--r--usr.sbin/ntpd/ntpd.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c
index cfd34be03cc..abea6df358a 100644
--- a/usr.sbin/ntpd/ntpd.c
+++ b/usr.sbin/ntpd/ntpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.c,v 1.45 2006/06/22 11:11:25 otto Exp $ */
+/* $OpenBSD: ntpd.c,v 1.46 2006/06/26 08:10:45 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -37,6 +37,7 @@ __dead void usage(void);
int main(int, char *[]);
int check_child(pid_t, const char *);
int dispatch_imsg(struct ntpd_conf *);
+void reset_adjtime(void);
int ntpd_adjtime(double);
void ntpd_adjfreq(double);
void ntpd_settime(double);
@@ -128,6 +129,7 @@ main(int argc, char *argv[])
}
endpwent();
+ reset_adjtime();
if (!conf.settime) {
log_init(conf.debug);
if (!conf.debug)
@@ -323,6 +325,17 @@ dispatch_imsg(struct ntpd_conf *conf)
return (0);
}
+void
+reset_adjtime(void)
+{
+ struct timeval tv;
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ if (adjtime(&tv, NULL) == -1)
+ log_warn("reset adjtime failed");
+}
+
int
ntpd_adjtime(double d)
{