From: Harlan Stenn Date: Mon, 21 May 2007 04:29:26 +0000 (-0400) Subject: [Bug 808] Only write the drift file if we are in state 4 X-Git-Tag: NTP_4_2_5P35~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36385cacce7de348513c5e516aab2e6f56a05b78;p=thirdparty%2Fntp.git [Bug 808] Only write the drift file if we are in state 4 bk: 46512026ogiF0i6ITK52B_tfI82IOg --- diff --git a/ChangeLog b/ChangeLog index 69a3e885a..8b4f9ea35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 808] Only write the drift file if we are in state 4. * Initial import of libisc/log.c and friends. * [Bug 826] Fix redefinition of PI. * [Bug 825] ntp_scanner.c needs to #include . diff --git a/ntpd/ntp_util.c b/ntpd/ntp_util.c index 1934a5c6b..6c2fdce4d 100644 --- a/ntpd/ntp_util.c +++ b/ntpd/ntp_util.c @@ -221,40 +221,43 @@ write_stats(void) } prev_drift_comp = drift_comp; if (stats_drift_file != 0) { - if ((fp = fopen(stats_temp_file, "w")) == NULL) { - msyslog(LOG_ERR, "can't open %s: %m", - stats_temp_file); - return; - } - fprintf(fp, "%.3f\n", drift_comp * 1e6); - (void)fclose(fp); - /* atomic */ + if (state == 4) { + if ((fp = fopen(stats_temp_file, "w")) == NULL) { + msyslog(LOG_ERR, "can't open %s: %m", + stats_temp_file); + return; + } + fprintf(fp, "%.3f\n", drift_comp * 1e6); + (void)fclose(fp); + /* atomic */ #ifdef SYS_WINNT - (void) _unlink(stats_drift_file); /* rename semantics differ under NT */ + (void) _unlink(stats_drift_file); /* rename semantics differ under NT */ #endif /* SYS_WINNT */ #ifndef NO_RENAME - (void) rename(stats_temp_file, stats_drift_file); + (void) rename(stats_temp_file, stats_drift_file); #else - /* we have no rename NFS of ftp in use */ - if ((fp = fopen(stats_drift_file, "w")) == NULL) { - msyslog(LOG_ERR, "can't open %s: %m", - stats_drift_file); - return; - } - + /* we have no rename NFS of ftp in use */ + if ((fp = fopen(stats_drift_file, "w")) == NULL) { + msyslog(LOG_ERR, "can't open %s: %m", + stats_drift_file); + return; + } #endif #if defined(VMS) - /* PURGE */ - { - $DESCRIPTOR(oldvers,";-1"); - struct dsc$descriptor driftdsc = { - strlen(stats_drift_file),0,0,stats_drift_file }; + /* PURGE */ + { + $DESCRIPTOR(oldvers,";-1"); + struct dsc$descriptor driftdsc = { + strlen(stats_drift_file),0,0,stats_drift_file }; - while(lib$delete_file(&oldvers,&driftdsc) & 1) ; - } + while(lib$delete_file(&oldvers,&driftdsc) & 1); + } #endif + } else { + /* XXX: Log a message at INFO level */ + } } }