Deleted Added
sdiff udiff text old ( 106163 ) new ( 132451 )
full compact
1/*
2 * ntp_timer.c - event timer support routines
3 */
4#ifdef HAVE_CONFIG_H
5# include <config.h>
6#endif
7
8#include "ntp_machine.h"

--- 9 unchanged lines hidden (view full) ---

18# include <unistd.h>
19#endif
20
21#if defined(HAVE_IO_COMPLETION_PORT)
22# include "ntp_iocompletionport.h"
23# include "ntp_timer.h"
24#endif
25
26#ifdef PUBKEY
27#include "ntp_crypto.h"
28#endif /* PUBKEY */
29
30/*
31 * These routines provide support for the event timer. The timer is
32 * implemented by an interrupt routine which sets a flag once every
33 * 2**EVENT_TIMEOUT seconds (currently 4), and a timer routine which
34 * is called when the mainline code gets around to seeing the flag.
35 * The timer routine dispatches the clock adjustment code if its time
36 * has come, then searches the timer queue for expiries which are
37 * dispatched to the transmit procedure. Finally, we call the hourly

--- 7 unchanged lines hidden (view full) ---

45
46/*
47 * The counters
48 */
49static u_long adjust_timer; /* second timer */
50static u_long keys_timer; /* minute timer */
51static u_long hourly_timer; /* hour timer */
52static u_long huffpuff_timer; /* huff-n'-puff timer */
53#ifdef AUTOKEY
54static u_long revoke_timer; /* keys revoke timer */
55u_long sys_revoke = 1 << KEY_REVOKE; /* keys revoke timeout */
56#endif /* AUTOKEY */
57
58/*
59 * Statistics counter for the interested.
60 */
61volatile u_long alarm_overflow;
62
63#define MINUTE 60
64#define HOUR (60*60)

--- 13 unchanged lines hidden (view full) ---

78#endif /* VMS */
79
80#if defined SYS_WINNT
81static HANDLE WaitableTimerHandle = NULL;
82#else
83static RETSIGTYPE alarming P((int));
84#endif /* SYS_WINNT */
85
86
87/*
88 * init_timer - initialize the timer data structures
89 */
90void
91init_timer(void)
92{
93#if !defined(VMS)
94# if !defined SYS_WINNT || defined(SYS_CYGWIN32)
95# ifndef HAVE_TIMER_SETTIME
96 struct itimerval itimer;
97# else
98 static timer_t ntpd_timerid; /* should be global if we ever want */
99 /* to kill timer without rebooting ... */
100 struct itimerspec itimer;
101# endif /* HAVE_TIMER_SETTIME */
102# else /* SYS_WINNT */
103 HANDLE hToken;
104 TOKEN_PRIVILEGES tkp;
105# endif /* SYS_WINNT */
106#endif /* !VMS */
107
108 /*
109 * Initialize...
110 */
111 alarm_flag = 0;
112 alarm_overflow = 0;
113 adjust_timer = 1;
114 hourly_timer = HOUR;

--- 98 unchanged lines hidden (view full) ---

213
214/*
215 * timer - dispatch anyone who needs to be
216 */
217void
218timer(void)
219{
220 register struct peer *peer, *next_peer;
221 u_int n;
222
223 current_time += (1<<EVENT_TIMEOUT);
224
225 /*
226 * Adjustment timeout first.
227 */
228 if (adjust_timer <= current_time) {
229 adjust_timer += 1;
230 adj_host_clock();
231 }
232
233 /*
234 * Now dispatch any peers whose event timer has expired. Be careful
235 * here, since the peer structure might go away as the result of
236 * the call.
237 */
238 for (n = 0; n < HASH_SIZE; n++) {

--- 25 unchanged lines hidden (view full) ---

264 /*
265 * Huff-n'-puff filter
266 */
267 if (huffpuff_timer <= current_time) {
268 huffpuff_timer += HUFFPUFF;
269 huffpuff();
270 }
271
272#ifdef AUTOKEY
273 /*
274 * Garbage collect old keys and generate new private value
275 */
276 if (revoke_timer <= current_time) {
277 revoke_timer += sys_revoke;
278 expire_all();
279#ifdef DEBUG
280 if (debug)
281 printf("key expire: at %lu next %lu\n",
282 current_time, revoke_timer);
283#endif
284 }
285#endif /* AUTOKEY */
286
287 /*
288 * Finally, call the hourly routine.
289 */
290 if (hourly_timer <= current_time) {
291 hourly_timer += HOUR;
292 hourly_stats();
293 }

--- 42 unchanged lines hidden ---