[Git][NTPsec/ntpsec][master] Isolate the ntpd main loop into a mainloop() function.
Eric S. Raymond
gitlab at mg.gitlab.com
Fri Dec 4 10:23:52 UTC 2015
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
804a57f9 by Eric S. Raymond at 2015-12-04T05:12:37Z
Isolate the ntpd main loop into a mainloop() function.
Also moves timer setup into the beginning of this function, and makes
timer reinitialization in the loopfilter contingent on not being in
replay mode.
Though simple, this change is a major step towards implementing replay mode.
- - - - -
2 changed files:
- ntpd/ntp_loopfilter.c
- ntpd/ntpd.c
Changes:
=====================================
ntpd/ntp_loopfilter.c
=====================================
--- a/ntpd/ntp_loopfilter.c
+++ b/ntpd/ntp_loopfilter.c
@@ -630,7 +630,8 @@ local_clock(
fp_offset);
report_event(EVNT_CLOCKRESET, NULL, tbuf);
step_systime(fp_offset);
- reinit_timer();
+ if (intercept_get_mode() != replay)
+ reinit_timer();
tc_counter = 0;
clock_jitter = LOGTOD(sys_precision);
rval = 2;
=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -135,6 +135,7 @@ char ** saved_argv;
#ifndef SIM
int ntpdmain (int, char **);
+static void mainloop (void);
static void set_process_priority (void);
static void assertion_failed (const char *, int,
isc_assertiontype_t,
@@ -544,7 +545,6 @@ ntpdmain(
char *argv[]
)
{
- struct recvbuf *rbuf;
mode_t uv;
uid_t uid;
# if defined(HAVE_WORKING_FORK)
@@ -754,7 +754,6 @@ ntpdmain(
init_util();
init_restrict();
init_mon();
- init_timer();
init_control();
init_peer();
# ifdef REFCLOCK
@@ -922,8 +921,20 @@ ntpdmain(
msyslog(LOG_INFO, "running as non-root disables dynamic interface tracking");
}
-# ifdef HAVE_IO_COMPLETION_PORT
+ mainloop();
+ return 1;
+}
+
+/*
+ * Process incoming packets until exit or interrupted.
+ */
+static void mainloop(void)
+{
+ struct recvbuf *rbuf;
+ init_timer();
+
+# ifdef HAVE_IO_COMPLETION_PORT
for (;;) {
GetReceivedBuffers();
# else /* normal I/O */
@@ -1043,7 +1054,6 @@ ntpdmain(
}
UNBLOCK_IO_AND_ALARM();
- return 1;
}
#endif /* !SIM */
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/804a57f98785806e6393056d249b47b6a0836f60
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151204/9e5d90f5/attachment.html>
More information about the vc
mailing list