[Git][NTPsec/ntpsec][master] TESTFRAME: on replay, skip certain operations before mainloop.
Eric S. Raymond
gitlab at mg.gitlab.com
Wed Sep 14 16:46:47 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
bff64f91 by Eric S. Raymond at 2016-09-14T12:45:33-04:00
TESTFRAME: on replay, skip certain operations before mainloop.
- - - - -
3 changed files:
- ntpd/ntp_intercept.c
- ntpd/ntp_intercept.h
- ntpd/ntpd.c
Changes:
=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -928,13 +928,20 @@ int intercept_open_socket(sockaddr_u *addr,
return sock;
}
-void intercept_replay(void)
+bool intercept_replay(void)
{
- printf("# entering replay loop at line %d\n", lineno);
+ if (mode == capture)
+ fputs("mainloop\n", stdout);
+ if (mode != replay)
+ return false; /* fall through to normal mail loop */
+
for (;;) {
get_operation(NULL);
- if (strncmp(linebuf, "finish", 7) == 0)
+ if (strncmp(linebuf, "mainloop", 8) == 0)
break;
+ else if (strncmp(linebuf, "getaddrinfo ", 12) == 0)
+ /* DNS lookups for initial configuration */
+ continue;
else if (strncmp(linebuf, "sendpkt ", 8) == 0)
/*
* If we get here, this is a sendpkt generated not by the protocol
@@ -943,17 +950,10 @@ void intercept_replay(void)
*/
continue;
else
- {
- char errbuf[BUFSIZ], *cp;
- strlcpy(errbuf, linebuf, sizeof(errbuf));
- cp = strchr(errbuf, ' ');
- if (cp != NULL)
- *cp = '\0';
- fprintf(stderr, "ntpd: unexpected operation '%s' at line %d\n",
- errbuf, lineno);
- exit(1);
- }
+ replay_fail("unexpected operation before mainloop\n");
}
+
+ return true; /* don't do normal main loop */
}
void
=====================================
ntpd/ntp_intercept.h
=====================================
--- a/ntpd/ntp_intercept.h
+++ b/ntpd/ntp_intercept.h
@@ -38,7 +38,7 @@ int intercept_set_tod(struct timespec *tvs);
extern bool intercept_leapsec_load_file(const char * fname, struct stat * sb,
bool force, bool logall);
void intercept_getauthkeys(const char *);
-void intercept_replay(void);
+bool intercept_replay(void);
void intercept_exit(const int);
/* end */
=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -900,10 +900,8 @@ ntpdmain(
msyslog(LOG_INFO, "running as non-root disables dynamic interface tracking");
}
#endif
-
- if (intercept_get_mode() == replay)
- intercept_replay();
- else
+
+ if (!intercept_replay())
mainloop();
return 1;
}
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/bff64f91ed8846cc01f700965bbacdb588a87a70
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160914/657487da/attachment.html>
More information about the vc
mailing list