1 $DragonFly: src/usr.sbin/ntpd/patches/Attic/ntp.c.patch,v 1.8 2005/04/23 20:43:34 joerg Exp $
3 --- ntp.c 25 Feb 2005 16:43:19 -0000 1.6
4 +++ ntp.c 12 Apr 2005 20:13:45 -0000
8 bzero(&conf->status, sizeof(conf->status));
9 + conf->freq_samples = -1;
11 + conf->freq_xx = 0.0;
12 + conf->freq_xy = 0.0;
14 conf->status.leap = LI_ALARM;
15 clock_getres(CLOCK_REALTIME, &tp);
16 b = 1000000000 / tp.tv_nsec; /* convert to Hz */
18 if (p->deadline > 0 && p->deadline < nextaction)
19 nextaction = p->deadline;
20 if (p->deadline > 0 && p->deadline <= time(NULL)) {
21 - timeout = error_interval();
22 + if (p->trustlevel > TRUSTLEVEL_BADPEER)
23 + timeout = scale_interval(
24 + INTERVAL_QUERY_AGRESSIVE);
26 + timeout = error_interval();
27 log_debug("no reply from %s received in time, "
28 "next query %ds", log_sockaddr(
29 (struct sockaddr *)&p->addr->ss), timeout);
35 +priv_adjfreq(double offset)
37 + double curtime, freq;
39 + conf->freq_samples++;
41 + if (conf->freq_samples <= 0)
44 + offset += conf->overall_offset;
45 + curtime = gettime_corrected();
46 + conf->freq_xy += offset * curtime;
47 + conf->freq_x += curtime;
48 + conf->freq_y += offset;
49 + conf->freq_xx += curtime * curtime;
51 + if (conf->freq_samples % FREQUENCY_SAMPLES != 0)
55 + (conf->freq_xy - conf->freq_x * conf->freq_y / conf->freq_samples)
57 + (conf->freq_xx - conf->freq_x * conf->freq_x / conf->freq_samples);
59 + if (freq > MAX_FREQUENCY_ADJUST)
60 + freq = MAX_FREQUENCY_ADJUST;
61 + else if (freq < -MAX_FREQUENCY_ADJUST)
62 + freq = -MAX_FREQUENCY_ADJUST;
64 + imsg_compose(ibuf_main, IMSG_ADJFREQ, 0, 0, &freq, sizeof(freq));
65 + log_info("adjusting freqency by %f ppm", freq * 1e6);
66 + conf->freq_xy = 0.0;
69 + conf->freq_xx = 0.0;
70 + conf->freq_samples = 0;
77 imsg_compose(ibuf_main, IMSG_ADJTIME, 0, 0,
78 &offset_median, sizeof(offset_median));
80 + conf->overall_offset += offset_median;
81 + priv_adjfreq(offset_median);
83 conf->status.reftime = gettime();
84 conf->status.leap = LI_NOWARNING;
85 conf->status.stratum++; /* one more than selected peer */
87 if (peers[offset_cnt / 2]->addr->ss.ss_family == AF_INET)
88 conf->status.refid = ((struct sockaddr_in *)
89 &peers[offset_cnt / 2]->addr->ss)->sin_addr.s_addr;
91 + TAILQ_FOREACH(p, &conf->ntp_peers, entry) {
92 + for (i = 0; i < OFFSET_ARRAY_SIZE; i++)
93 + p->reply[i].offset -= offset_median;
100 - TAILQ_FOREACH(p, &conf->ntp_peers, entry)
101 - p->update.good = 0;