Browse Source

After calling adjfreq to correct the clock's rate, measure and fix the clock

offset. This avoids future frequency adjustments based on measurements of a
clock that was being adjusted. End result: more stable clock and better
frequency convergence.
Also, fix a mis-ordered structure member while I'm here.
ok henning
OPENBSD_4_6
ckuethe 15 years ago
parent
commit
b6c201f1e1
2 changed files with 11 additions and 3 deletions
  1. +7
    -1
      src/usr.sbin/ntpd/ntp.c
  2. +4
    -2
      src/usr.sbin/ntpd/ntpd.h

+ 7
- 1
src/usr.sbin/ntpd/ntp.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp.c,v 1.110 2009/01/26 11:51:50 henning Exp $ */
/* $OpenBSD: ntp.c,v 1.111 2009/06/04 23:39:45 ckuethe Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -530,6 +530,11 @@ priv_adjfreq(double offset)
if (!conf->status.synced)
return;
if (conf->filters & FILTER_ADJFREQ){
conf->filters &= ~FILTER_ADJFREQ;
return;
}
conf->freq.samples++;
if (conf->freq.samples <= 0)
@ -558,6 +563,7 @@ priv_adjfreq(double offset)
freq = -MAX_FREQUENCY_ADJUST;
imsg_compose(ibuf_main, IMSG_ADJFREQ, 0, 0, &freq, sizeof(freq));
conf->filters |= FILTER_ADJFREQ;
conf->freq.xy = 0.0;
conf->freq.x = 0.0;
conf->freq.y = 0.0;


+ 4
- 2
src/usr.sbin/ntpd/ntpd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.100 2009/05/13 15:08:10 stevesk Exp $ */
/* $OpenBSD: ntpd.h,v 1.101 2009/06/04 23:39:46 ckuethe Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -62,6 +62,7 @@
#define REPORT_INTERVAL (24*60*60) /* interval between status reports */
#define MAX_SEND_ERRORS 3 /* max send errors before reconnect */
#define FILTER_ADJFREQ 0x01 /* set after doing adjfreq */
#define SENSOR_DATA_MAXAGE (15*60)
#define SENSOR_QUERY_INTERVAL 30
@ -171,11 +172,12 @@ struct ntpd_conf {
TAILQ_HEAD(ntp_conf_sensors, ntp_conf_sensor) ntp_conf_sensors;
struct ntp_status status;
struct ntp_freq freq;
u_int32_t scale;
u_int8_t listen_all;
u_int8_t settime;
u_int8_t debug;
u_int32_t scale;
u_int8_t noaction;
u_int8_t filters;
};
struct buf {


Loading…
Cancel
Save