|
|
6e16f6 |
diff -up ntp-4.2.6p1/include/ntp_refclock.h.sleep ntp-4.2.6p1/include/ntp_refclock.h
|
|
|
6e16f6 |
--- ntp-4.2.6p1/include/ntp_refclock.h.sleep 2009-12-09 08:36:35.000000000 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p1/include/ntp_refclock.h 2010-03-10 19:27:46.000000000 +0100
|
|
|
6e16f6 |
@@ -260,6 +260,7 @@ extern void refclock_control (sockaddr_u
|
|
|
6e16f6 |
struct refclockstat *);
|
|
|
6e16f6 |
extern int refclock_open (char *, u_int, u_int);
|
|
|
6e16f6 |
extern int refclock_setup (int, u_int, u_int);
|
|
|
6e16f6 |
+extern int refclock_timer_needed (struct peer *);
|
|
|
6e16f6 |
extern void refclock_timer (struct peer *);
|
|
|
6e16f6 |
extern void refclock_transmit (struct peer *);
|
|
|
6e16f6 |
extern int refclock_ioctl (int, u_int);
|
|
|
6e16f6 |
diff -up ntp-4.2.6p1/include/ntp_stdlib.h.sleep ntp-4.2.6p1/include/ntp_stdlib.h
|
|
|
6e16f6 |
--- ntp-4.2.6p1/include/ntp_stdlib.h.sleep 2009-12-09 08:36:35.000000000 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p1/include/ntp_stdlib.h 2010-03-10 19:27:46.000000000 +0100
|
|
|
6e16f6 |
@@ -116,6 +116,7 @@ extern const char * FindConfig (const ch
|
|
|
6e16f6 |
extern void signal_no_reset (int, RETSIGTYPE (*func)(int));
|
|
|
6e16f6 |
|
|
|
6e16f6 |
extern void getauthkeys (const char *);
|
|
|
6e16f6 |
+extern int auth_agekeys_needed (void);
|
|
|
6e16f6 |
extern void auth_agekeys (void);
|
|
|
6e16f6 |
extern void rereadkeys (void);
|
|
|
6e16f6 |
|
|
|
6e16f6 |
diff -up ntp-4.2.6p1/include/ntpd.h.sleep ntp-4.2.6p1/include/ntpd.h
|
|
|
6e16f6 |
--- ntp-4.2.6p1/include/ntpd.h.sleep 2009-12-09 08:36:35.000000000 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p1/include/ntpd.h 2010-03-10 19:27:46.000000000 +0100
|
|
|
6e16f6 |
@@ -112,8 +112,10 @@ extern void block_io_and_alarm (void);
|
|
|
6e16f6 |
/* ntp_loopfilter.c */
|
|
|
6e16f6 |
extern void init_loopfilter(void);
|
|
|
6e16f6 |
extern int local_clock(struct peer *, double);
|
|
|
6e16f6 |
-extern void adj_host_clock(void);
|
|
|
6e16f6 |
+extern int adj_host_clock_needed(void);
|
|
|
6e16f6 |
+extern void adj_host_clock(int);
|
|
|
6e16f6 |
extern void loop_config(int, double);
|
|
|
6e16f6 |
+extern int huffpuff_enabled(void);
|
|
|
6e16f6 |
extern void huffpuff(void);
|
|
|
6e16f6 |
extern u_long sys_clocktime;
|
|
|
6e16f6 |
extern u_int sys_tai;
|
|
|
6e16f6 |
@@ -219,6 +221,8 @@ extern void hack_restrict (int, sockaddr
|
|
|
6e16f6 |
/* ntp_timer.c */
|
|
|
6e16f6 |
extern void init_timer (void);
|
|
|
6e16f6 |
extern void reinit_timer (void);
|
|
|
6e16f6 |
+extern double get_timeout (l_fp *);
|
|
|
6e16f6 |
+extern int timer_elapsed (l_fp, int);
|
|
|
6e16f6 |
extern void timer (void);
|
|
|
6e16f6 |
extern void timer_clr_stats (void);
|
|
|
6e16f6 |
extern void timer_interfacetimeout (u_long);
|
|
|
6e16f6 |
diff -up ntp-4.2.6p1/libntp/authkeys.c.sleep ntp-4.2.6p1/libntp/authkeys.c
|
|
|
6e16f6 |
--- ntp-4.2.6p1/libntp/authkeys.c.sleep 2009-12-09 08:36:35.000000000 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p1/libntp/authkeys.c 2010-03-10 19:27:46.000000000 +0100
|
|
|
6e16f6 |
@@ -445,6 +445,25 @@ auth_delkeys(void)
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
+int
|
|
|
6e16f6 |
+auth_agekeys_needed(void) {
|
|
|
6e16f6 |
+ struct savekey *sk;
|
|
|
6e16f6 |
+ int i;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ if (authnumkeys > 20)
|
|
|
6e16f6 |
+ return 1;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ for (i = 0; i < HASHSIZE; i++) {
|
|
|
6e16f6 |
+ sk = key_hash[i];
|
|
|
6e16f6 |
+ while (sk != 0) {
|
|
|
6e16f6 |
+ if (sk->lifetime > 0)
|
|
|
6e16f6 |
+ return 1;
|
|
|
6e16f6 |
+ sk = sk->next;
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+ return 0;
|
|
|
6e16f6 |
+}
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* auth_agekeys - delete keys whose lifetimes have expired
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
diff -up ntp-4.2.6p1/ntpd/ntp_loopfilter.c.sleep ntp-4.2.6p1/ntpd/ntp_loopfilter.c
|
|
|
6e16f6 |
--- ntp-4.2.6p1/ntpd/ntp_loopfilter.c.sleep 2009-12-09 08:36:36.000000000 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p1/ntpd/ntp_loopfilter.c 2010-03-10 19:27:46.000000000 +0100
|
|
|
6e16f6 |
@@ -677,6 +677,13 @@ local_clock(
|
|
|
6e16f6 |
#endif /* LOCKCLOCK */
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
+int
|
|
|
6e16f6 |
+adj_host_clock_needed(void)
|
|
|
6e16f6 |
+{
|
|
|
6e16f6 |
+ return !(!ntp_enable || mode_ntpdate || (pll_control &&
|
|
|
6e16f6 |
+ kern_enable));
|
|
|
6e16f6 |
+}
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* adj_host_clock - Called once every second to update the local clock.
|
|
|
6e16f6 |
@@ -686,7 +693,7 @@ local_clock(
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
void
|
|
|
6e16f6 |
adj_host_clock(
|
|
|
6e16f6 |
- void
|
|
|
6e16f6 |
+ int time_elapsed
|
|
|
6e16f6 |
)
|
|
|
6e16f6 |
{
|
|
|
6e16f6 |
double adjustment;
|
|
|
6e16f6 |
@@ -698,7 +705,7 @@ adj_host_clock(
|
|
|
6e16f6 |
* since the poll interval can exceed one day, the old test
|
|
|
6e16f6 |
* would be counterproductive.
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
- sys_rootdisp += clock_phi;
|
|
|
6e16f6 |
+ sys_rootdisp += clock_phi * time_elapsed;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
#ifndef LOCKCLOCK
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
@@ -819,6 +826,12 @@ set_freq(
|
|
|
6e16f6 |
#endif /* KERNEL_PLL */
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
+int
|
|
|
6e16f6 |
+huffpuff_enabled(void)
|
|
|
6e16f6 |
+{
|
|
|
6e16f6 |
+ return sys_huffpuff != NULL;
|
|
|
6e16f6 |
+}
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* huff-n'-puff filter
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
diff -up ntp-4.2.6p1/ntpd/ntp_refclock.c.sleep ntp-4.2.6p1/ntpd/ntp_refclock.c
|
|
|
6e16f6 |
--- ntp-4.2.6p1/ntpd/ntp_refclock.c.sleep 2009-12-09 08:36:36.000000000 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p1/ntpd/ntp_refclock.c 2010-03-10 19:27:46.000000000 +0100
|
|
|
6e16f6 |
@@ -268,6 +268,21 @@ refclock_unpeer(
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
|
|
|
6e16f6 |
+int
|
|
|
6e16f6 |
+refclock_timer_needed(
|
|
|
6e16f6 |
+ struct peer *peer /* peer structure pointer */
|
|
|
6e16f6 |
+ )
|
|
|
6e16f6 |
+{
|
|
|
6e16f6 |
+ u_char clktype;
|
|
|
6e16f6 |
+ int unit;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ clktype = peer->refclktype;
|
|
|
6e16f6 |
+ unit = peer->refclkunit;
|
|
|
6e16f6 |
+ if (refclock_conf[clktype]->clock_timer != noentry)
|
|
|
6e16f6 |
+ return 1;
|
|
|
6e16f6 |
+ return 0;
|
|
|
6e16f6 |
+}
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* refclock_timer - called once per second for housekeeping.
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
diff -up ntp-4.2.6p1/ntpd/ntp_timer.c.sleep ntp-4.2.6p1/ntpd/ntp_timer.c
|
|
|
6e16f6 |
--- ntp-4.2.6p1/ntpd/ntp_timer.c.sleep 2009-12-09 08:36:35.000000000 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p1/ntpd/ntp_timer.c 2010-03-11 15:23:59.000000000 +0100
|
|
|
6e16f6 |
@@ -56,7 +56,6 @@ static u_long adjust_timer; /* second ti
|
|
|
6e16f6 |
static u_long stats_timer; /* stats timer */
|
|
|
6e16f6 |
static u_long huffpuff_timer; /* huff-n'-puff timer */
|
|
|
6e16f6 |
u_long leapsec; /* leapseconds countdown */
|
|
|
6e16f6 |
-l_fp sys_time; /* current system time */
|
|
|
6e16f6 |
#ifdef OPENSSL
|
|
|
6e16f6 |
static u_long revoke_timer; /* keys revoke timer */
|
|
|
6e16f6 |
static u_long keys_timer; /* session key timer */
|
|
|
6e16f6 |
@@ -74,6 +73,12 @@ volatile u_long alarm_overflow;
|
|
|
6e16f6 |
#define DAY (24 * HOUR)
|
|
|
6e16f6 |
|
|
|
6e16f6 |
u_long current_time; /* seconds since startup */
|
|
|
6e16f6 |
+l_fp timer_base;
|
|
|
6e16f6 |
+int time_elapsed;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+#define TIMEOUT_TS_SIZE 2
|
|
|
6e16f6 |
+l_fp timeout_ts[TIMEOUT_TS_SIZE];
|
|
|
6e16f6 |
+unsigned int timeout_ts_index;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* Stats. Number of overflows and number of calls to transmit().
|
|
|
6e16f6 |
@@ -110,6 +115,8 @@ static RETSIGTYPE alarming (int);
|
|
|
6e16f6 |
void
|
|
|
6e16f6 |
reinit_timer(void)
|
|
|
6e16f6 |
{
|
|
|
6e16f6 |
+ get_systime(&timer_base);
|
|
|
6e16f6 |
+#if 0
|
|
|
6e16f6 |
#if !defined(SYS_WINNT) && !defined(VMS)
|
|
|
6e16f6 |
# if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME)
|
|
|
6e16f6 |
timer_gettime(ntpd_timerid, &itimer);
|
|
|
6e16f6 |
@@ -143,6 +150,7 @@ reinit_timer(void)
|
|
|
6e16f6 |
setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
|
|
|
6e16f6 |
# endif
|
|
|
6e16f6 |
# endif /* VMS */
|
|
|
6e16f6 |
+#endif
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
@@ -165,6 +173,12 @@ init_timer(void)
|
|
|
6e16f6 |
timer_xmtcalls = 0;
|
|
|
6e16f6 |
timer_timereset = 0;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
+ get_systime(&timer_base);
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ for (timeout_ts_index = 0; timeout_ts_index < TIMEOUT_TS_SIZE; timeout_ts_index++)
|
|
|
6e16f6 |
+ L_CLR(&timeout_ts[timeout_ts_index]);
|
|
|
6e16f6 |
+ timeout_ts_index = 0;
|
|
|
6e16f6 |
+#if 0
|
|
|
6e16f6 |
#if !defined(SYS_WINNT)
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* Set up the alarm interrupt. The first comes 2**EVENT_TIMEOUT
|
|
|
6e16f6 |
@@ -226,6 +240,7 @@ init_timer(void)
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
#endif /* SYS_WINNT */
|
|
|
6e16f6 |
+#endif
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
#if defined(SYS_WINNT)
|
|
|
6e16f6 |
@@ -236,6 +251,104 @@ get_timer_handle(void)
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
#endif
|
|
|
6e16f6 |
|
|
|
6e16f6 |
+double
|
|
|
6e16f6 |
+get_timeout(l_fp *now)
|
|
|
6e16f6 |
+{
|
|
|
6e16f6 |
+ register struct peer *peer, *next_peer;
|
|
|
6e16f6 |
+ u_int n;
|
|
|
6e16f6 |
+ double r;
|
|
|
6e16f6 |
+ int next;
|
|
|
6e16f6 |
+ l_fp ts;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ ts = *now;
|
|
|
6e16f6 |
+ L_SUB(&ts, &timeout_ts[timeout_ts_index]);
|
|
|
6e16f6 |
+ timeout_ts[timeout_ts_index] = *now;
|
|
|
6e16f6 |
+ timeout_ts_index = (timeout_ts_index + 1) % TIMEOUT_TS_SIZE;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ /* don't waste CPU time if called too frequently */
|
|
|
6e16f6 |
+ if (ts.l_ui == 0) {
|
|
|
6e16f6 |
+ next = 1;
|
|
|
6e16f6 |
+ goto finish;
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ next = current_time + HOUR;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ if (adj_host_clock_needed()) {
|
|
|
6e16f6 |
+ next = 1;
|
|
|
6e16f6 |
+ goto finish;
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+ for (n = 0; n < NTP_HASH_SIZE; n++) {
|
|
|
6e16f6 |
+ for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
|
|
|
6e16f6 |
+ next_peer = peer->next;
|
|
|
6e16f6 |
+#ifdef REFCLOCK
|
|
|
6e16f6 |
+ if (peer->flags & FLAG_REFCLOCK && refclock_timer_needed(peer)) {
|
|
|
6e16f6 |
+ next = 1;
|
|
|
6e16f6 |
+ goto finish;
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+#endif /* REFCLOCK */
|
|
|
6e16f6 |
+ if (peer->action)
|
|
|
6e16f6 |
+ next = min(next, peer->nextaction);
|
|
|
6e16f6 |
+ next = min(next, peer->nextdate);
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ if (leapsec > 0)
|
|
|
6e16f6 |
+ next = min(next, leapsec);
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ if (huffpuff_enabled())
|
|
|
6e16f6 |
+ next = min(next, huffpuff_timer);
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+#ifdef OPENSSL
|
|
|
6e16f6 |
+ if (auth_agekeys_needed())
|
|
|
6e16f6 |
+ next = min(next, keys_timer);
|
|
|
6e16f6 |
+ if (sys_leap != LEAP_NOTINSYNC)
|
|
|
6e16f6 |
+ next = min(next, revoke_timer);
|
|
|
6e16f6 |
+#endif /* OPENSSL */
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ if (interface_interval)
|
|
|
6e16f6 |
+ next = min(next, interface_timer);
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ next = min(next, stats_timer);
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ next -= current_time;
|
|
|
6e16f6 |
+ if (next <= 0)
|
|
|
6e16f6 |
+ next = 1;
|
|
|
6e16f6 |
+finish:
|
|
|
6e16f6 |
+ ts = timer_base;
|
|
|
6e16f6 |
+ ts.l_ui += next;
|
|
|
6e16f6 |
+ L_SUB(&ts, now);
|
|
|
6e16f6 |
+ LFPTOD(&ts, r);
|
|
|
6e16f6 |
+#ifdef DEBUG
|
|
|
6e16f6 |
+ DPRINTF(2, ("timer: timeout %f\n", r));
|
|
|
6e16f6 |
+#endif
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ return r;
|
|
|
6e16f6 |
+}
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+int
|
|
|
6e16f6 |
+timer_elapsed(l_fp now, int timeout)
|
|
|
6e16f6 |
+{
|
|
|
6e16f6 |
+ int elapsed;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ L_SUB(&now, &timer_base);
|
|
|
6e16f6 |
+ elapsed = now.l_i;
|
|
|
6e16f6 |
+ if (elapsed < 0 || elapsed > timeout + 10) {
|
|
|
6e16f6 |
+#ifdef DEBUG
|
|
|
6e16f6 |
+ DPRINTF(2, ("timer: unexpected time jump\n"));
|
|
|
6e16f6 |
+#endif
|
|
|
6e16f6 |
+ elapsed = 0;
|
|
|
6e16f6 |
+ reinit_timer();
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ }
|
|
|
6e16f6 |
+ timer_base.l_ui += elapsed;
|
|
|
6e16f6 |
+ time_elapsed += elapsed;
|
|
|
6e16f6 |
+ current_time += elapsed;
|
|
|
6e16f6 |
+#ifdef DEBUG
|
|
|
6e16f6 |
+ DPRINTF(2, ("timer: time elapsed %d\n", time_elapsed));
|
|
|
6e16f6 |
+#endif
|
|
|
6e16f6 |
+ return time_elapsed;
|
|
|
6e16f6 |
+}
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* timer - event timer
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
@@ -251,11 +364,9 @@ timer(void)
|
|
|
6e16f6 |
* kiss-o'-deatch function and implement the association
|
|
|
6e16f6 |
* polling function..
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
- current_time++;
|
|
|
6e16f6 |
- get_systime(&sys_time);
|
|
|
6e16f6 |
if (adjust_timer <= current_time) {
|
|
|
6e16f6 |
- adjust_timer += 1;
|
|
|
6e16f6 |
- adj_host_clock();
|
|
|
6e16f6 |
+ adjust_timer += time_elapsed;
|
|
|
6e16f6 |
+ adj_host_clock(time_elapsed);
|
|
|
6e16f6 |
#ifdef REFCLOCK
|
|
|
6e16f6 |
for (n = 0; n < NTP_HASH_SIZE; n++) {
|
|
|
6e16f6 |
for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
|
|
|
6e16f6 |
@@ -286,7 +397,7 @@ timer(void)
|
|
|
6e16f6 |
* 128 s or less.
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
if (peer->throttle > 0)
|
|
|
6e16f6 |
- peer->throttle--;
|
|
|
6e16f6 |
+ peer->throttle -= min(peer->throttle, time_elapsed);
|
|
|
6e16f6 |
if (peer->nextdate <= current_time) {
|
|
|
6e16f6 |
#ifdef REFCLOCK
|
|
|
6e16f6 |
if (peer->flags & FLAG_REFCLOCK)
|
|
|
6e16f6 |
@@ -333,7 +444,7 @@ timer(void)
|
|
|
6e16f6 |
* set.
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
if (leapsec > 0) {
|
|
|
6e16f6 |
- leapsec--;
|
|
|
6e16f6 |
+ leapsec -= min(leapsec, time_elapsed);
|
|
|
6e16f6 |
if (leapsec == 0) {
|
|
|
6e16f6 |
sys_leap = LEAP_NOWARNING;
|
|
|
6e16f6 |
sys_tai = leap_tai;
|
|
|
6e16f6 |
@@ -398,11 +509,15 @@ timer(void)
|
|
|
6e16f6 |
* Finally, write hourly stats.
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
if (stats_timer <= current_time) {
|
|
|
6e16f6 |
+ l_fp sys_time;
|
|
|
6e16f6 |
+ get_systime(&sys_time);
|
|
|
6e16f6 |
stats_timer += HOUR;
|
|
|
6e16f6 |
write_stats();
|
|
|
6e16f6 |
if (sys_tai != 0 && sys_time.l_ui > leap_expire)
|
|
|
6e16f6 |
report_event(EVNT_LEAPVAL, NULL, NULL);
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ time_elapsed = 0;
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
|
|
|
6e16f6 |
diff -up ntp-4.2.6p1/ntpd/ntpd.c.sleep ntp-4.2.6p1/ntpd/ntpd.c
|
|
|
6e16f6 |
--- ntp-4.2.6p1/ntpd/ntpd.c.sleep 2010-03-10 19:27:46.000000000 +0100
|
|
|
6e16f6 |
+++ ntp-4.2.6p1/ntpd/ntpd.c 2010-03-10 19:27:46.000000000 +0100
|
|
|
6e16f6 |
@@ -195,8 +195,6 @@ extern const char *Version;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
char const *progname;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
-int was_alarmed;
|
|
|
6e16f6 |
-
|
|
|
6e16f6 |
#ifdef DECL_SYSCALL
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* We put this here, since the argument profile is syscall-specific
|
|
|
6e16f6 |
@@ -1033,7 +1031,7 @@ getgroup:
|
|
|
6e16f6 |
#else /* normal I/O */
|
|
|
6e16f6 |
|
|
|
6e16f6 |
BLOCK_IO_AND_ALARM();
|
|
|
6e16f6 |
- was_alarmed = 0;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
for (;;)
|
|
|
6e16f6 |
{
|
|
|
6e16f6 |
# if !defined(HAVE_SIGNALED_IO)
|
|
|
6e16f6 |
@@ -1041,42 +1039,39 @@ getgroup:
|
|
|
6e16f6 |
extern int maxactivefd;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
fd_set rdfdes;
|
|
|
6e16f6 |
- int nfound;
|
|
|
6e16f6 |
-# endif
|
|
|
6e16f6 |
+ int nfound, time_elapsed;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
- if (alarm_flag) /* alarmed? */
|
|
|
6e16f6 |
- {
|
|
|
6e16f6 |
- was_alarmed = 1;
|
|
|
6e16f6 |
- alarm_flag = 0;
|
|
|
6e16f6 |
- }
|
|
|
6e16f6 |
+ time_elapsed = 0;
|
|
|
6e16f6 |
+# endif
|
|
|
6e16f6 |
|
|
|
6e16f6 |
- if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE)
|
|
|
6e16f6 |
+ if (has_full_recv_buffer() == ISC_FALSE)
|
|
|
6e16f6 |
{
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* Nothing to do. Wait for something.
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
# ifndef HAVE_SIGNALED_IO
|
|
|
6e16f6 |
+ double timeout;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
rdfdes = activefds;
|
|
|
6e16f6 |
-# if defined(VMS) || defined(SYS_VXWORKS)
|
|
|
6e16f6 |
- /* make select() wake up after one second */
|
|
|
6e16f6 |
- {
|
|
|
6e16f6 |
- struct timeval t1;
|
|
|
6e16f6 |
+ get_systime(&now;;
|
|
|
6e16f6 |
+ timeout = get_timeout(&now;;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
- t1.tv_sec = 1; t1.tv_usec = 0;
|
|
|
6e16f6 |
+ if (timeout > 0.0) {
|
|
|
6e16f6 |
+ struct timeval t1;
|
|
|
6e16f6 |
+
|
|
|
6e16f6 |
+ t1.tv_sec = timeout;
|
|
|
6e16f6 |
+ t1.tv_usec = (timeout - t1.tv_sec) * 1000000;
|
|
|
6e16f6 |
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
|
|
|
6e16f6 |
(fd_set *)0, &t1;;
|
|
|
6e16f6 |
- }
|
|
|
6e16f6 |
-# else
|
|
|
6e16f6 |
- nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
|
|
|
6e16f6 |
- (fd_set *)0, (struct timeval *)0);
|
|
|
6e16f6 |
-# endif /* VMS */
|
|
|
6e16f6 |
- if (nfound > 0)
|
|
|
6e16f6 |
- {
|
|
|
6e16f6 |
- l_fp ts;
|
|
|
6e16f6 |
+ get_systime(&now;;
|
|
|
6e16f6 |
+ } else
|
|
|
6e16f6 |
+ nfound = 0;
|
|
|
6e16f6 |
|
|
|
6e16f6 |
- get_systime(&ts);
|
|
|
6e16f6 |
+ time_elapsed = timer_elapsed(now, timeout);
|
|
|
6e16f6 |
|
|
|
6e16f6 |
- (void)input_handler(&ts);
|
|
|
6e16f6 |
+ if (nfound > 0)
|
|
|
6e16f6 |
+ {
|
|
|
6e16f6 |
+ (void)input_handler(&now;;
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
else if (nfound == -1 && errno != EINTR)
|
|
|
6e16f6 |
msyslog(LOG_ERR, "select() error: %m");
|
|
|
6e16f6 |
@@ -1085,17 +1080,13 @@ getgroup:
|
|
|
6e16f6 |
msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
|
|
|
6e16f6 |
# endif /* DEBUG */
|
|
|
6e16f6 |
# else /* HAVE_SIGNALED_IO */
|
|
|
6e16f6 |
+# error not supported by sleep patch
|
|
|
6e16f6 |
|
|
|
6e16f6 |
wait_for_signal();
|
|
|
6e16f6 |
# endif /* HAVE_SIGNALED_IO */
|
|
|
6e16f6 |
- if (alarm_flag) /* alarmed? */
|
|
|
6e16f6 |
- {
|
|
|
6e16f6 |
- was_alarmed = 1;
|
|
|
6e16f6 |
- alarm_flag = 0;
|
|
|
6e16f6 |
- }
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
- if (was_alarmed)
|
|
|
6e16f6 |
+ if (time_elapsed > 0)
|
|
|
6e16f6 |
{
|
|
|
6e16f6 |
UNBLOCK_IO_AND_ALARM();
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
@@ -1103,7 +1094,6 @@ getgroup:
|
|
|
6e16f6 |
* to process expiry.
|
|
|
6e16f6 |
*/
|
|
|
6e16f6 |
timer();
|
|
|
6e16f6 |
- was_alarmed = 0;
|
|
|
6e16f6 |
BLOCK_IO_AND_ALARM();
|
|
|
6e16f6 |
}
|
|
|
6e16f6 |
|
|
|
6e16f6 |
@@ -1121,19 +1111,8 @@ getgroup:
|
|
|
6e16f6 |
rbuf = get_full_recv_buffer();
|
|
|
6e16f6 |
while (rbuf != NULL)
|
|
|
6e16f6 |
{
|
|
|
6e16f6 |
- if (alarm_flag)
|
|
|
6e16f6 |
- {
|
|
|
6e16f6 |
- was_alarmed = 1;
|
|
|
6e16f6 |
- alarm_flag = 0;
|
|
|
6e16f6 |
- }
|
|
|
6e16f6 |
UNBLOCK_IO_AND_ALARM();
|
|
|
6e16f6 |
|
|
|
6e16f6 |
- if (was_alarmed)
|
|
|
6e16f6 |
- { /* avoid timer starvation during lengthy I/O handling */
|
|
|
6e16f6 |
- timer();
|
|
|
6e16f6 |
- was_alarmed = 0;
|
|
|
6e16f6 |
- }
|
|
|
6e16f6 |
-
|
|
|
6e16f6 |
/*
|
|
|
6e16f6 |
* Call the data procedure to handle each received
|
|
|
6e16f6 |
* packet.
|