---
-* [Bug 3846] Use -Wno-format-truncation by default.
+* [Bug 3849] ntpd --wait-sync times out. <hart@ntp.org>
+* [Bug 3846] Use -Wno-format-truncation by default. <hart@ntp.org>
* [Bug 3841] 4.2.8p17 build break w/ gcc 12 -Wformat-security without -Wformat
Need to remove --Wformat-security when removing -Wformat to
silence numerous libopts warnings. <hart@ntp.org>
* [Bug 3837] NULL pointer deref crash when ntpd deletes last interface.
Reported by renmingshuai. Correct UNLINK_EXPR_SLIST() when the
list is empty. <hart@ntp.org>
-* [Bug 3835] NTP_HARD_*FLAGS not used by libevent tearoff.
+* [Bug 3835] NTP_HARD_*FLAGS not used by libevent tearoff. <hart@ntp.org>
* [Bug 3831] pollskewlist zeroed on runtime configuration. <hart@ntp.org>
* [Bug 3830] configure libevent check intersperses output with answer. <stenn@>
* [Bug 3828] BK should ignore a git repo in the same directory.
...
)
{
- char buf[1024];
va_list ap;
va_start(ap, fmt);
- mvsnprintf(buf, sizeof(buf), fmt, ap);
+ mvsyslog(level, fmt, ap);
va_end(ap);
- addto_syslog(level, buf);
}
+
void
mvsyslog(
int level,
)
{
char buf[1024];
+
mvsnprintf(buf, sizeof(buf), fmt, ap);
addto_syslog(level, buf);
}
tc_counter));
if (trans != state && trans != EVNT_FSET)
report_event(trans, NULL, NULL);
+#ifdef HAVE_WORKING_FORK
+ if (trans != state && EVNT_SYNC == trans) {
+ /*
+ * If our parent process is waiting for the
+ * first clock sync, send them home satisfied.
+ */
+ if (daemon_pipe[1] != -1) {
+ if (2 != write(daemon_pipe[1], "S\n", 2)) {
+ msyslog(LOG_ERR, "daemon failed to notify parent ntpd (--wait-sync)");
+ }
+ close(daemon_pipe[1]);
+ daemon_pipe[1] = -1;
+ }
+ }
+#endif /* HAVE_WORKING_FORK */
+
state = trans;
last_offset = clock_offset = offset;
clock_epoch = current_time;
if (crypto_flags)
crypto_update();
#endif /* AUTOKEY */
- /*
- * If our parent process is waiting for the
- * first clock sync, send them home satisfied.
- */
-#ifdef HAVE_WORKING_FORK
- if (daemon_pipe[1] != -1) {
- if (2 != write(daemon_pipe[1], "S\n", 2)) {
- msyslog(LOG_ERR, "daemon failed to notify parent ntpd (--wait-sync)");
- }
- close(daemon_pipe[1]);
- daemon_pipe[1] = -1;
- DPRINTF(1, ("notified parent --wait-sync is done\n"));
- }
-#endif /* HAVE_WORKING_FORK */
}
sys_clockhop = 0;
} else if ((x = fabs(typesystem->offset -
osys_peer->offset)) < sys_mindisp) {
- if (sys_clockhop == 0)
+ if (0 == sys_clockhop)
sys_clockhop = sys_mindisp;
else
sys_clockhop *= .5;
DPRINTF(1, ("select: clockhop %d %.6f %.6f\n",
j, x, sys_clockhop));
- if (fabs(x) < sys_clockhop)
+ if (x < sys_clockhop)
typesystem = osys_peer;
else
sys_clockhop = 0;
pipe[1] = -1;
exit_code = wait_child_sync_if(
pipe[0], wait_sync);
- DPRINTF(1, ("sync_if: rc=%d\n", exit_code));
if (exit_code <= 0) {
/* probe daemon exit code -- wait for
* child process if we have an unexpected
*/
exit_code = wait_child_exit_if(
cpid, (exit_code < 0));
- DPRINTF(1, ("exit_if: rc=%d\n", exit_code));
}
}
exit(exit_code);
#if defined(SYS_WINNT)
ntservice_isup();
#elif defined(HAVE_WORKING_FORK)
- if (daemon_pipe[1] != -1) {
+ if (daemon_pipe[1] != -1 && 0 == wait_sync) {
if (2 != write(daemon_pipe[1], "R\n", 2)) {
msyslog(LOG_ERR, "daemon failed to notify parent ntpd after init");
}
}
rc = read(pipe_read_fd, &ch, 1);
if (rc == 0) {
- DPRINTF(2, ("daemon control: got EOF\n"));
+ /* DPRINTF is useless here as -d/-D disable forking */
+ fprintf(stderr, "daemon control: got EOF\n");
return -1; /* unexpected EOF, check daemon */
} else if (rc == 1) {
- DPRINTF(2, ("daemon control: got '%c'\n",
- (ch >= ' ' ? ch : '.')));
- if (ch == 'R' && !wait_sync)
- return 0;
- if (ch == 'S' && wait_sync)
+ if ( ('S' == ch && wait_sync > 0)
+ || ('R' == ch && 0 == wait_sync)) {
return 0;
+ }
} else {
- DPRINTF(2, ("daemon control: read 1 char failed: %s\n",
- strerror(errno)));
+ mfprintf(stderr, "%s: daemon control: read 1 char failed: %m\n",
+ progname);
+ msyslog(LOG_ERR, "daemon control: read 1 char failed: %m");
return EX_IOERR;
}
} while (wait_rem > 0);
- if (wait_sync) {
+ if (wait_sync > 0) {
fprintf(stderr, "%s: -w/--wait-sync %ld timed out.\n",
progname, wait_sync);
+ msyslog(LOG_ERR, "-w/--wait-sync %ld timed out.", wait_sync);
return EX_PROTOCOL;
} else {
fprintf(stderr, "%s: daemon startup monitoring timed out.\n",
progname);
+ msyslog(LOG_ERR, "daemon startup monitoring timed out.");
return 0;
}
}
int rc = 0;
int wstatus;
if (cpid == waitpid(cpid, &wstatus, (blocking ? 0 : WNOHANG))) {
- DPRINTF(1, ("child (pid=%d) dead now\n", cpid));
if (WIFEXITED(wstatus)) {
rc = WEXITSTATUS(wstatus);
msyslog(LOG_ERR, "daemon child exited with code %d",
rc = EX_SOFTWARE;
msyslog(LOG_ERR, "daemon child died with unknown cause");
}
- } else {
- DPRINTF(1, ("child (pid=%d) still alive\n", cpid));
}
return rc;
# else
ntpsnmpd-opts.c ntpsnmpd-opts.h ntpSnmpSubagentObject.h \
ntp_snmp.h
# HMS: we probably want a version.o file here, too.
-LDADD = ../ntpq/libntpq.a ../libntp/libntp.a
-LDADD += $(SNMP_LIBS) $(LDADD_LIBNTP) $(LIBM)
-LDADD += $(PTHREAD_LIBS) $(LDADD_NTP) $(LIBOPTS_LDADD)
+ntpsnmpd_LDADD = ../ntpq/libntpq.a ../libntp/libntp.a
+ntpsnmpd_LDADD += $(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS)
+ntpsnmpd_LDADD += $(LDADD_NTP) $(LIBOPTS_LDADD) $(SNMP_LIBS)
AM_CFLAGS = $(SNMP_CFLAGS) $(CFLAGS_NTP)
AM_CFLAGS += $(NTP_HARD_CFLAGS)